MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / getDistance

Function getDistance

src/gamesbyexample/vacuumbot.py:181–184  ·  view source on GitHub ↗

Returns the distance between (x1, y1) and (x2, y2) by using the Pythagorean Theorem.

(x1, y1, x2, y2)

Source from the content-addressed store, hash-verified

179
180
181def getDistance(x1, y1, x2, y2):
182 """Returns the distance between (x1, y1) and (x2, y2) by using the
183 Pythagorean Theorem."""
184 return math.sqrt(((x1 - x2) ** 2) + ((y1 - y2) ** 2))
185
186
187def line(x1, y1, x2, y2):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected