Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. def main(): #The main function
  2. print('Hello,\nI am going to ask you your name, and your age. ' +
  3. 'After that, I will tell you what year you were born, and what year you will turn 100!\n')
  4.  
  5. #Local functions
  6. def get_age(): #Gets the age of the user
  7. age = input('Please enter your age: ')
  8.  
  9. #Convert age into a number
  10. if str.isdigit(age):
  11. return int(age)
  12. else:
  13. print('Make sure you only enter numbers!\n')
  14. return get_age()
  15.  
  16. #Get information
  17. name = input('Please enter your name: ')
  18. age = get_age()
  19. current_year = 2016
  20. birth_year = current_year - age
  21. years_till_hundred = 100 - age
  22. year_at_hundred = current_year + years_till_hundred
  23.  
  24. print('Okay \'' + name + '\', we have everything done now.\n' +
  25. 'Your current age is: ' + str(age) + '\n' +
  26. 'Your birth year was: ' + str(birth_year) + '\n' +
  27. 'You have this many years until you turn 100: ' + str(years_till_hundred) + '\n' +
  28. 'You will turn 100 in: ' + str(year_at_hundred) + '\n')
  29.  
  30. if __name__ == '__main__':
  31. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement