PYTHON Exercise 1 Input & Print

Exercise 1 - Input & Print

'''
Exercise:
Create a program that asks the user to enter their name and their age.
Print out a message addressed to them that tells them the year that they will turn 100 years old.
'''

Code:

# code:
name = input ('Please enter your name:')
age = int(input ('Please enter your age:'))
yearof100=2019+100-age
# print ('Hi, %s, You will be 100 years old in year %d'%(name, yearof100))    or
print ('Dear Mr/Ms ' + name + ', you will be 100 years old in ' + str(yearof100) + '\n' )

猜你喜欢

转载自blog.csdn.net/Schatzke/article/details/87130855