Write a Python Program to find the Area Of a Triangle using base and height with a practical example.
This Python program allows the user to enter the base and height of a triangle. By using the base and height values, it finds the area of a triangle. The mathematical formula to find the Area of a triangle using base and height is: Area = (base * height) / 2. Refer to the Python tutorial page.
base = float(input('Please Enter the Base of a Triangle: '))
height = float(input('Please Enter the Height of a Triangle: '))
# calculate the area
area = (base * height) / 2
print("The Area of a Triangle using", base, "and", height, " = ", area)

Python Program to find Area of a Triangle using base and height example 2
This Program for the area of the triangle is the same as above. However, we separated the area of the triangle Python program logic using the Python functions concept.
def area_of_triangle(base, height):
return (base * height) / 2
base = float(input('Please Enter the Base of a Triangle: '))
height = float(input('Please Enter the Height of a Triangle: '))
# calculate the area
area = area_of_triangle(base, height)
print("The Area of a Triangle using", base, "and", height, " = ", area)
The Area of a Triangle using base and height output.
Please Enter the Base of a Triangle: 35
Please Enter the Height of a Triangle: 85
The Area of a Triangle using 35.0 and 85.0 = 1487.5
Also Read