0
def findDistance():
first_coord = raw_input("Enter first coordinate set (format x, y): ").split(",")
second_coord = raw_input("Enter second coordinate set (format x, y): ").split(",")
x1 = float(first_coord[0])
x2 = float(second_coord[0])
y1 = float(first_coord[1])
y2 = float(first_coord[1])
print math.sqrt(float(((x2 - x1) * (x2 - x1))) + float(((y2 - y1) * (y2 - y1))))
Setzen in die Serie (10, 12), (12, 10) gibt mir 2.0, wenn der tatsächliche Abstand (etwas abgerundet) ist 2.82842
. Es scheint, Python ist meine Nummer. Warum und wie geschieht das?Warum (und wie) rundet Python diese mathematische Gleichung?
Das war es! Vielen Dank. * facepalm * Ich war auf der Suche nach etwas weniger Offensichtlichem. –
@ElliotBonneville: Immer zuerst das Offensichtliche suchen. Ich brauche weniger Zeit. –
Lektion gelernt, danke nochmal. Akzeptieren in 5 min. –