0% found this document useful (0 votes)
15 views1 page

Python Activity

This document contains a function that analyzes whether a year is a leap year or not based on checking if the year is divisible by 4, 100, and 400. The function is tested on sample data to check if it returns the correct results.

Uploaded by

Regino Vinluan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Python Activity

This document contains a function that analyzes whether a year is a leap year or not based on checking if the year is divisible by 4, 100, and 400. The function is tested on sample data to check if it returns the correct results.

Uploaded by

Regino Vinluan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#Module 4 Lab Act 1

def yearanalyzer(year):
if year % 4 != 0:
return False
elif year % 100 != 0:
return True
elif year % 400 != 0:
return False
else:
return True

year = int(input("Enter year"))


yearanalyzer(year)
print (yearanalyzer(year))

testdata = [1900, 2000, 2016, 1987]


testresults = [False, True, True, False]
for i in range (len(testdata)):
yr = testdata[i]
print(yr,"=> " , end="")
result = yearanalyzer(yr)
if result == testresults[i]:
print("OK")
else:
print("Failed")

You might also like