Learning-Python/Tools/AreaCalc/AreaCalc.py

111 lines
3.8 KiB
Python
Raw Normal View History

2019-12-16 09:14:03 +01:00
import math
print('''Which Area/Volume Are You Calculating
[0] Quit
[1] Square
[2] Cube
[3] Pyramid
[4] Circle
[5] Arch Length
[6] Circle Section
[7] Cylinder
[8] Cone
[9] Sphere
[10] Triangle
[11] Prism''')
calcOpti = int(input('Choose An Option For The List Above: '))
2020-11-08 19:57:57 +01:00
if calcOpti == 0: # If calcOpti is 0 then quit.
exit()
if calcOpti == 1: # Calculating the area of a square.
2019-12-16 09:14:03 +01:00
print('\nYou have chosen the option: Square')
SideA = float(input('How Wide is side A: '))
SideB = float(input('How Wide is side B: '))
sAxsB = SideA * SideB
2020-11-08 19:57:57 +01:00
print(f'The Square Area is: {sAxsB:.6f}')
2019-12-16 09:14:03 +01:00
2020-11-08 19:57:57 +01:00
if calcOpti == 2: # Calculating the volume of a cube.
2019-12-16 09:14:03 +01:00
print('\nYou have chosen the option: Cube')
SideA = float(input('How Wide is side A: '))
SideB = float(input('How Wide is side B: '))
SideC = float(input('How Wide is side C: '))
sAxsBxsC = SideA * SideB * SideC
2020-11-08 19:57:57 +01:00
print(f'The Cube Volume is: {sAxsBxsC:.6f}')
2019-12-16 09:14:03 +01:00
2020-11-08 19:57:57 +01:00
if calcOpti == 3: # Calculating the volume of a pyramid.
2019-12-16 09:14:03 +01:00
print('\nYou have chosen the option: Pyramid')
SideA = float(input('How Wide is side A: '))
SideB = float(input('How Wide is side B: '))
Height = float(input('How High is it: '))
sAxsBxsH = SideA * SideB * Height / 3
2020-11-08 19:57:57 +01:00
print(f'The Pyramid Volume is: {sAxsBxsH:.6f}')
2019-12-16 09:14:03 +01:00
2020-11-08 19:57:57 +01:00
if calcOpti == 4: # Calculating the area of a circle.
2019-12-16 09:14:03 +01:00
print('\nYou have chosen the option: Circle')
Radius = float(input('How Wide is Radius: '))
preArea = Radius * Radius
2020-11-08 19:57:57 +01:00
prePi = math.pi * preArea
print(f'The Circle Area is: {prePi:.6f}')
2019-12-16 09:14:03 +01:00
2020-11-08 19:57:57 +01:00
if calcOpti == 5: # Calculating the arch length of a circle.
2019-12-16 09:14:03 +01:00
print('\nYou have chosen the option: Arch Length')
Angle = float(input('What is the angle(°): '))
Radius = float(input('What is the Radius: '))
a = Angle
r = Radius
2020-11-08 19:57:57 +01:00
Answer = a / 360 * math.pi * 2 * r
print(f'The arch length is: {Answer:.6f}')
2019-12-16 09:14:03 +01:00
2020-11-08 19:57:57 +01:00
if calcOpti == 6: # Calculating the area of a circle section.
2019-12-16 09:14:03 +01:00
print('\nYou have chosen the option: Circle Section')
Angle = float(input('What is the angle(°): '))
Radius = float(input('What is the Radius: '))
a = Angle
r = Radius
2020-11-08 19:57:57 +01:00
Answer = a / 360 * math.pi * r * r
print(f'The Circle Section area is: {Answer:.6f}')
2019-12-16 09:14:03 +01:00
2020-11-08 19:57:57 +01:00
if calcOpti == 7: # Calculating the volume of a cylinder.
2019-12-16 09:14:03 +01:00
print('\nYou have chosen the option: Cylinder')
Radius = float(input('How Wide is Radius: '))
Height = float(input('How High is it: '))
preArea = Radius * Radius
2020-11-08 19:57:57 +01:00
prePi = math.pi * preArea
2019-12-16 09:14:03 +01:00
preCyl = prePi * Height
2020-11-08 19:57:57 +01:00
print(f'The Cylinder Volume is: {preCyl:.6f}')
2019-12-16 09:14:03 +01:00
2020-11-08 19:57:57 +01:00
if calcOpti == 8: # Calculating the volume of a cone.
2019-12-16 09:14:03 +01:00
print('\nYou have chosen the option: Cone')
Radius = float(input('How Wide is Radius: '))
Height = float(input('How High is it: '))
preArea = Radius * Radius
2020-11-08 19:57:57 +01:00
prePi = math.pi * preArea
2019-12-16 09:14:03 +01:00
preCyl = prePi * Height / 3
2020-11-08 19:57:57 +01:00
print(f'The Cone Volume is: {preCyl:.6f}')
2019-12-16 09:14:03 +01:00
2020-11-08 19:57:57 +01:00
if calcOpti == 9: # Calculating the volume of a sphere.
2019-12-16 09:14:03 +01:00
print('\nYou have chosen the option: Sphere')
Radius = float(input('How Wide is Radius: '))
r = Radius
prePi = r * r * r
2020-11-08 19:57:57 +01:00
pre4 = prePi * math.pi
2019-12-16 09:14:03 +01:00
preD3 = pre4 * 4
Answer = preD3 / 3
2020-11-08 19:57:57 +01:00
print(f'The Sphere Volume is: {Answer:.6f}')
2019-12-16 09:14:03 +01:00
2020-11-08 19:57:57 +01:00
if calcOpti == 10: # Calculating the area of a triangle
2019-12-16 09:14:03 +01:00
print('\nYou have chosen the option: Triangle')
sideA = float(input('How Wide is aide A: '))
sideB = float(input('How Wide is side B: '))
Answer = sideA * sideB / 2
2020-11-08 19:57:57 +01:00
print(f'The Triangle Area is: {Answer:.6f}')
2019-12-16 09:14:03 +01:00
2020-11-08 19:57:57 +01:00
if calcOpti == 11: # Calculating the volume of a prism.
2019-12-16 09:14:03 +01:00
print('\nYou have chosen the option: Prism')
sideA = float(input('How Wide is aide A: '))
sideB = float(input('How Wide is side B: '))
2019-12-16 09:14:03 +01:00
Length = float(input('How long is the Prism: '))
Answer = sideA * sideB / 2 * Length
2020-11-08 19:57:57 +01:00
print(f'The Prism Volume is: {Answer:.6f}')