Answer to Question #309919 in Python for big eddy

Question #309919

 

Write functions to solve the following problems: 

  1. Leap Year Calculator (25 points) 

Write a fuction isLeapYear with a parameter of type int named year.  

The parameter needs to be greater than or equal to 1 and less than or equal to 9999.  

If the parameter is not in that range return False.  

Otherwise, if it is in the valid range, calculate if the year is a leap year and return True if it is a leap year, otherwise return False.  

Tip: To determine whether a year is a leap year, follow these steps:   

1. If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5.  

2. If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4. 

3. If the year is evenly divisible by 400, go to step 4. Otherwise, go to step 5. 

4. The year is a leap year (it has 366 days).  The method isLeapYear needs to return True.  

5. The year is not a leap year (it has 365 days). The method isLeapYear needs to return False

1
Expert's answer
2022-03-11T17:39:31-0500
def isleapyear(param):
    if 1 <= param <= 9999:
        if param % 4 == 0:
            return True
        else:
            return False
    else:
        return False
isleapyear(2020)
True

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS