91.3k views
5 votes
In PyCharm, write a program that prompts the user for their name and age. Your program

should then tell the user the year they were born. Here is a sample execution of the program
with the user input in bold:
What is your name? Amanda
How old are you? 21
Hello Amanda! You were born in 2001.
1. Write the program. Format your code using best practices. You can refer to the zyBooks
style guide, if needed, to use proper naming conventions for variables and methods. Use the
most appropriate statements with minimal extraneous elements, steps, or procedures.
2. Run the program.
3. Debug the program. Be sure your code produces the correct results.
4. Save and submit your file.

User Vatine
by
4.8k points

1 Answer

1 vote

Program to prompt user for name and age and then tell them the year they were born

prompt user for name

name = input("What is your name? ")

prompt user for age

age = input("How old are you? ")

calculate year of birth

year_of_birth = 2022 - int(age)

print message to user

print("Hello " + name + "! You were born in " + str(year_of_birth) + ".")

User Mttrb
by
5.3k points