7.19 Please use Python correctly thanks! def is_valid_month(date_list): """ The function ... """ # TODO: Finish the function def is_valid_day(date_list): """ The function ... """ num_days = { 1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31 } # TODO: Finish the function if __name__ == "__main__":
7.19 Please use Python correctly thanks!
def is_valid_month(date_list):
"""
The function ...
"""
# TODO: Finish the function
def is_valid_day(date_list):
"""
The function ...
"""
num_days = {
1: 31,
2: 28,
3: 31,
4: 30,
5: 31,
6: 30,
7: 31,
8: 31,
9: 30,
10: 31,
11: 30,
12: 31
}
# TODO: Finish the function
if __name__ == "__main__":
# test incorrect types
assert is_valid_month([12, 31, 2021]) == False
assert is_valid_day([12, 31, 2021]) == False
assert is_valid_year([12, 31, 2021]) == False
# test the correct input
assert is_valid_month(["01", "01", "1970"]) == True
assert is_valid_month(["12", "31", "2021"]) == True
assert is_valid_day(["02", "03", "2000"]) == True
assert is_valid_day(["12", "31", "2021"]) == True
assert is_valid_year(["10", "15", "2022"]) == True
assert is_valid_year(["12", "31", "2021"]) == True
### test the edge cases
assert is_valid_month(["21", "01", "1970"]) == False
assert is_valid_month(["-2", "31", "2021"]) == False
assert is_valid_month(["March", "31", "2021"]) == False
assert is_valid_day(["02", "33", "2000"]) == False
assert is_valid_day(["02", "31", "2021"]) == False
assert is_valid_day(["02", "1st", "2021"]) == False
assert is_valid_day(["14", "1st", "2021"]) == False
assert is_valid_year(["10", "15", "22"]) == False
assert is_valid_year(["12", "31", "-21"]) == False
![Instructions
Write a function is_valid_month(date_list) that takes as a parameter a list of strings in the [MM, DD, YYYY] format and returns
True if the provided month number is a possible month in the U.S. (i.e., an integer between 1 and 12 inclusive).
Write a function is_valid_day (date_list) that takes as a parameter a list of strings in the [MM, DD, YYYY] format and returns True if
the provided day is a possible day for the given month. You can use the provided dictionary. Note that you should call is_valid_month()
within this function to help you validate the month.
Write a function is_valid_year (date_list) that takes as a parameter a list of strings in the [MM, DD, YYYY] format and returns True
if the provided year is a possible year: a positive integer. For the purposes of this lab, ensure that the year is also greater than 1000.
Test Your Code
#test incorrect types
assert is_valid_month([12, 31, 2021]) == False
assert is_valid_day ([12, 31, 2021]) == False
assert is_valid_year ([12, 31, 2021]) == False
Make sure that the input is of the correct type
assert is_valid_month(["01", "01", "1970"]) == True
assert is_valid_month ( ["12", "31", "2021"])
== True
assert is_valid_day (["02", "03", "2000"]) == True
assert is_valid_day (["12", "31", "2021"]) == True
assert is_valid_year (["10", "15", "2022"]) == True
assert is_valid_year (["12", "31", "2021"]) == True
Now, test the edge cases of the values:
assert is_valid_month(["21", "01", "1970"]) == False
assert is_valid_month(["-2", "31", "2021"]) == False
assert is_valid_month(["March", "31", "2021"]) == False
assert is_valid_day (["02", "33", "2000"]) == False
assert is_valid_day (["02", "31", "2021"]) == False
assert is_valid_day (["02", "1st", "2021"]) == False
assert is_valid_day(["14", "1st", "2021"]) == False
assert is_valid_year (["10", "15",
assert is_valid_year (["12", "31", "-21"]) == False
"22"]) == False](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fccac55ee-732b-4607-a38e-f5bd0a8aacb2%2Fef572c42-1ad2-4dd4-aa89-41c174fec6ac%2Fwicnltl_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images









