Neural Sync Active
Computational Thinking · Week 3 — Procedures & parameters
Registry Synced
Computational Thinking · Week 3 — Procedures & parameters
1176 words
6 min read
2026-08-16
Reading compass
Now · Week map
Week 3 — procedures & parameters
Quiz 2 scope: Weeks 1–8 per IITM May 2026 foundation courses. Source baseline: IITM BS admissions important-dates calendar · May 2026 cycle. Times on assessments are operational conventions — verify hall ticket.
Week map
Decompose → procedure with parameters → return vs side effect → OR selection
Classify → Represent → Execute → Trap-check
- Recognize: Ask: Difference between parameter and argument?
- Procedure: - Parameters
- Variations / traps: Watch for: Parameter name same as global without noticing shadowing.
Formula chain (compressed)
procedure call → parameters → local vs global → side effects.
- Procedure —
def name(params): body— reusable block - Call —
name(args)— jump to body, return - Parameter —
formal ↔ actual binding— per-call values - Return —
output value to caller— expression result - Side effect —
mutates external state— trace globals carefully
Open interactive formula desk · Week 3 tab.
Deep study
Computational Thinking · Week 3 — Procedures and parameters
Procedures package reusable steps. Week 3 adds parameters, return vs side effect, and OR selection patterns.
Week map
Decompose problem → procedure definition → parameters vs arguments → return to caller → side effects → OR predicates → call-stack trace.
Procedure notation
- Procedure / function → named block with parameters →
procedure Add(a, b). - Parameter → placeholder in definition →
a,binside body. - Argument → actual value at call →
Add(3, 5)passes 3 and 5. - Return → value replaces call expression →
x ← Add(2, 4)→x = 6. - Side effect → changes external state or prints → return may be absent.
Call flow: caller pauses → callee runs → returns to line after call.
Mini-trace:
textprocedure Square(n): return n * n x ← 3 y ← Square(x) + 1
y becomes 10.Return vs print (side effect)
| Mechanism | Caller gets | Use |
|---|---|---|
return v | value v | further computation |
Print(v) | nothing (display) | human output |
Quiz often asks final variable — trace
return, not display.OR selection
OR gate: pass if any condition true.
Eligibility: “scholarship if grade A or score > 90” → one true suffices.
Truth mini-table for OR:
| cond1 | cond2 | OR |
|---|---|---|
| F | F | F |
| T | F | T |
| F | T | T |
| T | T | T |
Contrast week 2 AND filter — both must hold.
Procedure sketch:
textprocedure Eligible(grade, score): if grade == "A" or score > 90: return True else: return False
Pattern families
Easy — Trace one call
- Substitute arguments into parameters.
- Single return to assignment.
- Parameter shadows outer name — inner definition wins inside body.
Medium — Return vs side effect
- Procedure prints but caller assigns from missing return →
None-like bug. - Mutating input list as side effect — caller’s list changes.
- Two calls in one expression:
Add(1,2) + Add(3,4).
Hard — OR procedure design
- Truth table from word problem → procedure returning category.
- Nested call:
Double(Square(3)). - Parameter count mismatch at call — error or wrong binding.
Worked mini-examples
Example 1 — Simple return.
textprocedure Max2(a, b): if a >= b: return a else: return b m ← Max2(7, 5) # m = 7
Example 2 — OR gate.
textprocedure Weekend(day): if day == "Sat" or day == "Sun": return True return False Weekend("Sat") → True Weekend("Mon") → False
Example 3 — Side effect only.
textprocedure Show(n): Print(n) # no return x ← Show(4) # displays 4; x not useful for math
Example 4 — Nested calls.
textprocedure Inc(n): return n + 1 Inc(Inc(5)) → Inc(6) → 7
Example 5 — AND vs OR trap.
“Free if member or senior” → OR. “Free if member and coupon” → AND. Procedure must match wording.
Traps
- Ignoring return value when assignment expected.
- Parameter name equals global variable — trace inside procedure carefully.
- Side effect mutating caller’s list without expecting it.
- OR when problem requires all conditions (AND).
- Wrong argument order if parameters positional.
Diagnostic (try yourself)
- Trace:
textprocedure Times3(k): return k * 3 a ← 2 b ← Times3(a) + Times3(1)
What is
b?-
Write OR condition in one line:
flagTrue whencode == 404orcode == 500. -
Procedure prints
n*nbut does not return. Caller runsy ← Square(5)thenz ← y + 1. What can go wrong? -
procedure Pick(a, b): if a > 10 or b > 10: return a + b else: return 0. EvaluatePick(3, 12)andPick(8, 2). -
Difference between parameter and argument in one sentence each.
ChatGPT prep archive
Archived import for extra depth — complements the notes above, not official IITM material.
Core concepts
- Procedure: named reusable block; parameters receive inputs per call.
- Return value replaces call expression; side effect changes external state (print, mutate list).
- OR selection: pass if any condition true—different from AND filter.
- Call stack: caller waits; callee runs; returns to caller line.
Notation & vocabulary
| Concept | Note |
|---|---|
| Parameter | input slot in definition |
| Argument | value passed at call |
| Side effect | change outside local vars |
Pattern families
Easy — Trace a call
Substitute arguments into parameter names in body. Execute body. Return value to caller if expression used.
Medium — Return vs print
Print shows human output; return sends value to caller for further use. Quiz traces often ask final variable—know which procedure does which.
Hard — OR gate procedure
Combine predicates with or for eligibility. Document truth table. Procedure may return bool or category label.
Drill these on the pattern atlas — filter to week 3.
Traps
- Parameter name same as global without noticing shadowing.
- Ignoring return value when assignment expected.
- Side effect mutating input list unexpectedly.
- OR when problem requires all conditions (AND).
Retrieval prompts
- Difference between parameter and argument?
- Return vs side effect example?
- When is OR the right composite predicate?
Practice loop
- Read Deep study (if present) or core concepts once.
- Recite the formula chain without looking.
- Open one easy pattern on the interactive atlas for week 3.
- Attempt without solutions; mark studied after an honest try.
- Say one trap aloud before closing the tab.