aneliabogeva

Distance Between Points

Jul 10th, 2019
127
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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))
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×