This Python program calculates the area of a trapezoid using the following formula:
s = h × (a + b) ÷ 2
Where a and b are the lengths of the two parallel sides, and h is the height.
The user enters these values, and the program computes and displays the result.
# Get input from user
a = float(input("Length of first parallel side (a): "))
b = float(input("Length of second parallel side (b): "))
h = float(input("Height (h): "))
# Calculate area
area = h * (a + b) / 2
# Display result
print("\n--- Result ---")
print(f"Trapezoid area: {area}")
Length of first parallel side (a): 8
Length of second parallel side (b): 12
Height (h): 5
--- Result ---
Trapezoid area: 50.0
- The user enters the lengths of the two parallel sides and the height
- The program applies the trapezoid area formula directly
- The result is printed in a clear and readable format