logo CodeStepByStep logo

birthday

Language/Type: Python interactive programs parameters return

Write a console program that prompts for today's date and the user's birthday, then prints various information about the dates. Your code should print the "absolute day of the year" for today and the birthday. This is a date's place within the year from 1 to 365. January 1st is absolute day #1 and December 31st is #365. Lastly the program prints the number of days until the user's next birthday. Different messages appear if the birthday is today or tomorrow.

This program tells you how many days
it will be until your next birthday.

Please enter today's date:
What is the month (1-12)? 7
What is the day   (1-31)? 24
7/24 is day #205 of 365.

Please enter your birthday:
What is the month (1-12)? 11
What is the day   (1-30)? 6
11/6 is day #310 of 365.

Your next birthday is in 105 days.

You should break down your program into several functions that use parameters and returns to exchange data.

Do not use Python's built-in date functions or libraries in your solution. Perform all date arithmetic yourself.

Complete program: Write an entire program that you could put into a file and run outside of CodeStepByStep.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.