Advertisement
aneliabogeva

Distance Between Points

Jul 10th, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import math
  2.  
  3.  
  4. class Point:
  5. def __init__(self, x, y):
  6. self.x = x
  7. self.y = y
  8.  
  9. @classmethod
  10. def calculate(cls, p1, p2):
  11. cls.distance = math.sqrt(math.pow(p1.x - p2.x, 2) + math.pow(p1.y - p2.y, 2))
  12. return f"{cls.distance:.3f}"
  13.  
  14. p1_coordinates = list(map(int, input().split(" ")))
  15. p1 = Point(p1_coordinates[0], p1_coordinates[1])
  16.  
  17. p2_coordinates = list(map(int, input().split(" ")))
  18. p2 = Point(p2_coordinates[0], p2_coordinates[1])
  19.  
  20. print(Point.calculate(p1, p2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement