1
0
forked from tdwojak/Python2018
Python2018/labs02/task02.py
Sylwia Miśkiewicz 1bf2836b87 in progres
2018-05-29 20:58:35 +02:00

32 lines
699 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Napisz funkcję days_in_year zwracającą liczbę dni w roku (365 albo 366).
"""
def days_in_year(days):
days_in_year=0
if days % 4 == 0 and days % 100 != 0 or days % 400 == 0:
days_in_year = 366
else:
days_in_year = 365
return days_in_year
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))