1
0
forked from tdwojak/Python2017
Python2017/labs02/task02.py

29 lines
701 B
Python
Raw Permalink Normal View History

2017-11-18 16:45:28 +01:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Napisz funkcję days_in_year zwracającą liczbę dni w roku (365 albo 366).
"""
2017-11-19 15:40:25 +01:00
def days_in_year(year):
if year % 4==0 and year % 100!=0 or year % 400 == 0:
return 366
else:
return 365
2017-11-18 16:45:28 +01:00
def tests(f):
inputs = [[2015], [2012], [1900], [2400], [1977]]
outputs = [365, 366, 365, 366, 365]
for input, output in zip(inputs, outputs):
if f(*input) != output:
return "ERROR: {}!={}".format(f(*input), output)
break
return "TESTS PASSED"
if __name__ == "__main__":
print(tests(days_in_year))
2017-11-19 15:40:25 +01:00
#jest podzielny przez 4, ale nie jest podzielny przez 100
#jest podzielny przez 400