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))))
加入系列(10,12),(12,10)給我2.0,當實際距離(圓整些)爲2.82842
。看起來Python是我的編號。爲什麼以及這是如何發生的?爲什麼(以及如何)Python圍繞這個數學方程?
就是這樣!謝謝。 * facepalm *我正在尋找一種不那麼明顯的方式。 – 2012-03-26 16:23:14
@ElliotBonneville:總是首先尋找明顯的。我需要更少的時間。 – 2012-03-26 16:30:29
經驗教訓,再次感謝。在5分鐘內接受。 – 2012-03-26 16:30:49