Program Console Vignaankosh.com
Execution Panel
Console is empty.
Protect a budget using break 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.
# Stop adding expenses before the budget is exceeded
expenses = [120, 180, 250, 90]
budget = 400
total = 0
i = 0
while i < len(expenses):
expense = expenses[i]
if total + expense > budget:
print(f"Cannot add {expense}: budget would be exceeded")
break
total += expense
print(f"Added {expense}, total = {total}")
i += 1
print(f"Final spending = {total}")