Write a Python program to compute distance between two points in R². Take the inputs
from the user.
Answers
Answered by
0
Answer:
Distance can be calculated using the two points (x1, y1) and (x2, y2), the distance d between these points is given by the formula:
for e.g : let x1 , y1=10,9 and x2 , y2=4,1 then (x2-x1)2=(10-4)2 = 62 = 36 and (y2-y1)2= (9-1)2 = 82 = 64 now 64 + 36 =100 and 100 is square root of 10 sp distance between (10,9) and (4,1) is 10 .
Explanation:
x1=int(input("enter x1 : "))
x2=int(input("enter x2 : "))
y1=int(input("enter y1 : "))
y2=int(input("enter y2 : "))
result= ((((x2 - x1 )**2) + ((y2-y1)**2) )**0.5)
print("distance between",(x1,x2),"and",(y1,y2),"is : ",result)
Similar questions