Sera H.
asked 02/20/21how do I get the final answer to 2 decimal places
this is what I have so far
x1 = input ("Enter coordinates for x1: ")
x1 = float (x1)
y1 = input ("Enter coordinates for y1: ")
y1 = float (y1)
x2 = input ("Enter coordinates for x2: ")
x2 = float (x2)
y2 = input ("Enter coordinates for y2: ")
y2 = float (y2)
d = ( (x2 - x1)**2 + (y2-y1)**2)** 0.5
print("Distance between",(x1,x2), "and",(y1,y2), "is:",d)
1 Expert Answer

Patrick B. answered 02/20/21
Math and computer tutor/teacher
# Changes in bold
x1 = input ("Enter coordinates for x1:> ")
x1 = float (x1)
y1 = input ("Enter coordinates for y1:> ")
y1 = float (y1)
x2 = input ("Enter coordinates for x2:> ")
x2 = float (x2)
y2 = input ("Enter coordinates for y2:> ")
y2 = float (y2)
d = ( (x2 - x1)**2 + (y2-y1)**2)** 0.5
dDistance = "{:.2f}".format(d)
print("Distance between",(x1,x2), "and",(y1,y2), "is:",dDistance)
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.
Sera H.
I want to use {:.2f}".format but I don't know where to add it02/20/21