Question

plz answers these short Qs in python language Q1-Given the String variable address, write an expression...

plz answers these short Qs in python language

Q1-Given the String variable address, write an expression that returns the position of the first occurrence of the String "Avenue" in address.

Q2-Write a sequence of statements that finds the first comma in the string associated with the variable line, and associates the variable clause the portion of line up to, but not including the comma.

Q3-Assume that sentence is a variable that has been associated with a string consisting of words separated by single space characters with a period at the end. For example: "This is a possible value of sentence."

Write the statements needed so that the variable secondWord is associated with the second word of the value of sentence . So, if the value of sentence were "Broccoli is delicious." your code would associate secondWord with the value "is" .

Q4-Write an expression whose value is the result of converting the int value 42 to a str (consisting of the digit 4 followed by the digit 2).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. address.find("Avenue")
2. line.split(',')[0]
3. secondWord= sentence.split(' ')[1]
4 str(42)

Here is the program

address = "This is a possible Avenue of sentence."
z = address.find( "Avenue" )
print (z)

line = "This, is, a, possible, Avenue, of, sentence."
clause = line.split(',')[0]
print(clause)

sentence = "Broccoli is delicious."
secondWord = sentence.split(' ')[1]
print("secondWord = ", secondWord)

y = str(42)
print (y)

Below is the screenshot of the outputs along with program

main.py 1 2 address This is a possible Avenue of sentence. 3 z address.find Avenue 4 print (z) 6 line - This, is, a, pos

Add a comment
Know the answer?
Add Answer to:
plz answers these short Qs in python language Q1-Given the String variable address, write an expression...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT