From acf48c8e1e2c51c8ed8c8584c361c0aa22f555ae Mon Sep 17 00:00:00 2001 From: Ola Piechowiak Date: Sun, 20 May 2018 16:53:37 +0200 Subject: [PATCH] zad 4, 8, 9 --- labs02/task04.py | 4 +--- labs02/task08.py | 6 +++++- labs02/task09.py | 6 +++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/labs02/task04.py b/labs02/task04.py index 7c786ab..9034453 100644 --- a/labs02/task04.py +++ b/labs02/task04.py @@ -10,9 +10,7 @@ def sum_from_one_to_n(n): if n<1: return 0 else: - for i in range(n+1): - sum += i - return sum + return sum(range(1,n+1)) def tests(f): inputs = [[999], [-100]] diff --git a/labs02/task08.py b/labs02/task08.py index 252b10d..368d765 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 + suma=0 + for i in range(n): + if (n%3 ==0 or n%5 ==0): + suma += i + return(suma) 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):