×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

math.hypot() method with example in Python

Python math.hypot() method: Here, we are going to learn about the math.hypot() method with example in Python.
Submitted by IncludeHelp, on April 18, 2019

Python math.hypot() method

math.hypot() method is a library method of math module, it used to find the result of Euclidean norm, sqrt(x*x, y*y), it accepts two numbers and returns the result of Euclidean norm.

Euclidean norm – is the length of the vector from the origin to point (x,y).

Note: If we provide anything like string, except a number, it returns a “ValueError” – “TypeError: a float is required”.

Reference: Python math library

Syntax of math.hypot() method:

    math.hypot(x, y)

Parameter(s): x, y – numbers to calculate Euclidean norm.

Return value: float – it returns a float value that is the calculated result of Euclidean norm.

Example:

    Input:
    x = 2
    y = 3

    # function call
    print(math.hypot(x,y))

    Output:
    3.605551275463989

Python code to demonstrate example of math.hypot() method

# python code to demonstrate example of 
# math.hypot() method 

# importing math module
import math 

# numbers
x = 2
y = 3
print(math.hypot(x,y))

x = 2.3
y = 3.34
print(math.hypot(x,y))

x = 0
y = 3
print(math.hypot(x,y))

x = 2
y = 0
print(math.hypot(x,y))

x = -2
y = 3
print(math.hypot(x,y))

x = -2
y = -3
print(math.hypot(x,y))

Output

3.605551275463989
4.055317496818221
3.0
2.0
3.605551275463989
3.605551275463989
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.