Answer to Question #258033 in Python for Kelly

Question #258033
S=9 b=5 C=8 Area=√s(s-9)(s-b)(s-c) S=a+b+c/2 Write a program that calculate the area of a triangle. Prompt for S Display area to 4dp
1
Expert's answer
2021-10-29T00:55:00-0400


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



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog