Hackerss.com

hackerss
hackerss

Posted on

Python Calculate perimeter of a circle


#create a function that calculates the perimeter of a circle
def perimeter(radius):
    """
    Calculate the perimeter of a circle.

    Parameters
    ----------
    radius : float
        The radius of the circle.

    Returns
    -------
    float
        The perimeter of the circle.
    """

    #return the perimeter of the circle
    return 2 * math.pi * radius

#example
result = perimeter(5)
#output
print(result)  #31.41592653589793


Enter fullscreen mode Exit fullscreen mode

Top comments (0)