In the previous article, we have discussed Python Program to Check Sunny Number

**Trapezoid**

A trapezoid is a four-sided geometrical figure with two sides that are parallel to each other. the sides that are parallel to each other are referred to as the “base” The other sides are referred to as “legs” (which may or may not be equal).

The **formula** for calculating the area of a trapezoid = **(a+b)*h/2**

where a, b = base of the trapezoid

h = denotes the distance between two parallel lines.

Given the base_1, base_2, and height of the trapezoid, and the task is to calculate the area of the given trapezoid.

**Examples:**

**Example 1:**

**Input: **

Given first base = 6 Given second base = 2 Given height = 1

**Output:**

The Area of the given Trapezoid = 4.0

**Example 2:**

**Input: **

Given first base = 10 Given second base = 9 Given height = 8.5

**Output:**

The Area of the given Trapezoid = 80.75

## Program to Calculate the Area of a Trapezoid

Below are the ways to calculate the area of the given trapezoid.

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

**Approach:**

- Give the first base as static input and store it in a variable.
- Give the second base as static input and store it in another variable.
- Give the height of the given trapezoid as static input and store it in another variable.
- Calculate the area of the given trapezoid using the above given mathematical formula and store it in another variable.
- Print the area of the given trapezoid.
- The Exit of the program.

**Below is the implementation:**

# Give the first base as static input and store it in a variable. fst_base = 2 # Give the second base as static input and store it in another variable. secnd_base = 4 # Give the height of the given trapezoid as static input and store it in another variable gvn_Heigt = 1.5 # Calculate the area of the given trapezoid using the above given mathematical formula # and store it in another variable. trapezod_area = 0.5 * (fst_base + secnd_base) * gvn_Heigt print("The Area of the given Trapezoid = ", trapezod_area)

**Output:**

The Area of the given Trapezoid = 4.5

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

**Approach:**

- Give the first base as user input using the float(input()) function and store it in a variable.
- Give the second base as user input using the float(input()) function and store it in another variable.
- Give the height of the given trapezoid as user input using the float(input()) function and store it in another variable.
- Calculate the area of the given trapezoid using the above given mathematical formula and store it in another variable.
- Print the area of the given trapezoid.
- The Exit of the program.

**Below is the implementation:**

# Give the first base as user input using the float(input()) function and # store it in a variable. fst_base = float(input("Enter some random number = ")) # Give the second base as user input using the float(input()) function and # store it in another variable. secnd_base = float(input("Enter some random number = ")) # Give the height of the given trapezoid as user input using the float(input()) function # and store it in another variable. gvn_Heigt = float(input("Enter some random number = ")) # Calculate the area of the given trapezoid using the above given mathematical formula # and store it in another variable. trapezod_area = 0.5 * (fst_base + secnd_base) * gvn_Heigt print("The Area of the given Trapezoid = ", trapezod_area)

**Output:**

Enter some random number = 3 Enter some random number = 4 Enter some random number = 5 The Area of the given Trapezoid = 17.5

Explore more instances related to python concepts from Python Programming Examples Guide and get promoted from beginner to professional programmer level in Python Programming Language.