2018-05-12 11:37:19 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
Zad 2. Napisz funkcję even_elements zwracającą listę,
|
|
|
|
która zawiera tylko elementy z list o parzystych indeksach.
|
|
|
|
"""
|
|
|
|
|
2018-06-13 19:28:15 +02:00
|
|
|
def days_in_year(days):
|
|
|
|
if ((days % 4) == 0 and ((days % 100) != 0)) or ((days % 400) == 0):
|
|
|
|
dni=366
|
|
|
|
else:
|
|
|
|
dni=365
|
2018-05-12 11:37:19 +02:00
|
|
|
|
2018-06-13 19:28:15 +02:00
|
|
|
return dni
|
2018-05-12 11:37:19 +02:00
|
|
|
|
|
|
|
def tests(f):
|
2018-06-13 19:28:15 +02:00
|
|
|
inputs = [[2015], [2012], [1900], [2400], [1977]]
|
|
|
|
outputs = [365, 366, 365, 366, 365]
|
2018-05-12 11:37:19 +02:00
|
|
|
|
|
|
|
for input, output in zip(inputs, outputs):
|
|
|
|
if f(*input) != output:
|
|
|
|
return "ERROR: {}!={}".format(f(*input), output)
|
|
|
|
break
|
|
|
|
return "TESTS PASSED"
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2018-06-13 19:28:15 +02:00
|
|
|
print(tests(days_in_year))
|