 # Lab Activity 1

May 5th, 2022
637
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import math
2.
3. # Volume of cube given edge length
4. # input
5. print("Input the edge length: ")
6. a = float(input("a = "))
7. # Computation of the volume, V = a^3
8. # Since no pi is needed, math module is not needed
9. V = a ** 3
10. # Output of the answer
11. print("Output:")
12. print(f"The volume of the cube is {round(V, 3)} cu. units.")
13.
14.
15. # Volume of Cylinder given a radius and height
16. # input
17. print("Input the height:")
18. h = float(input("h = "))
20. r = float(input("r = "))
21. # Computation of the Volume, V = pi * r^2 * h
22. V = math.pi * (r ** 2) * h
23. print("Output:")
24. print(f"The volume of the cylinder is {round(V, 3)} cu. units.")
25.
26. # Volume of Cone given a radius and height
27. # input
28. print("Input the height:")
29. h = float(input("h = "))
31. r = float(input("r = "))
32. # Computation of the Volume, V = 1/3 * pi * r^2 * h
33. V = 1/3 * (math.pi * (r ** 2) * h)
34. print("Output:")
35. print(f"The volume of the cone is {round(V, 3)} cu. units.")
36.
37. # Volume of Sphere given a radius
38. # input