Area Of Triangle In Python
Chapter:
Python
Last Updated:
14-09-2018 05:07:23 UTC
Program:
/* ............... START ............... */
# Python program to find area of triangle - Example
a = 8
b = 10
c = 15
# Finding semi-perimeter
s = (a + b + c) / 2
# Triangle area calculation
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('Area of Triangle : %0.2f' %area)
/* ............... END ............... */
Output
Notes:
-
In the above program first we will take the values of three sides and we will find semi-perimeter and store in variable s.
- Next step we will calculate area using the formula and print the values using the print function in python.