Print All Even Numbers Between 1 and 100
Print all even numbers from 1 to 100.
BeginnerPhase 2 - Level 1: Basic LoopingExample 2 of 14
print-all-even-numbers-between-1-and-100.py
1# Print even numbers from 1 to 1002for i in range(2, 101, 2):3 print(i)
Output
2 4 6 8 10 ... 100
What's going on
Use range with step size 2 to get even numbers.
Key Concepts:
range(2, 101, 2) starts at 2, goes to 100, steps by 2This gives: 2, 4, 6, 8, ..., 100
All are even numbers
🔗Related Content
- 📖
Phase 2 - Learn Concepts
Review Phase 2 concepts and explanations
- 📝
Phase 2 - Quiz
Test your Phase 2 understanding with quiz questions
- 💻
Phase 2 - All Practice Problems
Explore all practice problems for Phase 2
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum