5.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
Write a for loop to print all numbers from 1 to 5.
💡 Hint: Use range from 1 to 6 to include 1 to 5.
Create a for loop that prints characters from a string 'hello'.
💡 Hint: You can use the string directly as the sequence.
4 more questions available
Interactive Quizzes
Quick quizzes to reinforce your learning
What is the output of the following code?
💡 Hint: Consider the starting point and how many numbers are produced by range.
True or False: The for loop can iterate only through lists.
💡 Hint: Recall other sequences that can be iterated.
Get performance evaluation
Challenge Problems
Push your limits with advanced challenges
Create a program that uses a for loop to find the factorial of numbers from 1 to 5.
💡 Hint: Remember that factorial is the product of all positive integers up to that number.
Construct a for loop that generates the Fibonacci sequence up to 100.
💡 Hint: Keep track of the last two Fibonacci numbers and update them in each iteration.
Get performance evaluation
Reference links
Supplementary resources to enhance your learning experience.