Calculate Area of a Triangle
Develop a program that reads the lengths (L1, L2 and L3 be the lengths) of the sides of a triangle from the user and displays its area. Use inbuilt sqrt function from math module.
## #Python's program to calculate the area of Triangle. ## from math import sqrt #Read the inputs from user l1 = float(input("Enter the length (L1) of Triangle: ")) l2 = float(input("Enter the length (L2) of Triangle: ")) l3 = float(input("Enter the length (L3) of Triangle: ")) #Calculate the area length = (l1+l2+l3)/2 total = (length * (length-l1) * (length-l2) * (length-l3)) area = sqrt(total) #Display the result print("The area of Trianle is: ",round(area,2))
Sample output of above program.
C:\Python\programs>python program.py
Enter the length (L1) of Triangle: 15
Enter the length (L2) of Triangle: 26
Enter the length (L3) of Triangle: 24
The area of Trianle is: 177.27
C:\Python\programs>
Enter the length (L1) of Triangle: 15
Enter the length (L2) of Triangle: 26
Enter the length (L3) of Triangle: 24
The area of Trianle is: 177.27
C:\Python\programs>
2017-08-12T23:03:41+05:30
2017-08-12T23:03:41+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution