Program Console Vignaankosh.com
Execution Panel
Console is empty.
Number Guessing Game 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.
# Number guessing game with a fixed secret for dry run
secret = 42
attempts = 0
max_attempts = 5
print("=== NUMBER GUESSING GAME ===")
print("Guess a number between 1 and 100")
print(f"You have {max_attempts} attempts")
while attempts < max_attempts:
guess = int(input(f"Attempt {attempts + 1}: "))
attempts += 1
if guess == secret:
print(f"Correct! You guessed {secret} in {attempts} attempts.")
break
elif guess < secret:
print("Too low. Try a higher number.")
else:
print("Too high. Try a lower number.")
if guess != secret:
print(f"Game over. The number was {secret}.")