Question
Write a Python program that prints and saves the day number of the year, given the date in the form month-day-year. For example, if the
Write a Python program that prints and saves the day number of the year, given the date in the form month-day-year. For example, if the input is 1-1-2006, the day number is 1; if the input is 12-25-2006, the day number is 359. The program should check for a leap year. A year is a leap year if it is divisible by 4, but not divisible by 100. For example, 1992 and 2008 are divisible by 4., but not by 100; therefore, they are leap years.
Your program will begin by prompting the user for a date, once the date is entered, the program will pass the date to a function, calc_day_num_of_year, that determines and returns the day number of the year. The program will keep track of each date entered and the corresponding day number. The program should be able to process multiple dates. That is, when the user enters a date, the program will compute the day number of that date and return to the prompt. Pressing enter at the prompt without entering a date, means the user is done entering dates. The program should proceed to display and write to a file all the dates entered and the corresponding day numbers:
Include a function, display_day_num_of_year, to display the dates and corresponding day numbers. This function takes as input all dates and corresponding day numbers. Apply formatting to the data for proper alignment on screen.
The program should also contain a function, save_day_num_of_year, that takes all the dates and corresponding day numbers and save them to a file. One line for each date and corresponding day number. This function takes as input all dates and corresponding day numbers.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started