Print All Odd Numbers Between 1 and 100
Print all odd numbers from 1 to 100.
BeginnerPhase 2 - Level 1: Basic LoopingExample 5 of 14
print-all-odd-numbers-between-1-and-100.py
1# Print odd numbers from 1 to 1002for i in range(1, 101, 2):3 print(i)
Output
1 3 5 7 9 ... 99
What's going on
Use range with step 2 starting from 1.
Key Concepts:
range(1, 101, 2) gives: 1, 3, 5, 7, ..., 99
Step size 2 skips even numbers
All are odd 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