Python Jupyter Notebook
Write a program that prompts the user to enter his/her first
name, last name, and year of birth in a single string (in the
format: fn;ln;yyyy), then calculates the age tell
it to him/her after greeting him/her using the first name.
Make sure to capitalize the user's first name, regardless of how
he/she typed it in.
Hint: review Exercise 1!
Example:
Enter your first name, last name, and birth year (in format
fn;ln;yyyy): alex;smith;1994
Hi Alex, you are 26 years old!
Python code:
#accepting first name,last name and year
fn,ln,year=input("Enter your first name, last name, and birth year
(in format fn;ln;yyyy): ").split(";")
#printing how old he is
print("Hi {}, you are {} years
old!".format(fn.capitalize(),2020-int(year)))
Screenshot:
Input and Output:
Get Answers For Free
Most questions answered within 1 hours.