Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions