Area of a triangle is the product of base x height of the triangle.
Given the base and height of a triangle as an input to the Python program we have to find the product of base and height and print the area of a triangle.
Write a program to find area of triangle
Take two variables: base and height of triangle. Ask the user to enter the base and height of a triangle, Using input function call and convert it into a float.
base = float(input("Enter Base of Triangle : "))
height = float(input("Enter Height of Triangle : "))
Take another variable named area and try to find the product of base X height. Once the product of base and height is found print the area of a triangle.
area = base * height
print("Area of Triangle is : %.2f" %area)
Final Program:
base = float(input("Enter Base of Triangle : "))
height = float(input("Enter Height of Triangle : "))
area = base * height
print("Area of Triangle is : %.2f" %area)
OUTPUT:
Enter Base of Triangle : 23
Enter Height of Triangle : 5.9
Area of Triangle is : 135.70
Conclusion: Try to run the program and comment Down below if you have any queries or suggestions.
0 Comments