Skip to content

Instantly share code, notes, and snippets.

@Gwith
Created August 11, 2016 17:35
Show Gist options
  • Select an option

  • Save Gwith/b912207ad7e17da7342f60709ce6c99b to your computer and use it in GitHub Desktop.

Select an option

Save Gwith/b912207ad7e17da7342f60709ce6c99b to your computer and use it in GitHub Desktop.
# 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