Week 7 — Assignment (Adaptive Learning) · "Write, Return, Trace, Fix"
Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Objective assessed: Objective 5 (functions: def, parameters & arguments, return, return vs. print/None, scope) · SLO A (write & run a correct program) · SLO B (trace a call; 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 7 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 code, and the habit of this course is to confirm output by running it — define the function, call it, and print the call.
Midterm tie-in: functions are the last topic on the Week 8 Midterm (cumulative, Weeks 1–7). This assignment is targeted midterm practice.
Part 1 — Student Instructions (read this first)
What this is. An AI coach gives you four problems one at a time — you'll write functions, predict output (including a None case), trace scope, and fix a 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.
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 18.
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 7 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 define the function, call it, and print the call.
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 two functions with parameters and return ────────────
SHOW ME: "Write TWO functions. (a) max_of_two(a, b) that returns the larger of its two arguments. (b) area(w, h) that returns the area of a rectangle (width times height). Then show a call of each: print max_of_two(7, 3) and print area(6, 4)."
VETTED ANSWER:
def max_of_two(a, b):
if a > b:
return a
else:
return b
def area(w, h):
return w * h
print(max_of_two(7, 3)) → 7
print(area(6, 4)) → 24
(Either an if/else or return a if a > b else b is fine for max; what matters is it RETURNS the larger value, not prints it, and area RETURNS wh. max_of_two(2, 9) must give 9.)
RUBRIC: 25 — both functions defined with the right parameters and a return that produces the correct value, with a working call of each (full). Partial: one function correct (12–13); a function that PRINTS the answer instead of returning it, or correct logic with a small slip (8–18). If max only handles one case or returns nothing, low partial.
FRESH VARIANT: "Write two functions: (a) min_of_two(a, b) returns the smaller of two arguments; (b) perimeter(w, h) returns 2(w+h). Print min_of_two(8, 2) (→ 2) and perimeter(5, 3) (→ 16)." Same rubric.
──────────── PROBLEM 2 (25 points) — Predict the output (incl. a None case) ────────────
SHOW ME: "Without running it first, predict EXACTLY what this program prints, then explain WHY. After you answer, run it to confirm.
def greet(name):
print('Hi,', name)
x = greet('Sam')
print(x)"
VETTED ANSWER: it prints two lines —
Hi, Sam
None
WHY: the call greet('Sam') runs the body and PRINTS Hi, Sam, but greet has no return, so it hands back None; x is None, and print(x) shows None. (print shows a value to a human; return hands a value back. A no-return function returns None.)
RUBRIC: 25 — both lines correct (Hi, Sam then None) (15) + correct return-vs-print/None reasoning (10). Partial: gets Hi, Sam but misses or mis-explains the None (13); says it errors or returns the printed text = low; after running, a correct re-explanation earns back the reasoning points.
FRESH VARIANT: "Predict and explain:
def show(n):
print(n * 2)
y = show(4)
print(y)"
Answer: 8 then None (show prints 8, returns None, y is None). Same rubric.
──────────── PROBLEM 3 (25 points) — Trace the scope ────────────
SHOW ME: "Predict EXACTLY what this program prints, and explain what's happening with the variable total. Then run it.
total = 0
def add_tip(amount):
total = amount + 5
return total
print(add_tip(20))
print(total)"
VETTED ANSWER: it prints two lines —
25
0
WHY: inside add_tip, total = amount + 5 creates a NEW LOCAL total (= 25), which is returned — so the first print shows 25. But that assignment did NOT change the outer (global) total; it's still 0, so the second print shows 0. (Assignment inside a function makes a local; to change the outer value you'd reassign it from the return, e.g. total = add_tip(20).)
RUBRIC: 25 — both lines correct (25 then 0) (15) + correct scope reasoning (local vs. global; the inner assignment doesn't change the outer) (10). Partial: says the second line is 25 (the classic scope error) but explains correctly after running (13); right numbers, weak reason (16).
FRESH VARIANT: "Predict and explain:
points = 100
def bonus(p):
points = p + 10
return points
print(bonus(5))
print(points)"
Answer: 15 then 100 (local points is 15 and returned; global points unchanged at 100). Same rubric.
──────────── PROBLEM 4 (25 points) — Find and fix the bug ────────────
SHOW ME: "This function is supposed to convert Fahrenheit to Celsius and give the number back, but print(to_celsius(212)) shows None:
def to_celsius(f):
c = (f - 32) * 5 / 9
print(to_celsius(212))
Tell me (a) why it prints None, and (b) the corrected program and what it then prints."
VETTED ANSWER: (a) the function computes c but never returns it — there's no return — so the call hands back None, and print shows None. (Also, c is local, so you can't reach it from outside either.) (b) the fix is to add return c:
def to_celsius(f):
c = (f - 32) * 5 / 9
return c
print(to_celsius(212)) → 100.0
(212°F is 100°C; it's 100.0, a float, because / always returns a float — Week 2.)
RUBRIC: (a) 13 — identifies the missing return as the cause of the None (full); naming "it doesn't return" even loosely earns most of it. (b) 12 — adds return c (or return (f - 32) * 5 / 9) AND gives the output 100.0. Partial credit for the right fix but wrong/forgotten output, or the output without the fix.
FRESH VARIANT: "This crashes the result to None: def box_volume(l, w, h): / v = l * w * h / print(box_volume(2, 3, 4)). Why None, and what's the fix and its output?" Answer: no return, so it returns None; fix return v → 24. Same rubric.
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 code would error or PRINTS instead of returns, tell me to RUN it (define, call, print the call), read what comes back, and 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 7 ASSIGNMENT — Write, Return, Trace, Fix
Student: [name] | Date: ___
Problem 1 (Write two functions): a/25 — [one line]
Problem 2 (Predict the output / None): b/25 — [one line]
Problem 3 (Trace the scope): c/25 — [one line]
Problem 4 (Find and fix the 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:
7/24;Hi, Sam/None;25/0;100.0) means the coach grades the same way for every student and every chatbot, so checks are quick. Execution gate: PASS — every keyed output here was produced by running the code in Python. - 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.
Canvas placement block
canvas_object = Assignment
title = "Week 7 Assignment — Write, Return, Trace, Fix (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 = 6
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-7 assignment is the AI-coached, self-scored version in
I-assignment-and-rubric-week-07.md. This file shows the same Week-7 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 5 (functions: def, parameters & arguments, return, return vs. print/None, scope) · SLO A (write & run a correct program) · SLO B (trace a call; find & fix a defect)
Worth 100 points · Assignments group = 15% of the grade
The Assignment
This week is functions — defining them, returning values, and reasoning about scope. In four short parts you'll write two functions, predict an output (including a None case), trace scope, and fix a bug. 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. (Functions are the last topic on the Week 8 Midterm, so this is good midterm practice.)
Part 1 — Write two functions (25 pts). Write (a) max_of_two(a, b) that returns the larger of its two arguments, and (b) area(w, h) that returns width times height. Show a call of each: print(max_of_two(7, 3)) and print(area(6, 4)). (Your functions must return the value, not print it.) Submit the code and its output.
Part 2 — Predict the output (25 pts). For this program, (a) write down EXACTLY what it prints before running it, and (b) explain why in one or two sentences. Then run it and note whether your prediction was right.
def greet(name):
print("Hi,", name)
x = greet("Sam")
print(x)
Part 3 — Trace the scope (25 pts). For this program, (a) predict EXACTLY what it prints, and (b) explain what's happening with the variable total (why each line prints what it does). Then run it to check.
total = 0
def add_tip(amount):
total = amount + 5
return total
print(add_tip(20))
print(total)
Part 4 — Find and fix the bug (25 pts). This function is supposed to convert Fahrenheit to Celsius and give the number back, but print(to_celsius(212)) shows None:
def to_celsius(f):
c = (f - 32) * 5 / 9
print(to_celsius(212))
(a) Explain why it prints None, and (b) give the corrected program and what it then prints.
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 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-07.md.)
Rubric — 100 points
| Criterion (part) | Full credit | Partial | Little/none |
|---|---|---|---|
| Part 1 — Write two functions (25) | Both functions defined with correct parameters and a return that gives the right value, with a working call of each (7 and 24) (25) |
One function correct, or a function that PRINTS instead of returns, or correct logic with a small slip (8–18) |
Neither function works / no output shown (0–7) |
| Part 2 — Predict the output / None (25) | Both lines correct (Hi, Sam then None) and correct return-vs-print/None reasoning (25) |
Gets Hi, Sam but misses/mis-explains the None, or right output with weak reason (10–18) |
Wrong output and reasoning (0–8) |
| Part 3 — Trace the scope (25) | Both lines correct (25 then 0) and correct local-vs-global reasoning (inner assignment doesn't change the outer) (25) |
Says second line is 25 (scope error) but explains after running, or right numbers with weak reason (10–18) |
Wrong output and reasoning (0–8) |
| Part 4 — Find & fix the bug (25) | Identifies the missing return as the cause of the None and gives the fix return c with output 100.0 (25) |
Right fix with a fuzzy explanation, or correct cause but no fix/output (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.
- Part 1: two functions that return (not print) their results, e.g.:
```python
def max_of_two(a, b):
if a > b:
return a
else:
return b
def area(w, h):
return w * h
print(max_of_two(7, 3))
print(area(6, 4))
Output (run-verified):
7
24
`return a if a > b else b` is an acceptable one-line `max`. Check `max_of_two(2, 9)` gives `9`. The key point: the functions **`return`** the value; a version that `print`s the answer inside is partial credit.
- **Part 2:** output is **two lines** (run-verified):
Hi, Sam
None
Reasoning: `greet("Sam")` **prints** `Hi, Sam`, but has no `return`, so it hands back `None`; `x` is `None`, and `print(x)` shows `None`. (`print` shows a value; `return` hands one back — a no-`return` function returns `None`.)
- **Part 3:** output is **two lines** (run-verified):
25
0
Reasoning: inside `add_tip`, `total = amount + 5` makes a **new local** `total` (= 25) that is returned, so the first print is `25`. That assignment does **not** change the outer (global) `total`, which stays `0`, so the second print is `0`. (To change the outer value: `total = add_tip(20)`.)
- **Part 4:** (a) the function computes `c` but never **returns** it (no `return`), so the call hands back `None` and `print` shows `None` (and `c` is local, unreachable from outside). (b) The fix:python
def to_celsius(f):
c = (f - 32) * 5 / 9
return c
print(to_celsius(212))
``
Output (run-verified):100.0(212°F = 100°C; it's a float because/` always returns a float).
Canvas placement block
canvas_object = Assignment
title = "Week 7 Assignment — Write, Return, Trace, Fix (traditional)"
assignment_group = "Assignments"
points_possible = 100
grading_type = points
assignment_type = traditional
submission_types = [online_upload, online_text_entry]
due_offset_days = 6
published = true
rubric_ref = "week-07-assignment-rubric"
provenance = "~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com"
~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com