Skip to content

Instantly share code, notes, and snippets.

@pdbartsch
Last active February 5, 2019 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdbartsch/5adf1c19bd8721054c955946942986e0 to your computer and use it in GitHub Desktop.
Save pdbartsch/5adf1c19bd8721054c955946942986e0 to your computer and use it in GitHub Desktop.
# https://www.practicepython.org/exercise/2014/01/29/01-character-input.html
import datetime
import math
name = input("Hey Bud! What's your name? ")
# by converting to float before forcing to int I avoid errors when user inputs decimal
age = int(float(input("Hi! "+ name +" How old are you? ")))
# round up to make sure number isn't 0
mult = math.ceil(float(input("Please enter a number. ")))
# get the current year
now = datetime.datetime.now()
year = (100 - age) + now.year
if age >= 100:
print("Looks like you've already reached 100. Way to go!.")
elif mult >10:
print(("Good news "+ name +"! You'll be turning 100 years old in either "\
+ str(year-1) + " or " + str(year) + '! \n')*10)
else:
print(("Good news "+ name +"! You'll be turning 100 years old in either "\
+ str(year-1) + " or " + str(year) + '! \n')*mult)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment