diff --git a/labs02/task07.py b/labs02/task07.py index 80cbd37..fe9405b 100644 --- a/labs02/task07.py +++ b/labs02/task07.py @@ -6,7 +6,7 @@ Napisz funkcję char_sum, która dla zadanego łańcucha zwraca sumę kodów ASCII znaków. """ def char_sum(text): - pass + return sum(ord(i) for i in text) def tests(f): inputs = [["this is a string"], ["this is another string"]] diff --git a/labs02/task08.py b/labs02/task08.py index 252b10d..e0eca7b 100644 --- a/labs02/task08.py +++ b/labs02/task08.py @@ -7,7 +7,11 @@ przez 3 lub 5 mniejszych niż n. """ def sum_div35(n): - pass + sum=0 + for i in range(n): + if (i%3 ==0 or i%5 ==0): + sum += i + return(sum) def tests(f): inputs = [[10], [100], [3845]] diff --git a/labs02/task09.py b/labs02/task09.py index 9045054..044d0ae 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 + text = text.replace('e', '3') + text = text.replace('l', '1') + text = text.replace('o', '0') + text = text.replace('t', '7') + return text def tests(f): diff --git a/labs02/task10.py b/labs02/task10.py index 58d40d2..741ecfb 100644 --- a/labs02/task10.py +++ b/labs02/task10.py @@ -9,7 +9,17 @@ na wielką. Np. pokemon_speak('pokemon') powinno zwrócić 'PoKeMoN'. def pokemon_speak(text): - pass + slowo = list(text) + wynik = [] + for i in range(len(slowo)): + if i == 0 or i % 2 == 0: + wynik.append(slowo[i].upper()) + + else: + wynik.append(slowo[i]) + + slowo = "".join(wynik) + return slowo def tests(f):