# BirthdaysStandard.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-04 File created. # 2022-12-18 Converted to Python 3. # This program works in the same way as Birthdays.py, but this is # written by using standard Python classes. from datetime import date days_of_week = ( "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ) print( "\n Type in your date of birth as YYYY-MM-DD" \ "\n Please, use four digits for the year, and" \ "\n two digits for the month and day: ", end="" ) given_date_as_string = input() year_of_birth = int( given_date_as_string[ 0 : 4 ] ) month_of_birth = int( given_date_as_string[ 5 : 7 ] ) day_of_birth = int( given_date_as_string[ 8 : ] ) date_of_birth = date( year_of_birth, month_of_birth, day_of_birth ) print( "\n You were born on a %s" % days_of_week[ date_of_birth.weekday() ] ) print( " Here are your days to celebrate. You are" ) years_to_celebrate = 10 while years_to_celebrate < 80 : date_to_celebrate = date( year_of_birth + years_to_celebrate, month_of_birth, day_of_birth ) print( "\n %d years old on %s (%s)" % ( years_to_celebrate, date_to_celebrate.isoformat(), days_of_week[ date_to_celebrate.weekday() ] ), end="" ) years_to_celebrate = years_to_celebrate + 10 print( "\n" )