Write a Python Program to find the Area Of a Triangle using base and height with a practical example.
Python Program to find Area of a Triangle using base and height 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: Area = (base * height) / 2.
# Python Program to find Area of a Triangle using base and height 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 calculate Area of a Triangle using base and height example 2
This Python program for the area of the triangle is the same as above. However, we separated the area of triangle program logic using Python functions concept.
# Python Program to find Area of a Triangle using base and height 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)
Python 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