-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleAreaFinder.py
102 lines (89 loc) · 2.51 KB
/
SimpleAreaFinder.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Importing math module for Sqroot and Pi.
import math
#This is the menu part.
menu = """
A SIMPLE AREA FINDER FOR BASIC SHAPER.
1. For Circle
2. For Square
3. For Triangle
"""
# This prints the menu
print(menu)
# Getting the option input
Is_Option_Selected = False
while not Is_Option_Selected:
try:
option = int(input("Please select the option "))
if option > 0 and option < 4:
Is_Option_Selected = True
else:
print("Please Select From the list.")
Is_Option_Selected = False
except:
print("Must be a number")
Is_Option_Selected = False
# This is the processing part
def Asker(option):
if option == 1:
Circle()
elif option == 2:
Square()
elif option == 3:
Triangle()
# Circle
def Circle():
Is_End = False
while not Is_End:
radius = input("Please Enter the Radius >>> ")
try:
r = int(radius)
area = 2 * math.pi * r
return print(f"The Area of the Circle is {area} or ~ {round(area)} units")
Is_End = True
except:
print("Must Be a Number")
Is_End = False
def Square():
Is_End = False
while not Is_End:
side = input("Please Enter the Side >>> ")
try:
s = int(side)
area = s*s
return print(f"The Area of the Square is {area} units")
Is_End = True
except:
print("Must be a Number")
Is_End = False
def Triangle():
Is_End_1 = False
while not Is_End_1:
type_menu = """
Please enter the type of Triangle (In number):
1. A Triangle given Sides a, b, c
2. A Triangle given it's Height and Base
3. An equal-sides Triangle
"""
print(type_menu)
try:
Stype = int(input("Please Enter the type >>> "))
Is_End_1 = True
except:
print("Option Must be a number")
Is_End_1 = False
def ABC():
a = input("Please input the First Side >>> ")
b = input("Please input the Second Side >>> ")
c = input("Please input the Third Side >>> ")
try:
a = int(a)
b = int(b)
c = int(c)
s = (a+b+c)/2
area = math.sqrt(s * (s - a) * (s - b) * (s - c))
return print(f"The area of the triangle is {area} or ~ {round(area)}")
except:
print("lol")
if Stype == 1:
ABC()
Asker(option)