On this page
math.dist
Prev: math.degrees | Up: math | Next: math.erf
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.dist
Tags: #public #python3 #stdlib #math
Import
import math
from math import dist
Signature & Overview
math.dist(p, q, /)
Return the Euclidean distance between two points p and q.
Usage
import math
assert math.isclose(math.dist((0, 0), (3, 4)), 5.0)
assert math.isclose(math.dist([1, 2, 3], [4, 6, 3]), 5.0)
Gotchas
- Works in any number of dimensions: Both points must have the same length, or
ValueErroris raised.
REPL Inspect
from math import dist
help(dist)
Linked from
Related notes
- tuts/python3/stdlib_module/math/degrees Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/erf Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/math/acos Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/acosh Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asin Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asinh Linked here; shared tags: #math, #stdlib
- tuts/c/stdlib/math shared tags: #math, #stdlib
- tuts/c/stdlib/math/fabs shared tags: #math, #stdlib
- tuts/c/stdlib/math/floor shared tags: #math, #stdlib