Back to the Introduction to Computer Science outline The Course Maker
Introduction to Computer Science outline
Week 4 · Coding Lab

Week 4 — Coding Lab / Programming Studio · "Decisions, Decisions"

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
Objective: Objective 3 — make programs decide with Booleans and if/elif/else; trace which branch runs; spot the =-vs-== bug · SLO A (write & run) + SLO B (trace & debug)
Worth 50 points · Coding Labs group = 15% of the grade · Coding Lab 4
Format: a hands-on programming studio worked in a free online Python environment — you'll (a) write small decision programs, (b) trace a truth table and "which branch runs" (predict, then run), and (c) find and fix a bug — and then catch the AI's mistake when it mis-ranks and/or or flips a boundary.

This is the course's signature weekly component. Every instructional week has one Coding Lab. Everything runs in your browser — nothing to buy or install. The whole habit of this lab (and this course): don't guess which branch runs or what a Boolean evaluates to — run it and read what Python actually prints.


Part 1 — The Big Picture

This week your programs learned to decide: a condition is a Boolean (True/False), and if/elif/else runs exactly one branch based on it. This lab is that idea, three ways: you'll write decision programs, trace Boolean expressions and branches (predict the output, then run to check), and debug a conditional (find and fix what's broken — including the famous =-vs-== slip). By the end you'll trust the interpreter, not your gut, on every True/False.

Your tools (both free, both in the browser):
- An online Python editor to write and run code: 🔗 https://www.online-python.com/ (or 🔗 https://www.programiz.com/python-programming/online-compiler)
- Python Tutor to watch a conditional decide step by step: 🔗 https://pythontutor.com/ — paste a program, click Visualize Execution, then step forward and watch the arrow check each condition and jump to the branch that runs.


Part 2 — Setup (2 minutes)

  1. Open the online Python editor in a new tab.
  2. Delete any sample code so you have a blank editor.
  3. Type print(True and not False) and press Run. You should see True in the output area. You just evaluated a Boolean expression.

Part 3 — (a) Write: Small Decision Programs

Write each of these in the editor, run it, and paste your code and its output into your submission.

  1. Even or odd. Write a program that sets a variable n to a whole number, then uses if/else to print even if n is divisible by 2 (n % 2 == 0) and odd otherwise. Run it once with an even n and once with an odd n; write down both outputs.
  2. Pass or fail. Write a program that sets score to a number and prints Pass if score >= 60, otherwise Fail. Run it for a passing and a failing score.
  3. Password check (uses and). Set two variables: length = 10 and has_digit = True. Print Strong only if length >= 8 and has_digit is true; otherwise print Weak. Run it, then change length to 5 and run again — notice the branch flips.

Part 4 — (b) Trace: Predict, Then Run

4a — Truth table. For each expression below, first write your predicted value (True/False) in the table (don't run it yet!). Then run each one in the editor and fill in the "Actual" column. Where your prediction and the actual differ, that's the lesson.

# Expression Your prediction Actual (after running)
1 print(True and False) ______ ______
2 print(True or False) ______ ______
3 print(not False) ______ ______
4 print(True and not False) ______ ______
5 print(True or False and False) ______ ______
6 print(not (3 > 2)) ______ ______
7 print(5 >= 5) ______ ______
8 print(5 > 5) ______ ______

Hints: for #5, remember the precedence order notandor (which operator goes first?). For #7 vs #8, look carefully at whether the operator includes the equal case.

4b — Which branch runs. Type this program into the editor. For each value of n in the table, predict which line prints, then change n, run it, and record the actual output.

n = 50
if n > 100:
    print("huge")
elif n > 10:
    print("big")
elif n > 0:
    print("small")
else:
    print("zero or negative")
n Your prediction Actual (after running)
150 ______ ______
50 ______ ______
5 ______ ______
0 ______ ______
-3 ______ ______

Visualize one: paste the n = 50 program into Python Tutor and step through it. Watch Python check each condition top to bottom and stop at the first true one.


Part 5 — (c) Find & Fix the Bug

Each program below is broken — but in two different ways. For each: run it (or trace it), then write (i) what's wrong, (ii) why, and (iii) the fixed program (with the output it then produces).

Bug A — it crashes.

x = 7
if x = 7:
    print("seven")

Bug B — it runs, but prints the WRONG thing. A score of 100 should be a "High distinction," but watch what happens:

score = 100
if score >= 50:
    print("Pass")
elif score >= 90:
    print("High distinction")
else:
    print("Fail")

Hint for Bug B: there is no syntax error here — it runs fine. Trace it by hand first: which condition is true first? Remember Python takes the first true branch and stops.


Part 6 — Analysis Questions

Answer in a sentence or two each:
1. In the 4a truth table, which prediction did you get wrong (if any)? What did you learn from the gap?
2. Expression #5 (True or False and False) — explain, using precedence, why it evaluates the way it does. (Which operator runs first?)
3. Expressions #7 (5 >= 5) and #8 (5 > 5) differ by one character but give different results. Why? What does that tell you about boundary values?
4. For Bug A and Bug B, one is a SyntaxError and one is a logic bug. In your own words, what's the difference — and why is the logic bug sneakier?
5. Connect it: in the 4b "which branch runs" table, only one line printed each time, even though several conditions could look true. Explain the rule that makes that happen.


Part 7 — AI-Critique Moment (required — this is the BYOAI step)

Now bring in your approved chatbot (Gemini, Claude, or ChatGPT) and be the programmer who checks its work.

  1. Paste this to the chatbot: "What does this Python program print? print(True or False and False) and also print(not (3 > 2)). And which branch runs (what does it print) here? score = 60 then if score > 60: print('above') else: print('at or below'). Give me the exact output of each."
  2. Check every claim by running each yourself in the editor:
    - Did it get the precedence one right — True for True or False and False (the and runs first), or did it read left-to-right and wrongly say False?
    - Did it say not (3 > 2) is False (correct), or wrongly True?
    - Did it put the boundary right? With >, a score of exactly 60 is NOT "above" — it prints at or below. Chatbots often say above here.
  3. Write 2–3 sentences reporting what the AI got right and at least one thing you had to correct or verify carefully. If it happened to get everything right, say how you confirmed each one by running it — that's the skill.

The habit all term: the tool drafts, you run it and judge. A chatbot will confidently mis-rank and/or or flip a boundary — catching it by running the code is the entire point of this course.


Part 8 — What to Submit

Submit a single document (or text entry) with: your Part 3 programs and their outputs; your completed Part 4a truth table and Part 4b branch table (both columns); your Part 5 bug answers (what's wrong, why, and the fix + its output for each); your Part 6 answers; and your Part 7 AI-critique paragraph. Due Sunday, Sep 27, 11:59 p.m. (50 points).


Instructor answer key & model outputs — REMOVE BEFORE PUBLISHING TO STUDENTS

Execution gate: PASS — every output and branch below was produced by actually running the code in Python. Students' Part 3 wording/values vary; grade those on "does it run and produce the right kind of output for the branch chosen."

Part 3 (model, run-verified):
1. Even/odd: n = 4even; n = 7odd (uses n % 2 == 0). ✓ (values vary)
2. Pass/fail: score = 72Pass; score = 40Fail. ✓
3. Password: length = 10, has_digit = TrueStrong; change to length = 5Weak (the and needs both true). ✓

Part 4a truth table (run-verified):

# Expression Actual
1 print(True and False) False
2 print(True or False) True
3 print(not False) True
4 print(True and not False) True
5 print(True or False and False) True
6 print(not (3 > 2)) False
7 print(5 >= 5) True
8 print(5 > 5) False

Part 4b which-branch-runs (run-verified):

n Output
150 huge
50 big
5 small
0 zero or negative
-3 zero or negative

Part 5 bugs (run-verified):
- Bug A if x = 7: → (i) a SyntaxError; (ii) a single = is assignment (it stores a value) and isn't allowed inside a condition — a condition needs a comparison; Python even prints Maybe you meant '==' or ':=' instead of '='?; (iii) fix: if x == 7: → output seven.
- Bug B (elif order) → (i) a logic bug — it prints Pass for a 100; (ii) Python takes the first true branch: 100 >= 50 is True, so it runs Pass and never reaches >= 90, making the High distinction branch unreachable; (iii) fix: order most-specific (highest threshold) first —
python score = 100 if score >= 90: print("High distinction") elif score >= 50: print("Pass") else: print("Fail")
→ output High distinction.

Part 6 (expected): (1) most commonly #5 (True, not False) or #6 (False, not True). (2) Precedence notandor: the and runs first (False and FalseFalse), then True or FalseTrue — not left-to-right. (3) >= includes the boundary (so 5 >= 5 is True), while > excludes it (5 > 5 is False); boundary values land differently depending on which you choose. (4) A SyntaxError stops the program before it runs (Bug A); a logic bug runs fine but gives the wrong answer (Bug B) — sneakier because Python never warns you. (5) In an if/elif/else chain, Python runs the first branch whose condition is true and skips the rest, so only one line prints.

Part 7 (AI-critique): full credit for a specific catch — most commonly the AI saying True or False and False is False (reading left-to-right) instead of True, or putting the boundary score of 60 in above instead of at or below. Full credit also if the student verified each AI claim by running it.

Grading rubric — 50 points

Criterion Full Partial None
Part 3 — wrote & ran 3 decision programs (code + output; #3 uses and) (14) 14 7–11 0–5
Part 4 — truth table + branch table (predictions attempted + all actual values/branches correct from running) (14) 14 7–11 0–5
Part 5 — found & fixed both bugs (the SyntaxError =/== AND the elif-order logic bug: what/why/fix for each) (12) 12 6–10 0–4
Part 6 — analysis (precedence, the >=/> boundary, SyntaxError vs logic bug, first-true-branch rule) (6) 6 3–5 0–2
Part 7 — AI-critique (names a specific thing checked/corrected by running) (4) 4 2 0–1

Quality gate (self-checked): every model output above (even, odd, Strong, Weak, the eight truth-table values False/True/True/True/True/False/True/False, the five branches huge/big/small/zero or negative/zero or negative, seven, and High distinction) and the =-vs-== SyntaxError were produced by actually running the code in Pythonexecution gate: PASS. No output is hand-traced. The lab grades the student's process (write → run → trace → debug), not a single fixed wording for the open-ended Part 3.

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