Please enable JavaScript to use CodeHS

AP Computer Science Principles in Python

Lesson 1.10 For Loops

Description

In this lesson, students learn how to use for loops in their programs. The for loop allows you to repeat a specific part of code a fixed number of times.

A for loops is written as follows:

for i in range(4):
    # Code to be repeated 4 times


Objective

Students will be able to:

  • Create for loops to repeat code a fixed number of times
  • Explain when a for loop would be a useful tool
  • Utilize for loops to write programs that would be difficult/impossible without loops