Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- # Volume of cube given edge length
- # input
- print("Input the edge length: ")
- a = float(input("a = "))
- # Computation of the volume, V = a^3
- # Since no pi is needed, math module is not needed
- V = a ** 3
- # Output of the answer
- print("Output:")
- print(f"The volume of the cube is {round(V, 3)} cu. units.")
- # Volume of Cylinder given a radius and height
- # input
- print("Input the height:")
- h = float(input("h = "))
- print("Input the radius:")
- r = float(input("r = "))
- # Computation of the Volume, V = pi * r^2 * h
- V = math.pi * (r ** 2) * h
- print("Output:")
- print(f"The volume of the cylinder is {round(V, 3)} cu. units.")
- # Volume of Cone given a radius and height
- # input
- print("Input the height:")
- h = float(input("h = "))
- print("Input the radius:")
- r = float(input("r = "))
- # Computation of the Volume, V = 1/3 * pi * r^2 * h
- V = 1/3 * (math.pi * (r ** 2) * h)
- print("Output:")
- print(f"The volume of the cone is {round(V, 3)} cu. units.")
- # Volume of Sphere given a radius
- # input
- print("Input radius:")
- r = float(input("r = "))
- # Computation of the Volume, 4/3 * pi * r^3
- V = 4/3 * (math.pi * r ** 3)
- print("Output:")
- print(f"The volume of the sphere is {round(V, 3)} cu. units.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement