Sum of even numbers from 1 to N Dry Run in PYTHON

Sum of even numbers from 1 to N 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.

Sum of even numbers from 1 to N Program Code

# Sum of even numbers from 1 to N
n = int(input("Enter N: "))
sum_even = 0
i = 2

while i <= n:
    sum_even += i
    i += 2

print(f"Sum of even numbers up to {n} = {sum_even}")

View the complete While programs page.

Program Console Sum of even numbers from 1 to N Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.