Calculate power of number (without ** operator) Dry Run in PYTHON

Calculate power of number (without ** operator) is an interactive PYTHON dry run visualizer from the While 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.

Calculate power of number (without ** operator) Program Code

# Calculate power using loop (without ** operator)
base = float(input("Enter base: "))
exponent = int(input("Enter exponent: "))
result = 1
i = 0

if exponent >= 0:
    while i < exponent:
        result *= base
        i += 1
else:
    while i > exponent:
        result /= base
        i -= 1

print(f"{base} raised to power {exponent} = {result}")

View the complete While programs page.

Program Console Calculate power of number (without ** operator) Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.