Practice Loops – for and while - 5 | 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 - Loops – for and while

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

Print all numbers from 1 to 10 using a for loop.

💡 Hint: Use range function starting from 1 to 11.

Question 2

Easy

Use a while loop to count down from 5 to 0.

💡 Hint: Start count at 5 and decrement.

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 does the 'break' statement do in a loop?

  • Terminates the loop
  • Skips to the next iteration
  • Acts as a placeholder

💡 Hint: Think about where the loop might stop.

Question 2

True or False: A while loop will always execute at least once.

  • True
  • False

💡 Hint: Consider how a while loop starts.

Solve 3 more questions and get performance evaluation

Challenge Problems

Push your limits with challenges.

Question 1

Create a program using nested loops to output a triangle pattern of numbers (1 on the first line, 2 on the second, etc. up to 5 lines).

💡 Hint: The outer loop controls rows, and the inner loop controls printing spaces.

Question 2

Write a Python program that prompts for a number and calculates its Fibonacci sequence up to that number using a while loop.

💡 Hint: Remember to update your previous numbers in the loop.

Challenge and get performance evaluation