Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. from datetime import datetime
  2.  
  3. """
  4. 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.
  5.  
  6. Extras:
  7.  
  8. 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)
  9. Print out that many copies of the previous message on separate lines. (Hint: the string "\n is the same as pressing the ENTER button)
  10. """
  11.  
  12. def ask_age():
  13. your_name = raw_input("Your name: ")
  14. your_age = int(raw_input("Your age: " or 0))
  15.  
  16. left_age = datetime.now().year - your_age + 100
  17.  
  18. print "\nYour name is: %s" % your_name
  19. print "Your age is: %d years old. You will be 100 years old in the year %d\n" % (your_age, left_age)
  20. ask_age()
  21.  
  22. ask_age()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement