From 1afc8fd9fe08fcda870617aadbe320c67cb2421f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Maliszewski?= Date: Wed, 13 Jun 2018 17:35:20 +0000 Subject: [PATCH] Zaktualizuj 'labs02/task05.py' --- labs02/task05.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/labs02/task05.py b/labs02/task05.py index f59268a..0d62309 100644 --- a/labs02/task05.py +++ b/labs02/task05.py @@ -9,8 +9,17 @@ trzyelementowe listy liczb zmiennoprzecinkowych. np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5. """ +import cmath + def euclidean_distance(x, y): - pass + odleglosc=0 + + for i in range(3): + odleglosc= odleglosc + (x[i] - y[i]) ** 2 + + odleglosc = cmath.sqrt(odleglosc) + #odleglosc=odleglosc ** (1/2) + return odleglosc def tests(f): inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]] @@ -23,4 +32,4 @@ def tests(f): return "TESTS PASSED" if __name__ == "__main__": - print(tests(euclidean_distance)) + print(tests(euclidean_distance)) \ No newline at end of file