Last active
October 12, 2019 09:55
-
-
Save MM-coder/2609fbe5913d0af828ff2482c48efe9c to your computer and use it in GitHub Desktop.
Python program to calculate the distance between 2 points (2 tuples)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://py3.codeskulptor.org/#user304_lfQquGbAhO_0.py