Distance between two points using pythagoras theorem.
Q.write a program to compute distance between two points taking inputs from the user ( pythagoras theorem).
Ans:
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)
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)
Comments
Post a Comment