#!/usr/bin/env python # -*- coding: utf-8 -*- """ Napisz funkcję euclidean_distance obliczającą odległość między dwoma punktami przestrzeni trójwymiarowej. Punkty są dane jako trzyelementowe listy liczb zmiennoprzecinkowych. np. odległość pomiędzy punktami (0, 0, 0) i (3, 4, 0) jest równa 5. """ import math def euclidean_distance(x, y): x1 = x[0] x2 = y[0] y1 = x[1] y2 = y[1] z = math.sqrt((x1-x2)**2+(y1-y2)**2) return z def tests(f): inputs = [[(2.3, 4.3, -7.5), (2.3, 8.5, -7.5)]] outputs = [4.2] for input, output in zip(inputs, outputs): if f(*input) != output: return "ERROR: {}!={}".format(f(*input), output) break return "TESTS PASSED" if __name__ == "__main__": print(tests(euclidean_distance))