Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. class Coordinate(object):
  2. def __init__(self, x, y):
  3. self.x = x
  4. self.y = y
  5. def distance(self, other):
  6. x_diff_sq = (self.x-other.x)**2
  7. y_diff_sq = (self.y-other.y)**2
  8. return (x_diff_sq + y_diff_sq)**0.5
  9. def __str__(self):
  10. return "<"+str(self.x)+","+str(self.y)+">"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement