112k views
5 votes
Write a program that prompts the user to enter two points (x1, y1) and (x2, y2) and displays their distance between them. The formula for computing the distance is: Square root of ((x2 - x1) squared + (y2 - y1) squared) Note that you can use pow(a, 0.5) to compute square root of a.

User Rcheuk
by
3.0k points

1 Answer

11 votes

Answer:

x1 = input("enter x value of first number: ")

y1 = input("enter y value of first number: ")

x2 = input("enter x value of second number: ")

y2 = input("enter y value of second number: ")

ans = (float(x2)-float(x1))**2 + (float(y2)-float(y1))**2

ans = pow(ans, 0.5)

print(ans)

User Jlconlin
by
3.6k points