South Plantation High School logo
South Plantation High School · Procedural Programming with Python

for Loops & range() Practice

range() · looping through strings and lists · the in operator · 20 practice items

Instructions

The information on this page is not stored. If you start an assignment, you must finish it. This page does not save your progress.

Quick review

range()
range(5)          # 0 1 2 3 4
range(1, 6)       # 1 2 3 4 5
range(2, 11, 2)   # 2 4 6 8 10
range(5, 0, -1)   # 5 4 3 2 1
Looping through sequences
for letter in "hey":
    print(letter)
pets = ["dog", "cat"]
for pet in pets:
    print(pet)
The in operator
"a" in "cat"              # True
"kiwi" in ["kiwi", "fig"]  # True
"ki" in ["kiwi", "fig"]    # False
"x" not in "cat"          # True

Error messages you may see in the terminal

How this works

  1. Enter your first name, last name initial, and class period, then click Start Assignment. Your start time is recorded.
  2. The assignment opens in a Python editor with four files (tabs). Each orange numbered box or drop down is one practice item. There are 20 items.
  3. Click ▶ Run on Parts 1 to 3 to see what Python prints. Compare it with the expected output. Run is turned off for Part 4. Run does not grade you, so check your work carefully.
  4. When you finish all four tabs, click Submit for Score. Your end time is recorded and your score appears. Answers cannot be changed after submitting.
PartTaskItemsPoints
1range(): repeat, count up, count by steps, count down, and write a whole for line1 to 55
2Looping through strings and lists, the accumulator, and end=6 to 105
3The in operator: inside a loop, in a list, and fixing in bugs11 to 155
4Predict the output and choose for or while16 to 205
Total (1 point per item)2020

Student Information

Reminder: nothing on this page is saved. Once you click Start Assignment, plan to finish before you leave or refresh the page.