I wish to create a program that informs the user whether a given date is a holiday or not -

Here is how it should work: The student should be prompted to enter an integer for the month and then prompted to enter an integer for the day. (For example, entering "2" for the month and "14" for the day would represent February 14th.)

The program will tell the student if that date is a vacation day and if so, which one, by printing out a message such as:
February 18 is Presidents' Day. This is a Holiday.

If the day selected is not a holiday, the program should print out a message such as:
February 17 is not a school holiday.


Any idea how I could get this started?

You could start filling a dictionary with knowledge, like this

holydays_dict = {
    (2, 18) : "February 18 is Presidents' Day.",
}

Then find how your program could select an entry in the dictionary.

What about floating holidays like Easter, (Easter falls on the first Sunday after the first full moon after the spring equinox unless the full moon is on the equinox in which case it is after the following full moon), and Thanksgiving, which is easier but still not a specific date. Also, President's Day is usually celebrated (=some people get it off) on the Monday between Lincoln's and Washington's birthdays. So you will have to allow for some calculations. The simplest to digest would be one dictionary with actual dates, and a second dictionary with known symbols that can be used to calculate the date, 4Th-11 would be the fourth Thursday in November for Thanksgiving. For Easter, you would have to access a web site like NOAA'S to get the equinox and full moon, and that would probably be a separate function so not in any dictionary.

Edited 6 Years Ago by woooee: n/a

With some luck your department will publish a list of school holidays and then you can transfer it easily to a list of (month, day) tuples for the year, or the dictionary Gribouillis suggested.

Okay thanks guys - im going to get started on this and post up my finished attempt, hopefully by tonight.

With some luck your department will publish a list of school holidays and then you can transfer it easily to a list of (month, day) tuples for the year, or the dictionary Gribouillis suggested.

Ah yes. The simplest solution is the best. And there is probably a web page that can be traversed, making it even easier.

Edited 6 Years Ago by woooee: n/a

This article has been dead for over six months. Start a new discussion instead.