Area of a triangle in Python

 

Write a Python program to find the area of a triangle

# Three sides of the triangle is a, b and c:  
side1 = float(input('Enter first side: '))  
side2 = float(input('Enter second side: '))  
side3 = float(input('Enter third side: '))  
  
# calculate the semi-perimeter  
s = (side1 + side2 + side3) / 2  
  
# calculate the area  
Area_by_T4Tutorials = (s*(s-side1)*(s-side2)*(s-side3)) ** 0.5  
print('The area of the triangle is %0.2f' %Area_by_T4Tutorials)

Output

Enter first side: 6
Enter second side: 7
Enter third side: 4
The area of the triangle is 11.98

Leave a Reply

Contents Copyrights Reserved By T4Tutorials