Skip to content

Instantly share code, notes, and snippets.

@MM-coder
Last active October 12, 2019 09:55
Show Gist options
  • Save MM-coder/2609fbe5913d0af828ff2482c48efe9c to your computer and use it in GitHub Desktop.
Save MM-coder/2609fbe5913d0af828ff2482c48efe9c to your computer and use it in GitHub Desktop.
Python program to calculate the distance between 2 points (2 tuples)
# Interactive @ https://py3.codeskulptor.org/#user304_lfQquGbAhO_0.py
import math
def point_distance(x0: int, y0: int, x1: int, y1: int):
result = math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2))
return result
x1 = int(input("Value for x1: "))
x2 = int(input("Value for x2: "))
y1 = int(input("Value for y1: "))
y2 = int(input("Value for y2: "))
print(f"The distance between ({x1},{x2}) ({y1},{y2}) is {point_distance(x1, x2, y1, y2)}")
@MM-coder
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment