-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAreaCalculator.py
60 lines (44 loc) · 1.34 KB
/
AreaCalculator.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
# Codédex – Area Calculator
# GitHub & Codédex: @gabizzle
# 07/20/2024
import math
print('----------------------------------------------')
print(' Area Calculator 📐 ')
print('----------------------------------------------')
print(' 1) Triangle')
print(' 2) Rectangle')
print(' 3) Square')
print(' 4) Circle')
print(' 5) Quit\n')
print('Choose Shape by picking a number from 1 to 5: ')
choice = int(input())
# Triangle
if choice == 1:
print('TRIANGLE')
base = float(input('Enter the base: '))
height = float(input('Enter the height: '))
area = 0.5 * base * height
print(f'The area of the triangle is {area}')
# Rectangle
elif choice == 2:
print('RECTANGLE')
length = float(input('Enter the length: '))
width = float(input('Enter the width: '))
area = length * width
print(f'The area of the rectangle is {area}')
# Square
elif choice == 3:
print('SQUARE')
side = float(input('Enter the side: '))
area = side * side
print(f'The area of the square is {area}')
# Circle
elif choice == 4:
print('CIRCLE')
radius = float(input('Enter the radius: '))
# or use 3.14 without 'import math' & 'math.pi'
area = math.pi * radius * radius
print(f'The area of the circle is {area}')
# Quit
elif choice == 5:
print('Goodbye!')