Question: Python. This is the starter code Thank you This lab will test your ability to use various selection constructs (if, elif, else) in a program
Python.
This lab will test your ability to use various selection constructs (if, elif, else) in a program that makes decisions based on the value of passed parameters. The use of for loop is optional. Due: 11:59pm, Friday, Feb 15, 2019 Question: Write a function that is passed a year, a month and a day, and then returns the season, and the number of days past since the beginning of this season as a two-clement list. For the purposes of this lab, you may assume that spring, summer, autumn, and winter begin on the 21st day of Mch, June, September, and December, respectively Make sure to pay attention to leap years (google how to check for leap years). If program is passed an invalid entry for the month or the day, the program should return [invalid month', -1] or ['invalid day', -1], respectively. If passed both an invalid month and an invalid day, the program should return ['invalid month', -1]. Sample Inputs and Outputs: Inputs: seasons(year, month, day) seasons(1998, 3, 22) seasons(1998, 0, 40) seasons(1998, 1, 32) seasons(1998, 2, 29) seasons (2000, 2, 29) Output C'spring', 1] C'invalid month', -1] C'invalid day', -1] C'invalid day', -1] 'winter', 70] Hint You may want to calculate the number of days between Jan 1 and the input date. .You may find creating a list of days for each month helpful for your calculation. Be careful with winter, as it extends over the end of the year TO DO Download the file Lab4.py and complete the functions according to the descriptions. Test your code on MarkUS and Submit the final version of your code MPORTANT: Do not change the file name or function names. Do not use input0 or printo. Your submission file should not contain any additional lines of code outside the function definitions. Test cases are provided on MarkUS. Additional cases will be used in grading. def seasons (year, month, day): (int, int, int) -> [str, int] A function that is passed a month and day, calculates the number of days since the the season and days as a two element list Students may assume that the seasons begin September and December. Student SHOULD determines the season, and thein current season begins and returns on the 21st day of March, June, consider leap year Please refer to the handout for test cases and error conditions
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
