Python Function distance that calculates the distance between two points (x1, y1) and (x2, y2). All numbers and return values should be of type double.

#Python Function distance that calculates the distance between two points (x1, y1) and (x2, y2). All numbers and return values should be of type double.


import math
def findDistance(x1, y1, x2, y2):
  	d=math.sqrt((math.pow(x2-x1,2))+(math.pow(y2-y1,2)))
  	return d
print("\nTwo Points (x1,x2) & (y1,y2) : ")
print("Enter x1:")
x1 = int(input()) 
print("Enter x2:")
x2 = int(input()) 
print("Enter y1:")
y1 = int(input())  
print("Enter y2:")
y2 = int(input()) 
r=findDistance(x1,y1,x2,y2)
print("Distance between the 2 points is ", r )

Output :
Two Points (x1,x2) & (y1,y2) :

Enter x1:
1
Enter x2:
2
Enter y1:
3
Enter y2:
4
Distance between the 2 points is 1.414214



Leave a comment