Created
August 11, 2016 17:39
-
-
Save Gwith/08daa8dcaa1bd5c6c8f175c16f0a4a92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Calculate when user will be 100 years old | |
| import datetime #import datetime to grab year. | |
| name = input("What is your name?\n") #grab input of user 'name' | |
| name = name.replace(name[0], name[0].upper()) #replace first letter with capitol | |
| age = 0 | |
| while True: | |
| try: | |
| age = int(input("What is your age?\n")) #grab user age and change to int | |
| break | |
| except ValueError: | |
| print("You need to enter in a numerical digit") | |
| now = datetime.datetime.now() #grab current date | |
| year = str((now.year - age) + 100) #calculate user will be 100 | |
| print('Your name is ' + name + ' and your age is ' + str(age) +'.') | |
| print(name + " will be 100 years old in the year " + year) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment