Practice Loops – for and while - 5 | Loops – for and while | Python Programming Language
Students

Academic Programs

AI-powered learning for grades 8-12, aligned with major curricula

Professional

Professional Courses

Industry-relevant training in Business, Technology, and Design

Games

Interactive Games

Fun games to boost memory, math, typing, and English skills

Loops – for and while

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

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.

4 more questions available

Interactive Quizzes

Quick quizzes to reinforce your learning

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.

3 more questions available

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

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.

Challenge 2 Hard

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.

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.