diff --git a/labs02/task06.py b/labs02/task06.py index 53140fb..48c901f 100644 --- a/labs02/task06.py +++ b/labs02/task06.py @@ -11,8 +11,10 @@ ma być zwracany napis "It's not a Big 'No!'". def big_no(n): if n < 5: - return "It's not a Big 'No!" - new = n.split('N') + return "It's not a Big 'No!'" + else: + o_creater = 'O'*n + return 'N'+o_creater+'!' def tests(f): inputs = [[5], [6], [2]] diff --git a/labs02/task07.py b/labs02/task07.py index 80cbd37..a24caaf 100644 --- a/labs02/task07.py +++ b/labs02/task07.py @@ -6,7 +6,11 @@ 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 n in text: + asco = ord(n) + suma += asco + return suma def tests(f): inputs = [["this is a string"], ["this is another string"]] diff --git a/labs02/task08.py b/labs02/task08.py index 252b10d..0435078 100644 --- a/labs02/task08.py +++ b/labs02/task08.py @@ -7,7 +7,15 @@ przez 3 lub 5 mniejszych niż n. """ def sum_div35(n): - pass + new_range = range(n) + new_list = [] + suma = 0 + for n in new_range: + if n % 3 == 0 or n % 5 == 0: + new_list.append(n) + for x in new_list: + suma += x + return suma def tests(f): inputs = [[10], [100], [3845]] diff --git a/labs02/task09.py b/labs02/task09.py index 9045054..f6653de 100644 --- a/labs02/task09.py +++ b/labs02/task09.py @@ -9,7 +9,11 @@ Np. leet('leet') powinno zwrócić '1337'. def leet_speak(text): - pass + let_dict = {'e': 3, 'l': 1, 'o': 0, 't': 7} + for n in text: + if n in let_dict: + x = let_dict[n] + return text def tests(f): diff --git a/labs02/task10.py b/labs02/task10.py index 58d40d2..cb86b36 100644 --- a/labs02/task10.py +++ b/labs02/task10.py @@ -9,7 +9,16 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'. def pokemon_speak(text): - pass + text_list = [] + i = 0 + while i != len(text): + text_list.append(text[i].upper()) + i += 1 + if i != len(text): + text_list.append(text[i]) + i += 1 + text_list_joined = ''.join(text_list) + return text_list_joined def tests(f): diff --git a/labs02/task11.py b/labs02/task11.py index 7d36767..9909d5f 100644 --- a/labs02/task11.py +++ b/labs02/task11.py @@ -9,7 +9,10 @@ Oba napisy będą składać się wyłacznie z małych liter. """ def common_chars(string1, string2): - pass + string1_list = set([n for n in string1 if n != ' ']) + string2_list = set([n for n in string2 if n != ' ']) + common_letter_list = sorted([n for n in string1_list if n in string2_list and n != ' ']) + return common_letter_list def tests(f):