Number of Days Between Two Dates

The purpose of this assignment was to write a program, using the Python programming language, which was capable of taking as input any start day, start month, start year (between 1800 – 2200), end day, and end month and producing as output a count of the number of days between. The program takes into account whether the start and end years are leap years or not and whether the days, months, year entered are valid.

The IO looks like the following (python3  program_name):

$ python3 days_till.py
 Please enter the start month as an integer: 10
 Please enter the day of the start month as an integer: 5
 Please enter the start year as an integer: 2012
 Please enter the end month as an integer: 10
 Please enter the end day as an integer: 4
 364 days to go

$ python3 days_till.py
 Please enter the start month as an integer: 2
 Please enter the day of the start month as an integer: 1
 Please enter the start year as an integer: 1405
 Sorry, I need a valid date between 1/1/1800 and 12/31/2200

$ python3 days_till.py
 Please enter the start month as an integer: 2
 Please enter the day of the start month as an integer: 1
 Please enter the start year as an integer: 2012
 Please enter the end month as an integer: 3
 Please enter the end day as an integer: 35
 Sorry, that month and day don't look right

A link to the final code: days_till.py

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s