# Python Program To Find Area of a Circular Sector

In the previous article, we have discussed Python Program for Arc Length from Given Angle
A circular sector, also known as a circle sector, is a portion of a disc bounded by two radii and an arc, with the smaller area known as the minor sector and the larger as the major sector.

Given the radius and angle of a circle, the task is to calculate the area of the circular sector in python.

Formula:

Area of sector = (angle/360)*(pi * radiusÂ²)

where pi=3.1415….

Examples:

Example1:

Input:

Given radius = 24
Given Angle = 90

Output:

The area of circular sector for the given angle { 90 } degrees =  452.57142857142856

Example2:

Input:

Given radius = 15.5
Given Angle =  45

Output:

The area of circular sector for the given angle { 45.0 } degrees = 94.38392857142857

## Program To Find Area of a Circular Sector in Python

Below are the ways to calculate the area of the circular sector for the given radius and angle in python:

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

Approach:

• 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 its value to 22/7.
• 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 “Invalid Angle. Please enter the other”.
• Else, calculate the area of the circular sector using the above given mathematical formula and store it in a variable.
• Print the area of the circular sector for the given angle.
• The Exit of the Program.

Below is the implementation:

# Give the radius as static input and store it in a variable.
# Give the angle as static input and store it in another variable.
gvn_angl = 90
# Take a variable and initialize its value to 22/7.
gvn_pi = 22/7
# 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 "Invalid Angle. Please enter the other"
print("Invalid Angle. Please enter the other")
else:
# Else, calculate the area of circular sector using the above given mathematical
# formula and store it in a variable.
area_of_sectr = (gvn_pi * gvn_radiuss ** 2) * (gvn_angl / 360)
# Print the area of circular sector for the given angle.
print("The area of circular sector for the given angle {",
gvn_angl, "} degrees = ", area_of_sectr)

#include <iostream>
#include<math.h>
using namespace std;

int main() {
int gvn_angl = 90;
int gvn_pi = 22 / 7;
if ( gvn_angl >= 360 ) {
printf ( "Invalid Angle. Please enter the other\n" );
}
else {
float area_of_sectr = ( gvn_pi * gvn_radiuss * gvn_radiuss ) * ( gvn_angl / 360 );
printf ( "The area of circular sector for the given angle {%d} degrees = %d\n", gvn_angl, area_of_sectr );
}

return 0;
}



Output:

The area of circular sector for the given angle { 90 } degrees =  452.57142857142856

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

Approach:

• 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 its value to 22/7.
• 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 “Invalid Angle. Please enter the other”.
• Else, calculate the area of the circular sector using the above given mathematical formula and store it in a variable.
• Print the area of the circular sector for the given angle.
• The Exit of the Program.

Below is the implementation:

# Give the radius as user input using the float(input()) function and store it in a variable.
gvn_radiuss = 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 = "))
# Take a variable and initialize its value to 22/7.
gvn_pi = 22/7
# 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 "Invalid Angle. Please enter the other"
print("Invalid Angle. Please enter the other")
else:
# Else, calculate the area of circular sector using the above given mathematical
# formula and store it in a variable.
area_of_sectr = (gvn_pi * gvn_radiuss ** 2) * (gvn_angl / 360)
# Print the area of circular sector for the given angle.
print("The area of circular sector for the given angle {",
gvn_angl, "} degrees = ", area_of_sectr)


Output:

Enter some Random Number = 15.5
Enter some Random Number = 45
The area of circular sector for the given angle { 45.0 } degrees = 94.38392857142857

Grab the opportunity and utilize the Python Program Code Examples over here to prepare basic and advanced topics too with ease and clear all your doubts.