SOLUTION CODE FOR THE ABOVE PROGRAM
#A program for calculating the area of a triangle given the three sides
#prompt the user to enter the three sides of the triangle
print("\nEnter the three sides of the triangle i.e a, b and c")
a = int(input("Enter value of a: "))
b = int(input("Enter value of b: "))
c = int(input("Enter value of c: "))
#calculate the value of S
s = (a+b+c)/2
#Find the area of the triangle given by the formular Area=√s(s-9)(s-b)(s-c)
#The heroes formular
area = pow((s*(s-a)*(s-b)*(s-c)),0.5)
#Display the area of the triangle
print("\nThe area of the triangle = "+str(format(area, ".4f")))
SAMPLE OUTPUT OF THE ABOVE PROGRAM
Comments
Leave a comment