
Exercise 43
Write a python program that asks the user to enter the height and base of a triangle and returns the area of the triangle.
Solution
# ask user to enter height of triangle
h = float(input("Enter height value of triangle : "))
# ask user to enter base of triangle
b = float(input("Enter base value of triangle : "))
# calculatigng the area of triangle
area = b*h/2
# disply result
print("The area of triangle is Area = " , area)
# Example for h = 7 and b = 8 the out put is :
# The area of triangle is Area = 28.0
Younes Derfoufi
my-courses.net
my-courses.net