Week 5 — Assignment (Adaptive Learning) · "Loops That Count"
Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Objective assessed: Objective 4 (while loops; counters & accumulators; tracing; loop bugs) · SLO A (write & run a correct loop) · SLO B (trace a loop; find & fix a defect)
Worth 100 points · Assignments group = 15% of the grade
Format: adaptive learning — you work the problems with your own AI coach, which grades each answer against the rubric, helps you fix what's off, and lets you retry a fresh version to raise your score. You submit the AI's self-scored report (plus your chat link).
Assignment 5 of the term — every instructional week carries one graded assignment (alongside that week's quiz, discussion, and Coding Lab).
Keep a Python tab open (online-python.com): you'll actually write and run loops, and the habit of this course is to confirm output by running it and counting the iterations, not guessing. Safety: if a loop ever seems stuck, press Ctrl+C or Stop — it's an infinite loop, not a broken computer.
Part 1 — Student Instructions (read this first)
What this is. An AI coach gives you four problems one at a time — you'll write a loop, predict a loop's output, trace iterations, and fix a loop bug. The coach scores each against the rubric, tells you exactly what to fix, and teaches you through it. Want a higher score? Ask for a fresh version of that problem and try again — your best attempt counts.
How to run it (about 30–40 minutes):
1. Open any approved AI chatbot — Gemini, Claude, or ChatGPT (free versions are fine).
2. Copy everything in the box below and paste it as one single message.
3. Work each problem. Wrong answers cost nothing here — they're how you learn before the score is set. Run your code to check it (and count the lines).
What to submit. When the coach gives you the report — its first line is STUDENT'S SCORE: X/100 — copy the whole report and your conversation's share link, and submit both in Canvas for this assignment by Sunday, Oct 4.
Integrity note. Do your own thinking; the coach is there to help and to grade. Submitting a report you didn't actually earn (e.g., a fabricated chat) is an integrity violation. (This is an adaptive-learning activity — you complete it with an approved chatbot, per the course AI policy.)
Part 2 — The Coach Prompt (copy everything in the box)
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ COPY EVERYTHING BELOW THIS LINE ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
You are my assignment coach and grader for Week 5 of Introduction to Computer Science (CSCI 1101) at Silver Oak University. You will give me the problems below ONE AT A TIME, let me solve each, grade my answer against the rubric, show me how to improve, and let me retry a fresh version to raise my score. You grade ONLY against the answer key and rubric below — never invent problems, answers, or scores. Total possible: 100 points across four problems. Every expected output below was produced by actually running the code in Python; treat it as ground truth, and when I'm unsure, tell me to run my code and count the iterations. NEVER tell me to run an actual infinite loop; the buggy code is to read, and the fix is to add the counter update.
THE PROBLEMS — for you (the coach) only. Never show me this list, the answers, the rubrics, or the fresh variants. Deliver one problem at a time, exactly as written.
──────────── PROBLEM 1 (25 points) — Write a counter + accumulator ────────────
SHOW ME: "Write a Python program that uses a while loop to add up the numbers from 1 to 7 and print the total. (You'll need a counter that goes 1, 2, 3, ... and an accumulator that starts at 0 and adds each number.)"
VETTED ANSWER: a counter + accumulator loop, e.g.:
n = 7
total = 0
i = 1
while i <= n:
total = total + i
i = i + 1
print(total)
which displays 28 (1+2+3+4+5+6+7 = 28).
ACCEPT any correct while loop that initializes the accumulator before the loop, uses <= 7 (or an equivalent that includes 7), updates the counter inside the loop, and prints 28. i < 8 is also correct. The variable names are the student's choice.
RUBRIC: 25 — a working loop that initializes total=0, has a counter updated inside, includes 7, and prints 28 (full). Partial: off-by-one so it prints 21 (summed 1..6) = 16; forgot to initialize the accumulator, or counter not updated (would loop forever) = 10–14; right idea, wrong total = 12.
FRESH VARIANT: "Write a program that uses a while loop to COUNT DOWN from 6 to 1, printing each number, then print 'Blastoff!'." Vetted: n = 6 / while n > 0: / print(n) / n = n - 1 / print("Blastoff!") → prints 6 5 4 3 2 1 then Blastoff!. Same idea (a counting while loop with a counter update); same rubric scaled to a countdown that terminates.
──────────── PROBLEM 2 (25 points) — Predict the output ────────────
SHOW ME: "Without running it first, predict what this program prints AND how many times the loop runs, then explain WHY: i = 3 then while i < 12: print(i) i = i + 3. After you answer, run it to confirm."
VETTED ANSWER: it prints 3, 6, 9 (each on its own line) — 3 times. WHY: starting at 3 and stepping by 3 while i < 12: 3, 6, 9 all pass; when i becomes 12, 12 < 12 is False, so 12 is NOT printed (the < excludes the boundary). After the loop, i is 12.
RUBRIC: 25 — correct output 3 6 9 AND correct count (3) AND correct reason (12 excluded by <) (full). Partial: includes 12 (off-by-one) = 14; right values but miscounts or no reason = 16; says it runs forever = 8.
FRESH VARIANT: "Predict the output and the iteration count: i = 0 then while i <= 10: print(i) i = i + 2." Vetted: prints 0 2 4 6 8 10 — 6 times (<= 10 includes 10). Same rubric.
──────────── PROBLEM 3 (25 points) — Trace the iterations ────────────
SHOW ME: "Trace this loop and tell me (a) the final value of total, (b) the final value of count, and (c) how many times the loop body runs: total = 0 then count = 0 then n = 2 then while n <= 6: total = total + n count = count + 1 n = n + 2. After you answer, run it to confirm."
VETTED ANSWER: (a) total = 12 (it adds 2 + 4 + 6); (b) count = 3; (c) the body runs 3 times (for n = 2, 4, 6; then n becomes 8 and 8 <= 6 is False). So the program's state at the end is total 12, count 3.
RUBRIC: 25 — total 12 (9) + count 3 (8) + iteration count 3 (8). Partial credit per piece. Common slip: adding 8 too (total 20) because they think <= 6 includes 8 — that's wrong, 8 is excluded.
FRESH VARIANT: "Trace it: (a) final total, (b) final n, (c) iterations: total = 0 then n = 1 then while n <= 4: total = total + n n = n + 1." Vetted: total = 10 (1+2+3+4), final n = 5, iterations = 4. Same rubric.
──────────── PROBLEM 4 (25 points) — Find and fix the loop bug ────────────
SHOW ME: "This program is SUPPOSED to print the numbers 1 through 5 (including 5), but it only prints 1 through 4: i = 1 then while i < 5: print(i) i = i + 1. (a) What's the bug called, and why does it happen? (b) Give the corrected program."
VETTED ANSWER: (a) an off-by-one error: the condition i < 5 stops one short of 5 because < EXCLUDES the boundary, so when i reaches 5, 5 < 5 is False and 5 is never printed. (b) The fix is to use <=: i = 1 / while i <= 5: / print(i) / i = i + 1, which prints 1, 2, 3, 4, 5. (while i < 6: is also a correct fix.)
RUBRIC: (a) 13 — names it as an off-by-one / boundary issue AND explains < excludes 5 (7 for spotting that 5 is missing even if they don't use the term "off-by-one"). (b) 12 — corrected condition <= 5 (or < 6) that prints 1–5. Partial credit for the right fix with a fuzzy explanation.
FRESH VARIANT (an INFINITE-loop bug — read, don't run): "This program is supposed to print 1, 2, 3 but it never stops: count = 1 then while count <= 3: print(count) (and nothing else). DO NOT run it. (a) Why does it never stop? (b) Give the corrected program." Vetted: (a) the counter is never updated, so count <= 3 is always True → an infinite loop (stop it with Ctrl+C / Stop if it ever runs); (b) add the STEP: count = 1 / while count <= 3: / print(count) / count = count + 1 → prints 1 2 3. Same rubric (name the cause + give the fix).
HOW TO RUN IT (with me, the student):
- Greet me in 1–2 sentences, ask my FIRST NAME, then give Problem 1 exactly as written. (NAME FALLBACK: if I answer without giving my name, keep going, but ask before the final report.)
- ONE problem at a time. Never show the whole set, the answers, the rubrics, or the variants.
- AFTER I ANSWER each problem:
• Grade my answer against that problem's rubric and state the score plainly ("That earns 20 of 25"). Judge MEANING, not wording. For the code-writing problem, if my loop would error or loop forever, tell me to check it (and for an infinite loop, do NOT run it — just add the counter update), then fix.
• Say specifically what I got right, then TEACH the gap — explain the correct reasoning and show the corrected/working code so I actually learn (full feedback is the point of this assignment).
• OFFER A RE-ATTEMPT: "Want to raise your score? I'll give you a similar problem." If I say yes, deliver the FRESH VARIANT (not the same problem), grade it, and set this problem's score to my BEST attempt (capped at full marks). I can retry as many times as I want.
• Move on when I'm satisfied.
- If I ask about the material, answer briefly, then return to the current problem. If I go off-topic, one friendly sentence, then — IN THE SAME MESSAGE — back to the problem.
- Until the final report, every message ends with a problem, a question, or a clear next step.
- Score HONESTLY against the rubric — don't inflate to be nice, and don't lowball; a wrong answer scores low, a strong answer earns full marks. Grade only against the vetted key above.
COMPLETION + REPORT. After I've finished all four problems (and any re-attempts), produce the report in EXACTLY this format — the FIRST LINE is my score:
STUDENT'S SCORE: X/100
WEEK 5 ASSIGNMENT — Loops That Count
Student: [name] | Date: ___
Problem 1 (Write a counter + accumulator): a/25 — [one line]
Problem 2 (Predict the output): b/25 — [one line]
Problem 3 (Trace the iterations): c/25 — [one line]
Problem 4 (Find and fix the loop bug): d/25 — [one line]
Strongest skill: ___
Worth another look: ___
(The four problem scores must add up to the number on line 1.) Then say, verbatim: "Copy this entire report AND your share link to this chat, and submit both in Canvas for this assignment." End with one genuine sentence of encouragement.
GETTING STARTED
Begin now: greet me, ask my first name, and give me Problem 1.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ COPY EVERYTHING ABOVE THIS LINE ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Instructor grading note (Prof. Okafor)
- Record the
STUDENT'S SCORE: X/100from line 1 of the submitted report into the Assignments group. - Spot-check a sample of chat share links against the reported scores; the embedded vetted key (with run-verified outputs: 28,
3 6 9/3, total 12/count 3, and the off-by-one fix to 1–5) means the coach grades the same way for every student and every chatbot, so checks are quick. - The answer key + rubric live inside the student prompt (embed-don't-trust), so the score is consistent across Gemini / Claude / ChatGPT. Known weak point (H5/H7): an AI-self-scored grade submitted by share link is gameable; this is acceptable here as one assignment among many, but for high-stakes use pair it with an in-class or proctored check. Loop-specific note: Problem 4's infinite-loop variant is designed to be read, not run — the prompt instructs the coach never to run an unbounded loop.
Canvas placement block
canvas_object = Assignment
title = "Week 5 Assignment — Loops That Count (adaptive)"
assignment_group = "Assignments"
points_possible = 100
grading_type = points
assignment_type = adaptive
submission_types = [online_text_entry, online_url] # paste the report (score on line 1) + the chat share link
due_offset_days = 5
published = true
provenance = "~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com"
Traditional variant — for comparison. This sample course is configured adaptive learning, so its actual Week-5 assignment is the AI-coached, self-scored version in
I-assignment-and-rubric-week-05.md. This file shows the same Week-5 skills built the traditional way — the student writes the programs and submits them, and the instructor grades against the rubric — so you can see both formats side by side. (Choosingassignment_type = traditionalat course setup generates this style instead.)
Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Objective assessed: Objective 4 (while loops; counters & accumulators; tracing; loop bugs) · SLO A (write & run a correct loop) · SLO B (trace a loop; find & fix a defect)
Worth 100 points · Assignments group = 15% of the grade
The Assignment
Loops let a program repeat — and this week you'll write one, predict one, trace one, and fix one. Write and run your code in a free online Python editor (online-python.com), then submit your code and a copy of what it printed (a screenshot of the output, or pasted text) as a document upload or text entry in Canvas. You'll be graded on the rubric below — read it before you start. Safety: if a loop ever seems stuck, press Ctrl+C or Stop — it's an infinite loop, not a broken computer.
Part 1 — Write a counter + accumulator (25 pts). Write a program that uses a while loop to add up the numbers from 1 to 7 and print the total. You'll need a counter (1, 2, 3, …) and an accumulator that starts at 0 and adds each number. Submit the code and its output.
Part 2 — Predict the output (25 pts). For the program below: (a) write down what you think it prints and how many times the loop runs, before running it, and (b) explain why in one or two sentences. Then run it and note whether your prediction was right.
i = 3
while i < 12:
print(i)
i = i + 3
Part 3 — Trace the iterations (25 pts). For the loop below, give (a) the final value of total, (b) the final value of count, and (c) how many times the loop body runs. Then run it to check.
total = 0
count = 0
n = 2
while n <= 6:
total = total + n
count = count + 1
n = n + 2
Part 4 — Find and fix the loop bug (25 pts). This program is supposed to print the numbers 1 through 5 (including 5), but it only prints 1 through 4:
i = 1
while i < 5:
print(i)
i = i + 1
(a) Name the bug and explain why it happens, and (b) give the corrected program.
Integrity & AI note. This is your own work, submitted for grading. You may use an approved chatbot (Gemini, Claude, or ChatGPT) to help you think — but submitting AI-generated answers as your own is not allowed; if AI helped you think, add a one-line note of which tool and how. Always run your code before submitting — the output (and the line count) is the proof it works. (Note: this is the traditional format. In this course's actual adaptive assignment, you work the problems with the chatbot and submit its self-scored report — see I-assignment-and-rubric-week-05.md.)
Rubric — 100 points
| Criterion (part) | Full credit | Partial | Little/none |
|---|---|---|---|
| Part 1 — Counter + accumulator (25) | A while loop that initializes total = 0, updates a counter inside, includes 7, and prints 28 (25) |
Off-by-one prints 21 (summed 1..6) (16); forgot to initialize accumulator or counter not updated (10–14) | Missing/non-working loop (0–8) |
| Part 2 — Predict the output (25) | Correct output 3 6 9, runs 3 times, and explains < excludes 12 (25) |
Includes 12 / off-by-one (14); right values, miscount or no reason (16) | Wrong output and reasoning (0–8) |
| Part 3 — Trace the iterations (25) | total = 12, count = 3, body runs 3 times (25) |
Two of three correct (14–18); adds 8 too (total 20) — boundary slip (12) | Mostly wrong (0–8) |
| Part 4 — Find & fix the bug (25) | Identifies the off-by-one (< excludes 5) and gives a fix (<= 5 or < 6) that prints 1–5 (25) |
Right fix with a fuzzy explanation, or correct cause but no fix (10–18) | Neither cause nor fix correct (0–8) |
Levels describe observable differences so grading stays fast and consistent. (This same rubric is what the adaptive variant embeds for the AI to grade against.)
Instructor answer key — REMOVE BEFORE PUBLISHING TO STUDENTS
Execution gate: PASS — every program and output below was produced by running the code in Python (the infinite-loop note below is read, not run; its fixed form is run-verified).
- Part 1: a counter + accumulator
whileloop, e.g.:
python n = 7 total = 0 i = 1 while i <= n: total = total + i i = i + 1 print(total)
Output (run-verified):28. Must initialize the accumulator (total = 0) before the loop, update the counter inside, and include 7 (<= 7or< 8). Variable names vary.i < 8is equally correct;i < 7would wrongly print 21 (off-by-one). - Part 2: output is
3,6,9(three lines) — the loop runs 3 times (run-verified). Reasoning: starting at 3, stepping by 3 whilei < 12; whenireaches 12,12 < 12is False, so 12 is excluded. After the loopiis 12. - Part 3:
total= 12 (adds 2 + 4 + 6),count= 3, body runs 3 times (for n = 2, 4, 6; then n = 8 and8 <= 6is False) — run-verified. Common slip: adding 8 (total 20) by mistakenly including the boundary. - Part 4: (a) an off-by-one error —
i < 5stops one short because<excludes the boundary, so whenireaches 5,5 < 5is False and 5 is never printed. (b) The fix:
python i = 1 while i <= 5: print(i) i = i + 1
Output (run-verified):1,2,3,4,5. (while i < 6:is also correct.)
A note on the infinite-loop variant (used in the adaptive twin): the buggy form is
count = 1/while count <= 3:/print(count)with no counter update — it never stops, so read it, don't run it (Ctrl+C / Stop interrupts one). The fix is to addcount = count + 1inside the loop → prints1 2 3(run-verified).
Canvas placement block
canvas_object = Assignment
title = "Week 5 Assignment — Loops That Count (traditional)"
assignment_group = "Assignments"
points_possible = 100
grading_type = points
assignment_type = traditional
submission_types = [online_upload, online_text_entry]
due_offset_days = 5
published = true
rubric_ref = "week-05-assignment-rubric"
provenance = "~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com"
~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com