From 9e7ad31f19bdad13e14a94f55a298c42648166c5 Mon Sep 17 00:00:00 2001 From: s45165 Date: Sun, 19 Nov 2017 15:40:25 +0100 Subject: [PATCH] done --- labs02/task01.py | 3 ++- labs02/task02.py | 13 ++++++++++--- labs02/task03.py | 12 +++++++++++- labs02/test_task.py | 8 ++++---- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/labs02/task01.py b/labs02/task01.py index 7c08c56..60de4c0 100644 --- a/labs02/task01.py +++ b/labs02/task01.py @@ -7,7 +7,8 @@ która zawiera tylko elementy z list o parzystych indeksach. """ def even_elements(lista): - pass + return lista[::2] + def tests(f): diff --git a/labs02/task02.py b/labs02/task02.py index a6d6321..1280fdb 100644 --- a/labs02/task02.py +++ b/labs02/task02.py @@ -5,9 +5,11 @@ Napisz funkcję days_in_year zwracającą liczbę dni w roku (365 albo 366). """ -def days_in_year(days): - pass - +def days_in_year(year): + if year % 4==0 and year % 100!=0 or year % 400 == 0: + return 366 + else: + return 365 def tests(f): inputs = [[2015], [2012], [1900], [2400], [1977]] outputs = [365, 366, 365, 366, 365] @@ -20,3 +22,8 @@ def tests(f): if __name__ == "__main__": print(tests(days_in_year)) + + + +#jest podzielny przez 4, ale nie jest podzielny przez 100 +#jest podzielny przez 400 \ No newline at end of file diff --git a/labs02/task03.py b/labs02/task03.py index a1c3a85..a0c356f 100644 --- a/labs02/task03.py +++ b/labs02/task03.py @@ -13,9 +13,19 @@ jak 'set', która przechowuje elementy bez powtórzeń.) def oov(text, vocab): - pass + s = set() + for czajnik in text.split(): + if czajnik not in vocab: + s.add(czajnik.lower()) + return s +text = [("this is a string , which i will use for string testing", + [',', 'this', 'is', 'a', 'which', 'for', 'will', 'i'])] +vocab = [['string', 'testing', 'use']] + +oov("this is a string , which i will use for string testing", + [',', 'this', 'is', 'a', 'which', 'for', 'will', 'i']) def tests(f): inputs = [("this is a string , which i will use for string testing", diff --git a/labs02/test_task.py b/labs02/test_task.py index 5879768..14f2f89 100755 --- a/labs02/test_task.py +++ b/labs02/test_task.py @@ -3,10 +3,9 @@ def suma(a, b): - """ - Napisz funkcję, która zwraca sumę elementów. - """ - pass + return a+b + + def tests(f): inputs = [(2, 3), (0, 0), (1, 1)] @@ -20,3 +19,4 @@ def tests(f): if __name__ == "__main__": print(tests(suma)) +