Lesson 4
For Loops
Iterate over sequences
1What is a For Loop?✨
A for loop is a way to repeat actions in Python! It lets you run a block of code multiple times, which is super useful when you want to work with lists or ranges of numbers.
2Why Use For Loops?🎯
- ✓ Save time by automating repetitive tasks
- ✓ Easily go through items in a list
- ✓ Make your programs more efficient
- ✓ Improve your problem-solving skills
3Basic Structure of a For Loop💡
Here’s how a simple for loop works:
for number in range(5):
print(number)This will print numbers from 0 to 4, one on each line!
4Looping Through a List🚀
You can also use for loops to go through items in a list:
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print(fruit)This code will print each fruit in the list!
5Counting with For Loops🔍
You can use for loops to count or sum up numbers. Check this out:
total = 0
for number in range(1, 6):
total += number
print("Total:", total)This adds numbers from 1 to 5 and shows the total!
6Creating a Simple Countdown⭐
You can even create fun programs like a countdown:
for count in range(10, 0, -1):
print(count)
print("Blast off!")7This will count down from 10 to 1, and then say "Blast off!"🧩
🎯 Practice Challenges
Master For Loops by completing all 3 difficulty levels
For Loops - Easy Challenge
Start with the basics. Perfect for beginners!
For Loops - Medium Challenge
Get more challenging. Build your confidence!
For Loops - 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 For Loops? 🚀
Complete the challenges, take the quiz and keep your learning streak going!
Keep learning
- ← Previous lessonLesson 3: While LoopsRepeat until condition is met
- Next lesson →Lesson 5: Nested LoopsLoops within loops
- Grade 7 coursePython Functions & DataPython coding course for kids.
- Student ToolsFree calculators for studentsPercentage, fraction, ratio and marks calculators with steps.
- CBSEClass 6 CBSE & NCERT study materialMaths, Science and Computer chapters with solutions.
- Future SkillsExplore future skillsAI, robotics and new-age skills explained for students.