38.8k views
5 votes
Write some code that reads in a name and an age into the variables name and age. It then prints the message "The age of NAME is AGE" on a line by itself, where NAME and AGE represent the values read into the variables name and age respectively.

For example, if your code read in "Rohit" and 70 then it would print out "The age of Rohit is 70" on a line by itself. There should NOT be a period in the output.
please use python to answer this!!
Given the String variable address, write an expression that returns the position of the first occurrence of the String"Avenue" in the address.

User Shavone
by
8.0k points

1 Answer

3 votes

Final answer:

To read a name and an age and print them in Python, use input() and print(). To find the first occurrence of 'Avenue' in an address, use the find() method on the string.

Step-by-step explanation:

To read a name and an age into the variables name and age, and then print a message with these variables, you can use Python code similar to the following example:

name = input('Please enter your name: ')
age = int(input('Please enter your age: '))
print(f'The age of {name} is {age}')

For finding the position of the string "Avenue" within another string variable called address, the Python code would be:

position = address.find('Avenue')
print(position)

The 'find' method returns the lowest index in the string where the specified substring is found.

User Michael Balint
by
7.8k points

No related questions found