Python - Calculate Area Of Triangle

In this program, you will learn how to calculate area of traingle.


Formula to caulucate the triangle if a, b, and c are the three sides.

    s = (a + b + c)/2     #s - semi perimeter
    area = √(s(s-a)*(s-b)*(s-c))  
            
            

Program Code



    #Python program to calculate the area of Triangle
    a = 5
    b = 4
    c = 6
    
    #Calculate the semi perimeter
    p = (a + b + c) / 2
    
    # Calculate the area
    area = (p * (p-a) * (p-b) * (p-c)) ** 0.5
    
    print('The area of the triangle is %0.2f' %area)
            
            

Output


The area of the triangle is 9.92
            



The following topics can be useful to understand this program.



Related Tutorials