Function to calculate square and cube Dry Run in PYTHON

Function to calculate square and cube is an interactive PYTHON dry run visualizer from the Functions programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Function to calculate square and cube Program Code

def square(n):
    """Return square of a number"""
    return n ** 2

def cube(n):
    """Return cube of a number"""
    return n ** 3

# Test the functions
num = 5
print(f"Number: {num}")
print(f"Square: {square(num)}")
print(f"Cube: {cube(num)}")

View the complete Functions programs page.

Program Console Function to calculate square and cube Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.