Last active
February 5, 2019 21:08
-
-
Save pdbartsch/5adf1c19bd8721054c955946942986e0 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
# 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