Write a Python program to find the area of a triangle
1 2 3 4 5 6 7 8 9 10 11 |
# 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