Practice The for Loop - 5.2 | Loops – for and while | Python Programming Language
K12 Students

Academics

AI-Powered learning for Grades 8–12, aligned with major Indian and international curricula.

Academics
Professionals

Professional Courses

Industry-relevant training in Business, Technology, and Design to help professionals and graduates upskill for real-world careers.

Professional Courses
Games

Interactive Games

Fun, engaging games to boost memory, math fluency, typing speed, and English skills—perfect for learners of all ages.

games

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.

Learning

Practice Questions

Test your understanding with targeted questions related to the topic.

Question 1

Easy

Write a for loop to print all numbers from 1 to 5.

💡 Hint: Use range from 1 to 6 to include 1 to 5.

Question 2

Easy

Create a for loop that prints characters from a string 'hello'.

💡 Hint: You can use the string directly as the sequence.

Practice 4 more questions and get performance evaluation

Interactive Quizzes

Engage in quick quizzes to reinforce what you've learned and check your comprehension.

Question 1

What is the output of the following code?

Code Editor - python
  • 0
  • 1
  • 2
  • 0
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

💡 Hint: Consider the starting point and how many numbers are produced by range.

Question 2

True or False: The for loop can iterate only through lists.

  • True
  • False

💡 Hint: Recall other sequences that can be iterated.

Solve and get performance evaluation

Challenge Problems

Push your limits with challenges.

Question 1

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.

Question 2

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.

Challenge and get performance evaluation