From 6c10fb4b030cb68db3746889286a5a47aa99c11f Mon Sep 17 00:00:00 2001 From: s352037 Date: Sun, 13 May 2018 12:45:02 +0200 Subject: [PATCH] zrobione na zajeciach --- labs02/task04.py | 2 +- labs02/task05.py | 6 +++++- labs02/task06.py | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/labs02/task04.py b/labs02/task04.py index 99ce033..df2493d 100644 --- a/labs02/task04.py +++ b/labs02/task04.py @@ -10,7 +10,7 @@ def sum_from_one_to_n(n): if n > 1: wynik = 0 for i in range(n+1): - wynik = i + wynik + wynik += i return wynik else: return 0 pass diff --git a/labs02/task05.py b/labs02/task05.py index f59268a..69c9138 100644 --- a/labs02/task05.py +++ b/labs02/task05.py @@ -10,7 +10,11 @@ np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5. """ def euclidean_distance(x, y): - pass + sum = 0 + for i in range(len(x)): + sum += ((x[i]-y[i])**2) + distance = sum ** (1/2) + return distance def tests(f): inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]] diff --git a/labs02/task06.py b/labs02/task06.py index ff4a9d3..0f57c7b 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 + string = "NO!" + if n >= 5: + napis = string[0]+string[1]*n+string[2] + return napis + else: return "It's not a Big 'No!'" def tests(f): inputs = [[5], [6], [2]]