Back to the Introduction to Computer Science outline The Course Maker
Introduction to Computer Science outline
Week 6 · Module overview

Week 6 — Module Framing · Loops II: `for`, `range` & Nested Loops

Introduction to Computer Science · CSCI 1101 Fall 2026 · Prof. Okafor Fictional sample

Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Module: Week 6 of 16 · Fall 2026 · in-person, two 75-minute coding-along studio sessions
Objective covered: Objective 4 — Write and trace while and for loops, including range() and nested loops. (Week 6 is the for/range/nesting half.)

This file holds two pieces: (A) the Module 6 Overview page ("Start Here") and (B) the Welcome Announcement that drips out when the module opens. Dates below assume a Tuesday/Thursday pattern with Week 6 meeting Tue Oct 6 and Thu Oct 8, a Coding Lab that same week, and end-of-week work due Sunday Oct 11, 11:59 p.m. Adjust the day-of-week and times to match your section.


(A) Module 6 Overview — Start Here

Welcome to Week 6: Loops II — for, range & Nested Loops

This is your home base for the week. Read it first, then work the checklist below from top to bottom. Everything you need is linked inside the module.

Last week you met the while loop — repeat as long as a condition holds. This week we meet the loop you'll reach for most often: the for loop. When you know how many times to repeat — or you want to step through every character in a word, or every number from 1 to 100 — for with range() is the clean tool. We'll also put a loop inside a loop (nested loops) to build grids and tables. The week's single most important fact, and the #1 source of off-by-one bugs in all of programming: range(stop) stops before stop — the stop value is EXCLUSIVE. range(1, 5) gives you 1 2 3 4, not 1 2 3 4 5. We will run that one until nobody forgets it.

The week's big question

"When you know how many times to repeat — how do you say it, and what exactly does range() give you?"

By Friday you'll be able to write a for loop over range(), predict the exact numbers any range(...) call produces (start, stop, step — and the exclusive stop), iterate over a string, accumulate a running total, and trace a nested loop to predict its exact output and how many lines it prints.

By the end of this week, you can…

Use this as a checklist. If you can do all four, you're ready for the quiz.

  • [ ] Write a for loop that repeats a known number of times and one that walks through each character of a string.
  • [ ] Predict range() exactlyrange(stop), range(start, stop), and range(start, stop, step) — and explain why the stop value is excluded (range(1, 5)1 2 3 4).
  • [ ] Accumulate with a for loop — sum the numbers 1 through n, or build up a string, run-verifying the total.
  • [ ] Trace a nested loop — predict its exact output, and count how many lines it prints, knowing the inner loop runs fully for every single step of the outer loop.

What's due this week, and when

Work these in order — each one gets you ready for the next.

# Do this Type Due
1 Read the week's readings + watch the linked videos Read / watch (ungraded prep) Before Thu Oct 8
2 Skim the slides (Deck 6) and the Week 6 lecture outline Prep (ungraded) Alongside class
3 Lecture Tutorial 6 — work through for, range() (and its exclusive stop), and nested loops with one approved chatbot (Gemini, Claude, or ChatGPT), then submit the conversation share link Lecture Tutorial · graded (5% group) Sun Oct 11, 11:59 p.m.
4 Practice exercises — low-stakes reps to lock in the ideas Practice · ungraded Sun Oct 11 (recommended)
5 Coding Lab 6 — "Counting, Ranges & Grids" — write a for/range accumulator and a nested-loop pattern in a free online Python environment, predict-then-run a table of range() calls, fix an off-by-one bug, and visualize a nested loop in Python Tutor — then catch the AI when it includes the stop value Coding Lab · graded (Coding Labs, 15% group) · 50 pts Sun Oct 11, 11:59 p.m.
6 Quiz 6 — covers for/range output, the exclusive stop, step, nested loops, and an off-by-one debug Quiz · graded (Quizzes, 10% group) Sun Oct 11, 11:59 p.m.
7 Discussion 6 — "for vs while: Is One Always Better?" — argue when a for loop is the right tool and when while wins, with concrete examples, and decompose a grid/table into nested loops, in a dialogue with one approved chatbot; then post the AI summary + your chat link and reply to two classmates Discussion · graded (Discussions, 10% group) Initial post Fri Oct 9; replies Sun Oct 11
8 Assignment 6 — "Loops that Count & Build" — write a for/range loop that sums or draws a pattern, predict several range() outputs, trace a nested loop, and fix an off-by-one bug, coached and scored by one approved chatbot Assignment · graded (Assignments, 15% group) · 100 pts Sun Oct 11, 11:59 p.m.

Heads-up on the AI tools: you'll use a chatbot as a pair-programmer to draft and explain — and then you check its work by running the code. Chatbots are famous for one slip in particular this week: they'll write a loop "from 1 to 5" as range(1, 5) (which actually stops at 4), or miscount how many lines a nested loop prints. Catching that — by running the code and reading the real output — is the point, in the tutorial, the assignment, and the lab.

How to succeed this week

  • Run every range(). When you're unsure what numbers a range(...) produces, wrap it: print(list(range(1, 5))) shows you [1, 2, 3, 4] exactly. Never guess the contents of a range — list it.
  • Two tiny hooks to memorize. "range stops before the stop — the last number is one less." And for nesting: "The inner loop runs all the way through, every single time the outer loop takes one step."
  • Off-by-one is the bug of the week. Want 1 through n? That's range(1, n + 1), not range(1, n). The + 1 is doing real work. When a loop is "one short" or "one too many," suspect the stop value first.
  • Trace nested loops on paper, then run them. Write down the outer variable, then list every inner value before the outer moves on. Then run it and check — the count of printed lines is the giveaway.
  • Treat the chatbot as a smart intern, not an oracle. It drafts a loop; you run it and check the exact output and line count. That habit is the whole semester in miniature.

You don't need any setup for this week — the Python environment runs in your browser, nothing to install. Come to class ready to count. See you Tuesday.


(B) Welcome Announcement — Module 6

Release setting: post on the module's start day (offset = 0 days), i.e., Tue Oct 6, 2026 — not before. If your platform won't preserve the scheduled date on import, post this as a draft labeled "Release: Tue Oct 6."

Subject: Week 6 — the for loop, and the one off-by-one that gets everybody 🔁

Hi everyone,

Last week your programs learned to repeat as long as a condition held — the while loop. This week we add the loop you'll write most: the for loop, paired with range() for "do this a known number of times." We'll also nest a loop inside a loop to print grids and times-tables.

This week — Loops II: for, range & Nested Loops — we tackle the big question: When you know how many times to repeat, how do you say it, and what exactly does range() give you? By Friday you'll write for loops, predict any range(...) exactly, sum a series, and trace a nested loop line by line.

One fact to burn in now (it's the #1 off-by-one bug in programming): range(stop) stops before stop. So range(1, 5) gives 1, 2, 3, 4not 1, 2, 3, 4, 5. If you want the 5 included, you write range(1, 6). We'll run this in class until it's reflex.

Three things not to miss:
1. Lecture Tutorial 6 — work through for, range (and its exclusive stop), and nested loops with one approved chatbot (Gemini, Claude, or ChatGPT) and submit the share link. You'll use it as a pair-programmer — and catch its off-by-one. Due Sun Oct 11.
2. Coding Lab 6 ("Counting, Ranges & Grids"), Quiz 6, Discussion 6, and Assignment 6 also close Sun Oct 11 — the lab is where you build an accumulator and a nested-loop grid, so start early.
3. Open the Start Here page first — it lays out everything in order with due dates.

One habit to keep from day one: never trust the contents of a range you didn't list. When in doubt, print(list(range(...))) and read what Python actually produces. The source of truth is always the same — run the code.

Bring your curiosity (and a willingness to be wrong about whether range(1, 5) includes the 5) to class on Tuesday.

See you soon,
Prof. Okafor


~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com