Skip to content

Instantly share code, notes, and snippets.

@losbaltica
Last active January 15, 2017 18:54
Show Gist options
  • Save losbaltica/60085d680ed88baf91bb3ec57bd5a35c to your computer and use it in GitHub Desktop.
Save losbaltica/60085d680ed88baf91bb3ec57bd5a35c to your computer and use it in GitHub Desktop.
My first 'project' in python. Simple code to check at what year person will be 100 years old.
from datetime import date
name = (str(input("Enter your name: ")))
age = (int(input("Enter your age: ")))
current_year = int(date.today().year)
def count_age():
global magic
if age < 100:
magic = str((100 - age) + current_year)
print("Hello %s. You can celebrate your 100 birthday in %s" % (name, magic))
elif age == 100:
magic = str(current_year)
print("Hello %s. You are 100 years old now (%s)! Happy birthday!" % (name, magic))
else:
magic = str(current_year - (age - 100))
print("Hello %s. You already pass your 100 birthday in %s. Congratulation!" % (name, magic))
print(count_age())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment