Skip to content

Commit

Permalink
Implemented the distance between two points in python
Browse files Browse the repository at this point in the history
  • Loading branch information
grubdragon committed Oct 13, 2017
1 parent c5f84a8 commit 4d97e15
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def calc_distance(x1,y1,x2,y2):
return (((x1-x2)**2)+((y1-y2)**2))**0.5

try:
input = raw_input
except NameError:
pass

x1 = float(input("Enter X coordinate of point 1"))
y1 = float(input("Enter Y coordinate of point 1"))
x2 = float(input("Enter X coordinate of point 2"))
y2 = float(input("Enter Y coordinate of point 2"))

print("Distance between ("+x1+", "+y1+") and ("+x2+", "+y2+") : "+str(calc_distance(x1,y1,x2,y2))

0 comments on commit 4d97e15

Please sign in to comment.