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", "22"]) == False assert is_valid_year (["12", "31", "-21"]) == False == Hints • Use the type () function from Section 2.1 and review the note in Section 4.3 to see the syntax for checking the type of a variable. • Refer to LAB 6.19 to review how to use the .isdigit() string function, which returns True if all characters in are the numbers 0-9.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.2: Returning A Single Value
Problem 13E
icon
Related questions
icon
Concept explainers
Question

please Use PYTHON

 

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:
==
== False
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"])
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
==
Hints
Use the type () function from Section 2.1 and review the note in Section 4.3 to see the syntax for checking the type of a variable.
Refer to LAB 6.19 to review how to use the <str_var>.isdigit() string function, which returns True if all characters in <str_var>
are the numbers 0-9.
Transcribed Image Text: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: == == False 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"]) 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 == Hints Use the type () function from Section 2.1 and review the note in Section 4.3 to see the syntax for checking the type of a variable. Refer to LAB 6.19 to review how to use the <str_var>.isdigit() string function, which returns True if all characters in <str_var> are the numbers 0-9.
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Types of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr