Practice The WHILE Loop - 21.3 | 21. IF, FOR, WHILE | CBSE Class 9 AI (Artificial Intelligence)
K12 Students

Academics

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

Professionals

Professional Courses

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

Games

Interactive Games

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

Practice Questions

Test your understanding with targeted questions related to the topic.

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.

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 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.

Solve 1 more question and get performance evaluation

Challenge Problems

Push your limits with challenges.

Question 1

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.

Question 2

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.

Challenge and get performance evaluation