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.
Practice Questions
Test your understanding with targeted questions
Write a simple WHILE loop that counts down from 5 to 1.
💡 Hint: Use 'i -= 1' to decrement i each iteration.
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
What does a WHILE loop do?
💡 Hint: Think about what defines 'repeating' in programming.
True or False: A WHILE loop can run indefinitely.
💡 Hint: Consider what would make a loop stop executing.
1 more question available
Challenge Problems
Push your limits with advanced challenges
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.
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.