Guest User

Untitled

a guest
Oct 24th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. import math
  2.  
  3. # Example points in 3-dimensional space...
  4. x = (4, 5, 6)
  5. y = (7, 8, 9)
  6.  
  7. # Given that x and y are both tuples in k-dimensional space, we
  8. # can calculate the Euclidean distance from x to y as follows...
  9. distance = math.sqrt(sum([(a - b) ** 2 for a, b in zip(x, y)]))
Add Comment
Please, Sign In to add comment