21.2 - The FOR Loop
Enroll to start learning
You’ve not yet enrolled in this course. Please enroll for free to listen to audio lessons, classroom podcasts and take practice test.
Practice Questions
Test your understanding with targeted questions
What will the following code output? for i in range(0, 3): print(i)
💡 Hint: Count from the start value up to but not including the stop value.
Write a FOR loop to print 'Hello' 5 times.
💡 Hint: How many times do you want to print the message?
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What does the range function in a FOR loop do?
💡 Hint: Think about what aspect of iteration the range function influences.
True or False: A FOR loop can be used to iterate through a list.
💡 Hint: Consider the flexibility of FOR loops.
2 more questions available
Challenge Problems
Push your limits with advanced challenges
Write a FOR loop that prints numbers from 20 to 0, decrementing by 2 each time.
💡 Hint: Remember how the step value adjusts the direction and increment.
Consider a scenario where you have a list of student scores. Write a FOR loop to print a message for each score, indicating if it is a pass (>= 50) or a fail (< 50).
💡 Hint: You're checking a condition for each score; think about how if-else statements work.
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.