Question: Write a Python program that uses a main function and two additional functions named isValid and isLeap to do some basic calculations on a date.

Write a Python program that uses a main function and two additional functions named isValid and isLeap to do some basic calculations on a date. You are provided the main function below. You need to write the isValid and isLeap functions:
def main():
print(Enter a negative month, day, or year to quit.)
print(====================================)
while True:
month = int(input(Enter the month: ))
day = int(input(Enter the day: ))
year = int(input(Enter the year: ))
if month <0 or day <0 or year <0:
break
if isValid(month, day, year)== True:
print(The date is valid.)
if isLeap(year)== True:
print(The year is a leap year.)
else:
print(The year is not a leap year.)
else:
print(The date is invalid.)
print(
)
The isValid function accepts month, day, and year into the module as parameters. If the date is a valid date, the function will return True. Otherwise, the function will return False.
The isLeap function accepts the year into the module as a parameter. If the year is a leap year, the function returns True. Otherwise, the function will return False.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!