Created
February 24, 2019 08:05
-
-
Save evdokimovm/d8d39bbb9cf6071d59b8a5ae1c5602ef to your computer and use it in GitHub Desktop.
euclidean distance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def euclidean_distance(pt1, pt2): | |
distance = 0 | |
for i in range(len(pt1)): | |
distance += (pt1[i] - pt2[i]) ** 2 | |
return distance ** 0.5 | |
print(euclidean_distance([1, 2], [4, 0])) | |
print(euclidean_distance([5, 4, 3], [1, 7, 9])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment