Created
August 11, 2016 17:35
-
-
Save Gwith/b912207ad7e17da7342f60709ce6c99b 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 | |
| try: | |
| age = int(input("What is your age?\n")) #grab user age and change to int | |
| 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