Hackerss.com

Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in
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)