dist = sqrt( (x2 - x1)**2 + (y2 - y1)**2 )
As others have pointed out, you can also use the equivalent built-in math.hypot()
:
dist = math.hypot(x2 - x1, y2 - y1)
More Related Contents:
- Python. Finding thresholds for rows of data
- Does Python IDE have a module which imports math functions such as cos or sin? [closed]
- Evaluating a mathematical expression in a string
- What is the difference between ‘/’ and ‘//’ when used for division?
- Why does the division get rounded to an integer?
- What is the standard way to add N seconds to datetime.time in Python?
- Evenly distributing n points on a sphere
- Python round up integer to next hundred
- calculating direction of the player to shoot pygame
- Base 62 conversion
- What is the best way to get all the divisors of a number?
- How do you print superscript in Python?
- How do I do exponentiation in python? [duplicate]
- How did Python implement the built-in function pow()?
- How do I compute derivative using Numpy?
- How can I randomly choose a maths operator and ask recurring maths questions with it?
- numpy max vs amax vs maximum
- Safest way to convert float to integer in python?
- numpy arbitrary precision linear algebra
- Cubic root of the negative number on python
- What do these operators mean (** , ^ , %, //)? [closed]
- Python Math – TypeError: ‘NoneType’ object is not subscriptable
- Generating unique, ordered Pythagorean triplets
- How do order of operations go on Python?
- Math Expression Evaluation
- negative pow in python
- How to compute the nth root of a very big integer
- Function to determine if two numbers are nearly equal when rounded to n significant decimal digits
- How do you get the next value in the floating-point sequence? [duplicate]
- Why is numpy.prod() incorrectly returning negative results, or 0, for my long lists of natural numbers?