Saturday 2 March 2019

Area of Triangle in Python


# Python Program to find the area of triangle
a = 5
b = 6
c = 7
# Uncomment below to take inputs from 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:

The area of the triangle is 14.70

0 Comments:

Post a Comment

Popular Posts

Categories

AI (1) Android (23) AngularJS (1) Assembly Language (2) book (1) Books (36) C (76) C# (12) C++ (82) Course (51) Coursera (8) Cybersecurity (4) Data Science (19) Data Strucures (4) Deep Learning (4) Django (1) Downloads (3) edx (1) Engineering (13) Excel (1) flutter (1) FPL (17) Google (10) Hadoop (1) HTML&CSS (41) IBM (1) IS (25) Java (90) Leet Code (4) Machine Learning (2) Meta (2) Pandas (2) PHP (20) Projects (26) Python (585) Python Coding Challenge (40) R (69) Selenium Webdriver (2) Software (15) SQL (28)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses