In this activity, we will use user-defined functions to calculate the properties of a cube — its volume, surface area, and the length of its face diagonal. This is a great example of how functions make code clean and reusable.

Cube Property Formulas
Writing the Script
import math # Function to calculate volume def cube_volume(side): return side ** 3 # Function to calculate surface area def cube_surface_area(side): return 6 * side ** 2 # Function to calculate face diagonal def cube_face_diagonal(side): return side * math.sqrt(2) # Main program side = float(input("Enter the side length of the cube: ")) volume = cube_volume(side) surface_area = cube_surface_area(side) diagonal = cube_face_diagonal(side) print("Volume: " + str(volume)) print("Surface Area: " + str(surface_area)) print("Face Diagonal: " + str(round(diagonal, 2)))
Testing the Program
- Run with side = 4 → Volume: 64.0, Surface Area: 96.0, Face Diagonal: 5.66
- Run with side = 3 → Volume: 27.0, Surface Area: 54.0, Face Diagonal: 4.24


.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)
.webp&w=3840&q=75)