A Program to Find the Area of a Triangle

In this example, we are giving a program to find the area of a triangle. The rule of finding the area of a triangle is: A = 0.5 * base * height.


Program to find the area of a triangle:

  1. b = float(input("Enter the value of base: "))
  2. h = float(input("Enter the value of height: "))
  3. area = 0.5 * b * h;
  4. print("Area of triangle: %.2f"%area)

Output:

Enter the value of base: 3
Enter the value of height: 4
Area of triangle: 6.00