wk.2.2.4
Define a procedure pointDist(x1, y1, x2, y2)
that returns the distance between a point in two-dimensional space with coordinates x1, y1 and another point with coordinates x2, y2
. Use math.sqrt
(of type num -> float
). Your function should have type (num, num, num, num) -> float
.
import math
def pointDist(x1, y1, x2, y2):
return math.sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1))
Page Source