Find us on Facebook

Thursday, December 13, 2018

Expt2. Python Program to find the area of triangle



Aim: Implement a program to find the area of triangle
Algorithm:
1.Start
2.Read three sides (a,b,c) 
3.calculate s=(a+b+c)/2 
4. calculate area=sqrt(s*(s-a)*(s-b)*(s-c)) 
5.print area 
6.Stop
Program:
# Three sides of the triangle a, b and c are provided by the user
a = float(input('Enter first side: '))
b = float(input('Enter second side: '))
c = float(input('Enter third side: '))
# calculate the semi-perimeter
s = (a + b + c) / 2
# calculate the area
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('The area of the triangle is %0.2f' %area)
Output:
Enter first side: 5
Enter second side: 6
Enter third side: 7
The area of the triangle is 14.70


0 Comments:

Popular Posts

Text Widget

Search This Blog

Powered by Blogger.

Blogger Pages

Like Canvas?

Sponsor

Footer Widgetized Areas

About Canvas

About Canvas

Subscribe Us

About

Text Widget

Tags

Total Pageviews

print pdf

cal

Most Popular

    TUPLES
 LIST and SLICING
      ASCII VALUE
Copyright © KTU Btech Cse Python Lab Manuals | Powered by Blogger
Design by Saeed Salam | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates