Calculate sum of even numbers from 1 to n Dry Run in PYTHON

Calculate sum of even numbers from 1 to n is an interactive PYTHON dry run visualizer from the For 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 sum of even numbers from 1 to n Program Code

# Sum of even numbers from 1 to n
n = int(input("Enter a number: "))

sum_even = 0
for i in range(2, n + 1, 2):
    sum_even += i

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

View the complete For programs page.

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