Practice The WHILE Loop - 21.3 | 21. IF, FOR, WHILE | CBSE 9 AI (Artificial Intelligence)
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

The WHILE Loop

21.3 - The WHILE 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

Question 1 Easy

Write a simple WHILE loop that counts down from 5 to 1.

💡 Hint: Use 'i -= 1' to decrement i each iteration.

Question 2 Easy

What happens if you leave the condition always true in a WHILE loop?

💡 Hint: Think about what needs to change to prevent it from running forever.

4 more questions available

Interactive Quizzes

Quick quizzes to reinforce your learning

Question 1

What does a WHILE loop do?

It repeats an action a fixed number of times
It repeats an action as long as a condition is true
It executes code once only

💡 Hint: Think about what defines 'repeating' in programming.

Question 2

True or False: A WHILE loop can run indefinitely.

True
False

💡 Hint: Consider what would make a loop stop executing.

1 more question available

Challenge Problems

Push your limits with advanced challenges

Challenge 1 Hard

Create a WHILE loop that continuously asks the user for their age until a valid age (between 0 and 120) is entered. Display a message about aging based on the input.

💡 Hint: Think about how to validate the input and break the loop upon success.

Challenge 2 Hard

Imagine a game where you are guessing a number. Create a WHILE loop that keeps asking the user to guess a number between 1 to 100 until they guess correctly. Provide hints if they guess too high or too low.

💡 Hint: Consider how you'll guide the user based on their guesses.

Get performance evaluation

Reference links

Supplementary resources to enhance your learning experience.