livepython.net

121. Python Program to Find the Day of the Year Using a Tuple

MediumTuples

Overview

The number of days in each month never changes: a perfect tuple. Slice it and add it up to find the day of the year.

Problem Statement

Read a month (1 to 12) and a day, each on its own line. The year is not a leap year, so February has 28 days. Print which day of the year it is. For example, 1 March (3, then 1) is day 31 + 28 + 1:

Day 60 of the year

If the month is not between 1 and 12, or the day is less than 1 or more than the days in that month, print:

Invalid date

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

Two whole numbers, one per line: the month, then the day. Example:

3
1

Output

The output for that example:

Day 60 of the year

The tests try 5 different inputs.

Learn this firstChapter 14 · Python Tuples: Create, Read and Why They Can't Change
solution.py
# write your code here

EXPECTED OUTPUT

1Day 60 of the year

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.