Python Program to Find the Area of a Triangle

In this program, we will create a Python program to calculate the area of a triangle. The area of a triangle can be determined using its base and height. By taking user input for the base and height, we will calculate and display the area of the triangle using a simple formula.

Problem statement

Write a Python program to calculate the area of a triangle using the base and height provided by the user.

Python Program to Find the Area of a Triangle

# Python Program to Find the Area of a Triangle

# Function to calculate the area of a triangle
def calculate_area(base, height):
    area = (base * height) / 2
    return area

# Take user input for base and height
base = float(input("Enter the base of the triangle: "))
height = float(input("Enter the height of the triangle: "))

# Calculate and display the area of the triangle
area = calculate_area(base, height)
print("The area of the triangle is:", area)

Input/Output

Python Program to Find the Area of a Triangle

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this Python program, we will create a singly linked list and remove duplicate elements from it. A linked list...
This Python program solves the Celebrity Problem by finding a person who is known by everyone but does not know...
This Python program uses a recursive approach to solve the n-Queens problem. It explores all possible combinations of queen placements...