Python Programming: Area of Triangle

#Find the area of triangleimport math
a=int(input("Enter the length of first side : "))
b=int(input("Enter the length of second side : "))
c=int(input("Enter the lenth of third side : "))
if((a+b)>c and (c+a)>b and (b+c)>a):
    s=(a+b+c)/2    Area=math.sqrt(s*(s-a)*(s-b)*(s-c))
    print("Area of the triangle : ",Area)
else:
    print("Invalid Triangle")


Output:
Run 1: 

Enter the length of first side : 2
Enter the length of second side : 2
Enter the lenth of third side : 6
Invalid Triangle

Run 2:

Enter the length of first side : 6
Enter the length of second side : 4
Enter the lenth of third side : 7
Area of the triangle :  11.976539567003485

Comments