Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from datetime import datetime
- """
- 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.
- Extras:
- Add on to the previous program by asking the user for another number and printing out that many copies of the previous message. (Hint: order of operations exists in Python)
- Print out that many copies of the previous message on separate lines. (Hint: the string "\n is the same as pressing the ENTER button)
- """
- def ask_age():
- your_name = raw_input("Your name: ")
- your_age = int(raw_input("Your age: " or 0))
- left_age = datetime.now().year - your_age + 100
- print "\nYour name is: %s" % your_name
- print "Your age is: %d years old. You will be 100 years old in the year %d\n" % (your_age, left_age)
- ask_age()
- ask_age()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement