-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathArea-of-Triangle-Calculator.py
27 lines (25 loc) · 1.33 KB
/
Area-of-Triangle-Calculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# With Math Module
import math
base = int(input("Enter base of triangle: "))
height = int(input("Enter height of triangle: "))
ArM1 = (base*height)/2
print("Area of triangle is",ArM1,".")
print("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
side1 = int(input("Enter length of first side: "))
side2 = int(input("Enter length of second side: "))
side3 = int(input("Enter length of third side: "))
s = (side1+side2+side3)/2
ArM2 = math.sqrt(s*(s-side1)*(s-side2)*(s-side3))
print("Area of triangle is",ArM2,".")
# Without Math Module
base = int(input("Enter base of triangle: "))
height = int(input("Enter height of triangle: "))
ArM1 = (base*height)/2
print("Area of triangle is",ArM1,".")
print("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------")
side1 = int(input("Enter length of first side: "))
side2 = int(input("Enter length of second side: "))
side3 = int(input("Enter length of third side: "))
s = (side1+side2+side3)/2
ArM2 = (s*(s-side1)*(s-side2)*(s-side3))**(1/2)
print("Area of triangle is",ArM2,".")