# Python Program for Arc Length from Given Angle

In the previous article, we have discussed Python Program to Find Area of a Circular Segment
Given the diameter and angle of the circle, the task is to calculate the arclength from the given angle.

An angle is a geometrical figure formed when two rays intersect at the same point on a plane. These rays form the angle’s sides, and the point where they intersect is known as the angle’s vertex. It is important to remember that the plane that forms an angle does not have to be a Euclidean plane. The length of an arc in a circle is now a fraction of the circumference.

Formula:

ArcLength = ( 2 * pi * radius ) * ( angle / 360 )

The angle is given in degrees.

Note: It should be noted that if the angle is greater than or equal to 360 degrees, the arc length cannot be calculated because no angle is possible.

Examples:

Example1:

Input:

Given diameter = 15
Given Angle = 60

Output:

The arc length for the given angle { 60 } degrees =  7.857142857142856

Example2:

Input:

Given diameter = 30
Given Angle = 90

Output:

The arc length for the given angle { 90 } degrees =  23.57142857142857

## Program for Arc Length from Given Angle in Python

Below are the ways to calculate the arc length from the given angle in python:

### Method #1: Using Mathematical Formula (Static Input)

Approach:

• Import math module using the import keyword.
• Give the diameter as static input and store it in a variable.
• Give the angle as static input and store it in another variable.
• Check if the given angle is greater than or equal to 360 degrees or not using the if conditional statement.
• If it is true, then print “The Arc length cannot be calculated for the given angle”.
• Else, calculate the arc length using the above given mathematical formula and store it in a variable.
• Print the arclength of the circle from the given angle.
• The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the diameter as static input and store it in a variable.
gvn_diametr = 15
# Give the angle as static input and store it in another variable.
gvn_angl = 60
# Check if the given angle is greater than or equal to 360 degrees or not using the
# if conditional statement.
if gvn_angl >= 360:
# If it is true, then print "The Arc length cannot be calculated for
# the given angle".
print("The Arc length cannot be calculated for the given angle.")
else:
# Else, calculate the arc length using the above given mathematical formula and
# store it in a variable.
arc_lengt = (3.142857142857143 * gvn_diametr) * (gvn_angl / 360.0)
# Print the arclength of the circle from the given angle.
print("The arc length for the given angle {",
gvn_angl, "} degrees = ", arc_lengt)


Output:

The arc length for the given angle { 60 } degrees =  7.857142857142856

### Method #2: Using Mathematical Formula (User Input)

Approach:

• Import math module using the import keyword.
• Give the diameter as user input using the float(input()) function and store it in a variable.
• Give the angle as user input using the float(input()) function and store it in another variable.
• Check if the given angle is greater than or equal to 360 degrees or not using the if conditional statement.
• If it is true, then print “The Arc length cannot be calculated for the given angle”.
• Else, calculate the arc length using the above given mathematical formula and store it in a variable.
• Print the arclength of the circle from the given angle.
• The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math
# Give the diameter as user input using the float(input()) function and
# store it in a variable.
gvn_diametr = float(input("Enter some Random Number = "))
# Give the angle as user input using the float(input()) function and store it in another variable.
gvn_angl = float(input("Enter some Random Number = "))
# Check if the given angle is greater than or equal to 360 degrees or not using the
# if conditional statement.
if gvn_angl >= 360:
# If it is true, then print "The Arc length cannot be calculated for
# the given angle".
print("The Arc length cannot be calculated for the given angle.")
else:
# Else, calculate the arc length using the above given mathematical formula and
# store it in a variable.
arc_lengt = (3.142857142857143 * gvn_diametr) * (gvn_angl / 360.0)
# Print the arclength of the circle from the given angle.
print("The arc length for the given angle {",
gvn_angl, "} degrees = ", arc_lengt)


Output:

Enter some Random Number = 30
Enter some Random Number = 90
The arc length for the given angle { 90.0 } degrees = 23.57142857142857

Practice Python Program Examples to master coding skills and learn the fundamental concepts in the dynamic programming language Python.