Learn practical skills, build real-world projects, and advance your career
Created 3 years ago
# Volume Calcuator
import time
print("Hello and welcome to my self created calculator which will calculate volumes for you. ")
time.sleep(2)
Figure = input("What is the 3D object whose volume you want to know? (please enter cube / cuboid / cylinder / sphere / hemisphere): ")
if Figure == "cube":
a = float(input("Side length: "))
volume_of_cube = float(a**3)
print("The volume of the cube = ")
print(float(volume_of_cube))
elif Figure != "cube" and Figure != "cuboid" and Figure != "cylinder" and Figure != "sphere" and Figure != "hemisphere":
print("Restart the code and please type cube / cuboid / cylinder / sphere / hemisphere in lowercase letters! ")
if Figure == "cuboid":
a1 = float(input("Side length 1: "))
a2 = float(input("Side length 2: "))
a3 = float(input("Side length 3: "))
volume_of_cuboid = float(a1*a2*a3)
print("The volume of the cuboid = ")
print(float(volume_of_cuboid))
if Figure == "cylinder":
from math import pi
h = float(input("Enter Height: "))
r = float(input("Enter Radius: "))
volume_of_cylinder = float(pi*r*r*h)
print("The volume of the cylinder = ")
print(float(volume_of_cylinder))
if Figure == "sphere":
from math import pi
r = float(input("Enter Radius: "))
volume_of_sphere = float((4/3) *pi*r*r*r)
print("The volume of the sphere = ")
print(float(volume_of_sphere))
if Figure == "hemisphere":
from math import pi
r = float(input("Enter Radius: "))
volume_of_hemisphere = float((2/3) *pi*r*r*r)
print("The volume of the hemisphere = ")
print(float(volume_of_hemisphere))
# Total Surface Area Calculator
import time
print("Hello and welcome to my self created calculator which will calhttp://localhost:8888/notebooks/Desktop/Jupyter/Volume%20and%20Surface%20Area%20Calculator.ipynbculate surface areas for you. ")
time.sleep(2)
Figure = input("What is the 3D object whose Surface Area you want to know? (please enter cube / cuboid / cylinder / sphere / hemisphere): ")
if Figure == "cube":
a = float(input("Side length: "))
TSA_of_cube = float(6*a*a)
print("The total surface area of the cube = ")
print(float(TSA_of_cube))
elif Figure != "cube" and Figure != "cuboid" and Figure != "cylinder" and Figure != "sphere" and Figure != "hemisphere":
print("Restart the code and please type cube / cuboid / cylinder / sphere / hemisphere in lowercase letters! ")
if Figure == "cuboid":
l = float(input("length: "))
b = float(input("breadth: "))
h = float(input("height: "))
TSA_of_cuboid = float(2*l*b+2*b*h+2*h*l)
print("The total surface area of the cuboid = ")
print(float(TSA_of_cuboid))
if Figure == "cylinder":
from math import pi
h = float(input("Enter Height: "))
r = float(input("Enter Radius: "))
TSA_of_cylinder = float(2*pi*r*h+2*pi*r*r)
print("The total surface area of the cylinder = ")
print(float(TSA_of_cylinder))
if Figure == "sphere":
from math import pi
r = float(input("Enter Radius: "))
TSA_of_sphere = float(4*pi*r*r)
print("The total surface area of the sphere = ")
print(float(TSA_of_sphere))
if Figure == "hemisphere":
from math import pi
r = float(input("Enter Radius: "))
TSA_of_hemisphere = float(3*pi*r*r)
print("The total surface area of the hemisphere = ")
print(float(TSA_of_hemisphere))
# Lateral Surface Area Calculator
import time
print("Hello and welcome to my self created calculator which will calculate surface areas for you. ")
time.sleep(2)
Figure = input("What is the 3D object whose Surface Area you want to know? (please enter cube / cuboid / cylinder / sphere / hemisphere): ")
if Figure == "cube":
a = float(input("Side length: "))
TSA_of_cube = float(4*a*a)
print("The lateral surface area of the cube = ")
print(float(TSA_of_cube))
elif Figure != "cube" and Figure != "cuboid" and Figure != "cylinder" and Figure != "sphere" and Figure != "hemisphere":
print("Restart the code and please type cube / cuboid / cylinder / sphere / hemisphere in lowercase letters! ")
if Figure == "cuboid":
l = float(input("length: "))
b = float(input("breadth: "))
h = float(input("height: "))
TSA_of_cuboid = float(2*(l+b)*h)
print("The lateral surface area of the cuboid = ")
print(float(TSA_of_cuboid))
if Figure == "cylinder":
from math import pi
h = float(input("Enter Height: "))
r = float(input("Enter Radius: "))
TSA_of_cylinder = float(2*pi*r*h+2*pi*r*r)
print("The total surface area of the cylinder = ")
print(float(TSA_of_cylinder))
if Figure == "sphere":
from math import pi
r = float(input("Enter Radius: "))
TSA_of_sphere = float(4*pi*r*r)
print("The total surface area of the sphere = ")
print(float(TSA_of_sphere))
if Figure == "hemisphere":
from math import pi
r = float(input("Enter Radius: "))
TSA_of_hemisphere = float(3*pi*r*r)
print("The total surface area of the hemisphere = ")
print(float(TSA_of_hemisphere))