Question
You will write three functions for this assignment. monthNum(abbr) takes the three letter abbreviation for a month. It returns the month number. If the input
You will write three functions for this assignment.
monthNum(abbr) takes the three letter abbreviation for a month. It returns the month number. If the input is not a valid three letter code, return 0. This function must be case insensitive. That means Jan, jan, and JAN should all return 1.
tamilSeason(month,day) takes the month number and day of the month. Returns a string with the Tamil Season that date falls in. Both the month and the day must be integer inputs. The month is a number from 1-12 and the day is a number from 1-31.
validDay(month,day) takes the month and day, both as integers. The day must fall in the number of days allowed that month. Jan, Mar, May, Jul, Aug, Oct, Dec have 31 days, Feb can have up to 29 days, and the rest of the months 30 days. Assume Feb always has 29 days for this function. Return True if the day is in the month and false otherwise.
Your program will ask the user for two inputs. First, ask for the three letter month abbreviation. Next, ask for the date. Print out the Tamil Season for the given date.
There are two potential errors you need to check for. First, the user may enter an invalid month. If this is the case, your program will print "Month Invalid" and exit. You should use sys.exit(0) from the sys library to exit immediately on error. The second error is that the day is invalid. Months have different numbers of days: Jan, Mar, May, Jul, Aug, Oct, Dec have 31 days, Feb can have up to 29 days, and the rest of the months 30 days. You don't need to worry about if it is a leap year or not. Just assume 29 days if acceptable. Print "Day Invalid" and exit on an incorrect day.
The purpose of this problem is to practice using conditional branching.
Do not use loops.
Please make sure to submit a well-written program. Good identifier names, useful comments, and spacing will be some of the criteria that will be used when grading this assignment.
This assignment can be and must be solved using only the materials that have been discussed in class. Do not look for alternative methods that have not been covered as part of this course.
You are encouraged to use incremental development. Complete small parts of the assignment and submit for grading before starting the next part. Only a portion of tests pass after each try but this helps to confirm progress. For example, make sure you can cover the month abbreviation to a number before trying to write the Tamil season function.
The Tamil people of the Indian subcontinent use a six month calendar. The table below shows the relationship between Gregorian months and Tamil seasons. The start and stop dates are inclusive. They are the first and last day that can be officially called part of the season For example, June 14 is the last day of MuthuVenil and June 15 is the first day of Kaar. In this program, you will write a program that takes a Gregorian date and tells the user what Tamil season it is. More people are bad at remembering what number each month is. We are more used to the names of months. The mapping between three letter month abbreviations and their numbers are given in the following tableStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started