From e604060124857569a330b2ed3e88be327e82d56e Mon Sep 17 00:00:00 2001 From: s45147 Date: Sun, 19 Nov 2017 14:53:05 +0100 Subject: [PATCH 01/15] done --- labs02/test_task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs02/test_task.py b/labs02/test_task.py index 5879768..49e5fd9 100755 --- a/labs02/test_task.py +++ b/labs02/test_task.py @@ -6,7 +6,7 @@ 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)] From fd2448691d08f2d057cc73c4ace36e8a8912ab86 Mon Sep 17 00:00:00 2001 From: s45147 Date: Sun, 19 Nov 2017 14:57:58 +0100 Subject: [PATCH 02/15] done --- .idea/vcs.xml | 6 ++++++ labs02/task01.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/labs02/task01.py b/labs02/task01.py index 7c08c56..67c804b 100644 --- a/labs02/task01.py +++ b/labs02/task01.py @@ -7,7 +7,7 @@ która zawiera tylko elementy z list o parzystych indeksach. """ def even_elements(lista): - pass + return(lista[::2]) def tests(f): From 384abbe074d45fad8cedecad687032ef197d8354 Mon Sep 17 00:00:00 2001 From: s45147 Date: Sun, 19 Nov 2017 15:11:38 +0100 Subject: [PATCH 03/15] done --- labs02/task02.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/labs02/task02.py b/labs02/task02.py index a6d6321..103c752 100644 --- a/labs02/task02.py +++ b/labs02/task02.py @@ -5,8 +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(years): + if (years % 4 == 0 and years % 100 != 0) or years % 400 == 0: + return 366 + else: + return 365 def tests(f): inputs = [[2015], [2012], [1900], [2400], [1977]] From 77ffeebaea3352e488d3e7d0c0c9a8812b2d7064 Mon Sep 17 00:00:00 2001 From: s45147 Date: Sun, 19 Nov 2017 15:29:24 +0100 Subject: [PATCH 04/15] done --- labs02/task03.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/labs02/task03.py b/labs02/task03.py index a1c3a85..b5e2e5f 100644 --- a/labs02/task03.py +++ b/labs02/task03.py @@ -13,7 +13,12 @@ jak 'set', która przechowuje elementy bez powtórzeń.) def oov(text, vocab): - pass + list_of_words = [] + text_splitted = text.split(' ') + for word in text_splitted: + if word.lower() not in vocab: + list_of_words.append(word) + return set(list_of_words) From 36e78f1dfaaa5a9294e1918449a78a2f8f39e02c Mon Sep 17 00:00:00 2001 From: s45147 Date: Sun, 19 Nov 2017 15:34:42 +0100 Subject: [PATCH 05/15] done --- labs02/task04.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/labs02/task04.py b/labs02/task04.py index 37413f1..08d4cc0 100644 --- a/labs02/task04.py +++ b/labs02/task04.py @@ -7,8 +7,14 @@ Jeśli podany argument jest mniejszy od 1 powinna być zwracana wartość 0. """ def sum_from_one_to_n(n): - pass + suma = 0 + for i in range(n+1): + suma = suma + i + if n < 1: + return 0 + else: + return suma def tests(f): inputs = [[999], [-100]] From e1c9346baa007599bea03b3e92a58757c9207dd6 Mon Sep 17 00:00:00 2001 From: s45147 Date: Sun, 19 Nov 2017 15:35:13 +0100 Subject: [PATCH 06/15] done --- labs02/task04.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs02/task04.py b/labs02/task04.py index 08d4cc0..4be29e7 100644 --- a/labs02/task04.py +++ b/labs02/task04.py @@ -10,7 +10,7 @@ def sum_from_one_to_n(n): suma = 0 for i in range(n+1): - suma = suma + i + suma = suma + i if n < 1: return 0 else: From a946cb82daebd1c82f7eb7a76ac6877338a075b3 Mon Sep 17 00:00:00 2001 From: s45147 Date: Sun, 19 Nov 2017 15:40:09 +0100 Subject: [PATCH 07/15] done --- labs02/task04.py | 2 +- labs02/task05.py | 5 +++-- labs02/task10.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/labs02/task04.py b/labs02/task04.py index 4be29e7..08d4cc0 100644 --- a/labs02/task04.py +++ b/labs02/task04.py @@ -10,7 +10,7 @@ def sum_from_one_to_n(n): suma = 0 for i in range(n+1): - suma = suma + i + suma = suma + i if n < 1: return 0 else: diff --git a/labs02/task05.py b/labs02/task05.py index f59268a..961e7eb 100644 --- a/labs02/task05.py +++ b/labs02/task05.py @@ -8,9 +8,10 @@ dwoma punktami przestrzeni trójwymiarowej. Punkty są dane jako trzyelementowe listy liczb zmiennoprzecinkowych. np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5. """ - +from math import sqrt def euclidean_distance(x, y): - pass + + return sqrt(sum((x - y) ** 2 for x, y in zip(x, y))) def tests(f): inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]] diff --git a/labs02/task10.py b/labs02/task10.py index f380f0a..58d40d2 100644 --- a/labs02/task10.py +++ b/labs02/task10.py @@ -13,7 +13,7 @@ def pokemon_speak(text): def tests(f): - inputs = [['pokemon'], ['do not want'], 'POKEMON'] + inputs = [['pokemon'], ['do not want'], ['POKEMON']] outputs = ['PoKeMoN', 'Do nOt wAnT', 'POKEMON'] for input, output in zip(inputs, outputs): From c6901ebfc26a47b29f44dddadb8b2ac2dd7c65f6 Mon Sep 17 00:00:00 2001 From: s45147 Date: Mon, 20 Nov 2017 09:32:51 +0100 Subject: [PATCH 08/15] done --- labs02/task06.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/labs02/task06.py b/labs02/task06.py index ff4a9d3..5dcea87 100644 --- a/labs02/task06.py +++ b/labs02/task06.py @@ -10,7 +10,11 @@ ma być zwracany napis "It's not a Big 'No!'". """ def big_no(n): - pass + napis = 'N' + if n < 5: + return "It's not a Big 'No!'" + else: + return napis + n * 'O' + '!' def tests(f): inputs = [[5], [6], [2]] From 7cc01637fbb0a23fa21c0dcc81be3353568a5dff Mon Sep 17 00:00:00 2001 From: s45147 Date: Mon, 20 Nov 2017 09:36:10 +0100 Subject: [PATCH 09/15] done --- labs02/task07.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/labs02/task07.py b/labs02/task07.py index 80cbd37..6949fee 100644 --- a/labs02/task07.py +++ b/labs02/task07.py @@ -6,7 +6,10 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca sumę kodów ASCII znaków. """ def char_sum(text): - pass + suma = 0 + for c in text: + suma += ord(c) + return suma def tests(f): inputs = [["this is a string"], ["this is another string"]] From c941f0f6ac475a47e062feb86c28fa1753378c73 Mon Sep 17 00:00:00 2001 From: s45147 Date: Mon, 20 Nov 2017 09:43:00 +0100 Subject: [PATCH 10/15] done --- labs02/task08.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/labs02/task08.py b/labs02/task08.py index 252b10d..0100ab5 100644 --- a/labs02/task08.py +++ b/labs02/task08.py @@ -7,7 +7,12 @@ przez 3 lub 5 mniejszych niż n. """ def sum_div35(n): - pass + suma = 0 + for i in range(n): + if (i+1) < n and (i+1)%3 == 0 and (i+1)%5 == 0: + suma += (i+1) + + return suma def tests(f): inputs = [[10], [100], [3845]] From b52078b610c3cceb8d63511fc65d45b4a85b22e4 Mon Sep 17 00:00:00 2001 From: s45147 Date: Mon, 20 Nov 2017 09:56:26 +0100 Subject: [PATCH 11/15] done --- labs02/task09.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/labs02/task09.py b/labs02/task09.py index 9045054..28b9c01 100644 --- a/labs02/task09.py +++ b/labs02/task09.py @@ -9,8 +9,16 @@ Np. leet('leet') powinno zwrócić '1337'. def leet_speak(text): - pass + slownik = {'e':3, 'l':1, 'o':0, 't':7} + dekod = '' + for znak in text: + if znak in slownik: + dekod += slownik[znak] + else: + dekod += znak + + return dekod def tests(f): inputs = [['leet'], ['do not want']] From 70554cf0130c44d08ffa48cb6d6885d07b808a2f Mon Sep 17 00:00:00 2001 From: s45147 Date: Mon, 20 Nov 2017 10:11:11 +0100 Subject: [PATCH 12/15] done --- labs02/task10.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/labs02/task10.py b/labs02/task10.py index 58d40d2..2bf4bc9 100644 --- a/labs02/task10.py +++ b/labs02/task10.py @@ -9,8 +9,16 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'. def pokemon_speak(text): - pass - + wynik = '' + switch = 1 + for znak in text: + if switch == 1: + wynik += znak.upper() + switch *= -1 + else: + wynik += znak + switch *= -1 + return wynik def tests(f): inputs = [['pokemon'], ['do not want'], ['POKEMON']] From 66007e325294261d86941c4b3170b36a62ea1756 Mon Sep 17 00:00:00 2001 From: s45147 Date: Mon, 20 Nov 2017 10:17:48 +0100 Subject: [PATCH 13/15] done --- labs02/task11.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/labs02/task11.py b/labs02/task11.py index 7d36767..cda993a 100644 --- a/labs02/task11.py +++ b/labs02/task11.py @@ -9,8 +9,15 @@ Oba napisy będą składać się wyłacznie z małych liter. """ def common_chars(string1, string2): - pass + wspolne = [] + for z1 in string1: + for z2 in string2: + if z1 == z2: + wspolne.append(z1) + return wspolne.sort() + + def tests(f): inputs = [["this is a string", "ala ma kota"]] From e1ae7f9caeda6c1f3264d907dbe76f853b96ca82 Mon Sep 17 00:00:00 2001 From: s45147 Date: Mon, 20 Nov 2017 10:19:15 +0100 Subject: [PATCH 14/15] done --- labs02/task11.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs02/task11.py b/labs02/task11.py index cda993a..62e180d 100644 --- a/labs02/task11.py +++ b/labs02/task11.py @@ -17,7 +17,7 @@ def common_chars(string1, string2): wspolne.append(z1) return wspolne.sort() - + def tests(f): inputs = [["this is a string", "ala ma kota"]] From 090a391b68107fa66e74247927a4bf90e42ca342 Mon Sep 17 00:00:00 2001 From: s45147 Date: Mon, 20 Nov 2017 10:21:13 +0100 Subject: [PATCH 15/15] done --- labs02/task03.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labs02/task03.py b/labs02/task03.py index b5e2e5f..08c374c 100644 --- a/labs02/task03.py +++ b/labs02/task03.py @@ -17,7 +17,7 @@ def oov(text, vocab): text_splitted = text.split(' ') for word in text_splitted: if word.lower() not in vocab: - list_of_words.append(word) + list_of_words.append(word.lower()) return set(list_of_words)