Created
June 13, 2018 04:37
-
-
Save CavaTrendy/665e76066c0696d28dfd0ee3d02e0607 to your computer and use it in GitHub Desktop.
Birthday Count Down
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
''' | |
Created with the help of Python Jumpstart by Building 10 Apps | |
''' | |
import datetime | |
def print_header(): | |
print("----------------------------------") | |
print("BIRTHDAY APP") | |
print("----------------------------------") | |
print() | |
def get_birthday_from_user(): | |
print('When you where born? ') | |
year = int(input('Year [YYYY]: ')) | |
month = int(input('Month [MM]: ')) | |
day = int(input('Day [DD]: ')) | |
birthday = datetime.date(year, month, day) | |
return birthday | |
def compute_days_between_dates(original_date, target_date): | |
this_year = datetime.date(target_date.year, original_date.month, original_date.day ) | |
dt = this_year - target_date | |
return dt.days | |
def print_brithday_information(days): | |
if days < 0: | |
print ('You had your birthday {} days ago this year.'.format(-days)) | |
elif days > 0: | |
print('Your birthday is in {} days '.format(days)) | |
else: | |
print('Happy Birthday!') | |
def main(): | |
print_header() | |
bday = get_birthday_from_user() | |
today = datetime.date.today() | |
number_days = compute_days_between_dates(bday, today) | |
print_brithday_information(number_days) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment