From d032993997303449a7dbaa6db375cd9645a66ae8 Mon Sep 17 00:00:00 2001 From: s434579 Date: Sun, 13 May 2018 12:54:36 +0200 Subject: [PATCH] rozwiazanie zadania od 7 do 8 --- labs02/task07.py | 7 ++++++- labs02/task08.py | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/labs02/task07.py b/labs02/task07.py index 80cbd37..4cb2564 100644 --- a/labs02/task07.py +++ b/labs02/task07.py @@ -6,7 +6,12 @@ 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 i in text: + suma += ord(i) + 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..051ee41 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 i % 3 == 0 or i % 5 == 0: + suma += i + return suma def tests(f): inputs = [[10], [100], [3845]]