
Annie W.
asked 11/01/20python math help
Assign point_dist with the distance between point (x1, y1) and point (x2, y2). The calculation is: Distance = SquareRootOf( (x2 - x1)2 + (y2 - y1)2 ).
Sample output with inputs: 1.0 2.0 1.0 5.0
1 Expert Answer

Patrick B. answered 11/03/20
Math and computer tutor/teacher
import math
print("Hello world")
def point_dist (x1,y1,x2,y2):
xSqr = (float(x1)-float(x2))**2
ySqr = (float(y1)-float(y2))**2
return( math.sqrt(float(xSqr)+float(ySqr)))
print("First Point")
x1 = input("Please input X1 :>");
y1 = input("pLease input Y1 :>")
print("Second Point")
x2 = input("Please input X2 :>")
y2 = input("Please input Y2 :>")
D = point_dist(x1,y1,x2,y2)
print('the distance is ')
print(D)
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
source code uploaded to RESOURCES under this link.. you must rename the file to ptython with *.py extension11/03/20