Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

Python hypot

by suresh

The Python hypot function returns the square root of the sum of squares of the specified arguments. In this section, we discuss how to use hypot function in Python with an example.

The syntax of the math hypot Function in Python Programming Language is

math.hypot(Value1, Value2, ...ValueN);

Value1…ValueN: Valid numerical expression.

  • If the value argument is a positive integer and Negative integer, hypot function returns the Output.
  • If it is not a number, hypot function return TypeError.

Python hypot Function Example

The Python hypot function finds the square root of the sum of squares of a given number. In this hypot example, We are going to find the sum of squares of the square root of different data types and display the output.

# Python HYPOT Function

import math

Tup = (1, 2, 3, -4 , 5)
Lis = [-1, 2, -3.5, -4 , 7.5]

print('HYPOT value of Positive Number = %.2f' %math.hypot(2, 3))
print('HYPOT value of Negative Number = %.2f' %math.hypot(2, -4))

print('HYPOT value of Tuple Item = %.2f' %math.hypot(Tup[3], Tup[2]))
print('HYPOT value of List Item = %.2f' %math.hypot(Lis[2], Lis[4]))

print('HYPOT value of Multiple Number = %.2f' %math.hypot(2 + 7 - 4, 9 - 5))

print('HYPOT value of String Number = %.2f', math.hypot('Hello', 'Python'))
Python HYPOT Function

First, we used the hypot Function directly on both the Positive integer and negative integer. The following Python statements find the square root of the sum of squares of the corresponding values.

print('HYPOT value of Positive Number = %.2f' %math.hypot(2, 3))
print('HYPOT value of Negative Number = %.2f' %math.hypot(2, -4))

Next, We used the hypot Function on Tuple and List items. As you see, hypot function is working perfectly on them.

print('HYPOT value of Tuple Item = %.2f' %math.hypot(Tup[3], Tup[2]))
print('HYPOT value of List Item = %.2f' %math.hypot(Lis[2], Lis[4]))

Next, we used the hypot Math function on multiple values.

print('HYPOT value of Multiple Number = %.2f' %math.hypot(2 + 7 - 4, 9 - 5))

Within the last statement, we tried the hypot Function on the String value, and it returns TypeError.

print('HYPOT value of String Number = %.2f', math.hypot('Hello', 'Python'))

Placed Under: Python

  • Download and Install Python
  • Python Arithmetic Operators
  • Python Assignment Operators
  • Python Bitwise Operators
  • Python Comparison Operators
  • Python Logical Operators
  • Python If Statement
  • Python If Else
  • Python Elif Statement
  • Python Nested If
  • Python For Loop
  • Python While Loop
  • Python Break
  • Python Continue
  • Python Dictionary
  • Python datetime
  • Python String
  • Python Set
  • Python Tuple
  • Python List
  • Python List Comprehensions
  • Python Lambda Function
  • Python Functions
  • Python Types of Functions
  • Python Iterator
  • Python File Handling
  • Python Directory
  • Python Class
  • Python classmethod
  • Python Inheritance
  • Python Method Overriding
  • Python Static Method
  • Connect Python and SQL Server
  • Python SQL Create DB
  • Python SQL Select Top
  • Python SQL Where Clause
  • Python SQL Order By
  • Python SQL Select Statement
  • Python len Function
  • Python max Function
  • Python map Function
  • Python print Function
  • Python sort Function
  • Python range Function
  • Python zip Function
  • Python Math Functions
  • Python String Functions
  • Python List Functions
  • Python NumPy Array
  • NumPy Aggregate Functions
  • NumPy Arithmetic Operations
  • Python Numpy Bitwise operators
  • Numpy Comparison Operators
  • Numpy Exponential Functions
  • Python Numpy logical operators
  • Python numpy String Functions
  • NumPy Trigonometric Functions
  • Python random Array
  • Python numpy concatenate
  • Python numpy Array shape
  • Python pandas DataFrame
  • Pandas DataFrame plot
  • Python Series
  • Python matplotlib Histogram
  • Python matplotlib Scatter Plot
  • Python matplotlib Pie Chart
  • Python matplotlib Bar Chart
  • Python List Length
  • Python sort List Function
  • Python String Concatenation
  • Python String Length
  • Python substring
  • Python Programming Examples

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy