Python Programming: Area of a triangle

Example

Input 
enter the base 5 
enter the height 6 
Output 
The area of the triangle is 15

Required to Know

Use of Variables, Use of different operators like assignment or arithmetic operators, Use of functions like print(), and input(), and Use of Data types.

Formula

Area of the triangle = (base * height)/2

Steps

  • Take base and height as input from the user.

  • Use the formula to find the area of the triangle.

  • Print the area of the triangle.

Program

# Get the base and height of the triangle from the user
base = float(input("Enter the base of the triangle: "))
height = float(input("Enter the height of the triangle: "))
# Calculate the area of the triangle
area = (base * height) / 2
# Print the area of the triangle
print("The area of the triangle is", area)