Print the Month and Day

This function, when passed a day within a year (January 1 is 1, February 1 is 32, and so on) prints the month name and day within the month.

This function takes an extra parameter to specify if the year is a leap year (where February has 29 days).

The function should raise the ValueError exception if the day number is invalid.

Remember that a class with an empty definition functions like a struct in C, allowing data to be accessed by name.

This excerpt from the Python Reference Manual helps explain one potentially confusing expression in the code:

The expression x and y first evaluates x; if x is false, its value is returned; ...

Get Find the Bug A Book of Incorrect Programs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.