Created
February 19, 2015 08:34
-
-
Save ejmurray/b633855bd8ec728e914b to your computer and use it in GitHub Desktop.
Calculates the number of days, years from a given birthday.
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
#!/usr/bin/python | |
# encoding: utf-8 | |
''' | |
Calculate the number of years from the entered birthday | |
''' | |
__author__ = 'Ernest' | |
from datetime import date | |
stryear = raw_input("Enter the year you were born using four digits ") | |
strmonth = raw_input("Enter the month that you were born in two digits ") | |
strday = raw_input("Enter the day that you were born in two digits ") | |
intyear = int(stryear) | |
intmonth = int(strmonth) | |
intday = int(strday) | |
mybirhtday = date(intyear, intmonth, intday) | |
todaydate = date.today() | |
diff = todaydate - mybirhtday | |
numdays = diff.days | |
numsecs = diff.total_seconds() | |
numyears = numdays / 365 | |
print "You are", numyears, "years old and", numdays, "days and ", numsecs, "seconds" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment