Write a python program to calculate the area of a triangle using Heron's formula.

Write a  python  program to calculate the area of a triangle using Heron's formula.

program:

 # Heron's formula: [s(s-a)(s-b)]**(0.5) where s=(a+b+c)/2

# a,b,c are the sides of a triangle.

a=float(input("First side of a triangle:"))

b=float(input("Second side of a triangle:"))

c=float(input("Third side of a triangle:"))

s=float((a+b+c)/2)

area=((s)*(s-a)*(s-b)*(s-c))**(0.5)

print("The area of a triange by Heron's formula is",area,"square units")

OUTPUT:


No comments:

Post a Comment




Copyright Ⓒ 2022 | Mechpedia | All Right Reserved.