Write a Python program to calculate arc length of an angle


This Python code calculates and prints the arc length of a circle segment based on user input. Here's an explanation of each part of the code:

  • import math: This line imports the math module, which provides various mathematical functions and constants.
  • angle_degrees = float(input("Enter the Angle in Degrees : ")): This line prompts the user to enter the angle in degrees and stores it as a floating-point number in the variable angle_degrees.
  • radius = float(input("Enter the Radius : ")): This line prompts the user to enter the radius of the circle and stores it as a floating-point number in the variable radius.
  • arc_length = (angle_degrees / 360) * (2 * math.pi * radius): This line calculates the arc length of the circle segment using the formula (θ / 360) * (2 * π * r) , where θ is the angle in degrees, π is a constant (math.pi), and r is the radius. The result is stored in the variable arc_length.
  • The code then uses a print statement to display the calculated arc length.

Source Code

import math
 
# Input the angle in degrees and the radius
angle_degrees = float(input("Enter the Angle in Degrees : "))
radius = float(input("Enter the Radius : "))
 
# Calculate the arc length
arc_length = (angle_degrees / 360) * (2 * math.pi * radius)
 
# Display the result
print("Arc Length : ",arc_length)

Output

Enter the Angle in Degrees : 35
Enter the Radius : 25
Arc Length :  15.271630954950384

Example Programs