How to use the hypot() to get the square root of the sum of squares of its arguments in Python

1 Answer

0 votes
import math

# Return the Euclidean distance, sqrt(x*x + y*y)

print("math.hypot(3, 4) = ", math.hypot(3, 4))
print("math.sqrt(3*3 + 4*4) = ", math.sqrt(3*3 + 4*4))
print("math.hypot(1, 1) = ", math.hypot(1, 1))
print("math.hypot(-9, -25) = ", math.hypot(-9, -25))


'''
run:

math.hypot(3, 4) =  5.0
math.sqrt(3*3 + 4*4) =  5.0
math.hypot(1, 1) =  1.4142135623730951
math.hypot(-9, -25) =  26.570660511172843

'''

 



answered Oct 17, 2017 by avibootz
...