Lesson 8
Loops - Repeating Code
Learn to repeat actions efficiently
1While Loops✨
💻 code
count = 0
while count < 5:
print(count)
count = count + 1 # 0, 1, 2, 3, 42For Loops🎯
💻 code
for i in range(5):
print(i) # 0, 1, 2, 3, 43range() Function💡
💻 code
range(5) → 0, 1, 2, 3, 4
range(1, 6) → 1, 2, 3, 4, 5
range(0, 10, 2) → 0, 2, 4, 6, 84Loop Examples🚀
💻 code
# Print multiplication table
num = 5
for i in range(1, 11):
print(f"{num} × {i} = {num * i}")💻 code
# Repeat until correct
password = "secret"
while True:
guess = input("Password: ")
if guess == password:
print("Correct!")
break # Exit loop5Break & Continue🔍
💻 code
break → exits loop completely
continue → skip to next iteration🎯 Practice Challenges
Master Loops - Repeating Code by completing all 3 difficulty levels
🟢 EASY
Loops - Repeating Code - Easy Challenge
Start with the basics. Perfect for beginners!
🟡 MEDIUM
Loops - Repeating Code - Medium Challenge
Get more challenging. Build your confidence!
🔴 HARD
Loops - Repeating Code - Hard Challenge
Master this concept. Prove your skills!
🏆 Study a lesson for 2+ minutes to earn +10 TalentJR Points a day. Badges, certificates & prizes →
Ready to Master Loops - Repeating Code? 🚀
Complete the challenges, take the quiz and keep your learning streak going!
Keep learning
- ← Previous lessonLesson 7: If Statements & DecisionsMake programs that make decisions
- Next lesson →Lesson 9: Combining ConditionsUse multiple conditions in decisions
- Grade 6 coursePython Control FlowPython coding course for kids.
- Student ToolsFree calculators for studentsPercentage, fraction, ratio and marks calculators with steps.
- CBSEClass 5 CBSE & NCERT study materialMaths, Science and Computer chapters with solutions.
- Future SkillsExplore future skillsAI, robotics and new-age skills explained for students.