# Python program to calculate arc length of an angle

In this session, we are going to learn **how to calculate the arc length of an angle in Python.**

## Find out the arc length of an angle in python

Arc length:

Arc length is defined as the certain length of a circumference of a given circle.

The formula for the arc length:

Arc_length = (math.pi*d) * (A/360) where d= diameter of the circle. A=angle enterd by the user.

let’s see coding part of the arc length.

1st import the math package for using PI’s value.

#import math package to use math.pi for the value of PI import math

create a function which takes the value from the user and perform all operations:

#create a function to calculate the arc length. def Arclength(): # take input diameter and angle . d= float(input("please Enter the diameter of circle: ")) Angle = float(input("please Enter the angle value: ")) # checking for the angle validation if Angle >= 360: print("Invalid angle entered ") return #calculate arc length. Arc_length = (math.pi*d) * (Angle/360)

call the function and retrieve all the results.

print("the arc Length will be : %.2f" %Arc_length) #function call Arclength()

Now combine the whole program:

#python code for finding the arc length of the angle. ##impotr math package to use math.pi for the value of PI import math #create a function to calculate the arc length. def arclength(): # take input diameter and angle . d= float(input("please Enter the diameter of circle: ")) Angle = float(input("please Enter the angle value: ")) # checking for the angle validation if Angle >= 360: print("Invalid angle entered ") return #calculate arc length. Arc_length = (math.pi*d) * (Angle/360) print("the arc Length will be : %.2f" %Arc_length) #function call arclength()

Output:

please Enter the diameter of circle: 9 please Enter the angle value: 45 the arc Length will be : 3.53

Also learn:

## Leave a Reply