Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions maths/distance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
Finding distance between a pair of coordinates (x1, y1) and (x2, y2)
"""


def getDistance(x1, y1, x2, y2):
"""
Using the standard distance Formula
**2 is to perform square operation
**5 is to perform square root operation
"""
return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5


if __name__ == "__main__":
print(f"The distance between the points is {getDistance(2, 4, 7, 16)} units")