Please enable JavaScript to use CodeHS

Intro to Computer Science in Python 3

Lesson 5.1 While Loops

Description

In this lesson, students learn to use while loops in their Python programs. While loops allow code to be executed repeatedly based on a condition. They are also reminded of the possibility of creating an infinite loop, which occurs if the exit condition of the while loop is never met, causing the code inside the while loop to repeat continuously.


Objective

Students will be able to:

  • Effectively use while loops in their programs
  • Detect and resolve infinite loops