Calculate Right-Angled Triangle Hypotenuse Length

  • Share this:

Code introduction


Calculate the length of the hypotenuse of a right-angled triangle.


Technology Stack : None

Code Type : Mathematical calculation function

Code Difficulty : Intermediate


                
                    
def calculate_hypotenuse(a, b):
    """Calculate the length of the hypotenuse of a right-angled triangle.

    Args:
        a (float): Length of the first leg of the triangle.
        b (float): Length of the second leg of the triangle.

    Returns:
        float: Length of the hypotenuse.
    """
    return (a**2 + b**2)**0.5                
              
Tags: