# Python Program to Find Area of a Circular Segment

In the previous article, we have discussed Python Program to Find the Center of the Circle using Endpoints of Diameter
When a chord is drawn in a circle, it divides the circle into two parts. These two parts of the circle are known as circle segments. The smaller area is referred to as the Minor segment, while the larger area is referred to as the Major segment.

Given the radius of the circle and the angle that forms a minor segment, the task is to find the areas of both major and minor segments of a circle.

Formula:

pi * r2 * (angle/360) – 1/2 * r2 * Sin(angle)

Examples:

Example1:

Input:

Given radius = 20
Given angle =  60 (degrees)

Output:

The minor segment area = 36.23434102950645
The major segment area = 1220.402189686826

Example2:

Input:

Given radius = 10.5
Given angle =  45

Output:

The minor segment area = 4.315801733342639
The major segment area = 342.0447026361856

## Program to Find Area of a Circular Segment in Python

Below are the ways to find the areas of both major and minor segments of a circle in Python:

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

Approach:

• Import math module using the import keyword.
• Give the radius as static input and store it in a variable.
• Give the angle as static input and store it in another variable.
• Take a variable and initialize the pi value as 3.14159.
• Create a function to say BothSegments_area() which takes the given radius and angle as the arguments, and returns the major and minor segments area.
• Inside the function, calculate the value area of the sector using the above given mathematical formula and store it in a variable.
• Calculate the area of the triangle using the above given mathematical formula and math.sin() function.
• Store it in another variable.
• Subtract the area of a triangle from the area of a sector and return it.
• Pass the given radius and angle as the arguments to the BothSegments_area() function and print the area of the minor segment.
• Pass the given radius and 360-angle as the arguments to the BothSegments_area() function and print the area of the major segment.
• The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math

# Create a function to say BothSegments_area() which takes the given radius and angle
# as the arguments, and returns the major and minor segments area.

# Inside the function, calculate the value area of the sector using the above
# given mathematical formula and store it in a variable.

# Calculate theÂ area of the triangle using the above given mathematical formula and
#  math.sin() function.
# store it in another variable.
rsltareaof_triangl = 1 / 2 * \

# Subtract the area of a triangle from the area of a sector and return it.
return rsltareaof_sectr - rsltareaof_triangl

# Give the radius as static input and store it in a variable.
# Give the angle as static input and store it in another variable.
gven_angl = 60
# Take a variable and initialize the pi value as 3.14159.
pi = 3.14159
# Pass the given radius and angle as the arguments to the BothSegments_area()
# function and print the area of the minor segment.
print("The minor segment area =",
# Pass the given radius and 360-angle as the arguments to the BothSegments_area()
# function and print the area of the major segment.
print("The major segment area =",


Output:

The minor segment area = 36.23434102950645
The major segment area = 1220.402189686826

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

Approach:

• Import math module using the import keyword.
• Give the radius 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.
• Take a variable and initialize the pi value as 3.14159.
• Create a function to say BothSegments_area() which takes the given radius and angle as the arguments, and returns the major and minor segments area.
• Inside the function, calculate the value area of the sector using the above given mathematical formula and store it in a variable.
• Calculate the area of the triangle using the above given mathematical formula and math.sin() function.
• Store it in another variable.
• Subtract the area of a triangle from the area of a sector and return it.
• Pass the given radius and angle as the arguments to the BothSegments_area() function and print the area of the minor segment.
• Pass the given radius and 360-angle as the arguments to the BothSegments_area() function and print the area of the major segment.
• The Exit of the Program.

Below is the implementation:

# Import math module using the import keyword.
import math

# Create a function to say BothSegments_area() which takes the given radius and angle
# as the arguments, and returns the major and minor segments area.

# Inside the function, calculate the value area of the sector using the above
# given mathematical formula and store it in a variable.

# Calculate theÂ area of the triangle using the above given mathematical formula and
#  math.sin() function.
# store it in another variable.
rsltareaof_triangl = 1 / 2 * \

# Subtract the area of a triangle from the area of a sector and return it.
return rsltareaof_sectr - rsltareaof_triangl

# Give the radius as user input using the float(input()) function and store it in a variable.
gven_radius = float(input("Enter some random number = "))
# Give the angle as as user input using the float(input()) function and
# store it in another variable.
gven_angl = float(input("Enter some random number = "))
# Take a variable and initialize the pi value as 3.14159.
pi = 3.14159
# Pass the given radius and angle as the arguments to the BothSegments_area()
# function and print the area of the minor segment.
print("The minor segment area =",
# Pass the given radius and 360-angle as the arguments to the BothSegments_area()
# function and print the area of the major segment.
print("The major segment area =",

Enter some random number = 10.5
The major segment area = 342.0447026361856