Quiz 2
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.
  1. Proceduredef name(params): body — reusable block
  2. Callname(args) — jump to body, return
  3. Parameterformal ↔ actual binding — per-call values
  4. Returnoutput value to caller — expression result
  5. Side effectmutates external state — trace globals carefully

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, b inside 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:
text
procedure Square(n):
    return n * n

x ← 3
y ← Square(x) + 1
y becomes 10.

Return vs print (side effect)

MechanismCaller getsUse
return vvalue vfurther 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:
cond1cond2OR
FFF
TFT
FTT
TTT
Contrast week 2 AND filter — both must hold.
Procedure sketch:
text
procedure 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.
text
procedure Max2(a, b):
    if a >= b:
        return a
    else:
        return b

m ← Max2(7, 5)   # m = 7
Example 2 — OR gate.
text
procedure Weekend(day):
    if day == "Sat" or day == "Sun":
        return True
    return False

Weekend("Sat") → True
Weekend("Mon") → False
Example 3 — Side effect only.
text
procedure Show(n):
    Print(n)
    # no return

x ← Show(4)   # displays 4; x not useful for math
Example 4 — Nested calls.
text
procedure 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)

  1. Trace:
text
procedure Times3(k):
    return k * 3

a ← 2
b ← Times3(a) + Times3(1)
What is b?
  1. Write OR condition in one line: flag True when code == 404 or code == 500.
  2. Procedure prints n*n but does not return. Caller runs y ← Square(5) then z ← y + 1. What can go wrong?
  3. procedure Pick(a, b): if a > 10 or b > 10: return a + b else: return 0. Evaluate Pick(3, 12) and Pick(8, 2).
  4. 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

ConceptNote
Parameterinput slot in definition
Argumentvalue passed at call
Side effectchange 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

  1. Difference between parameter and argument?
  2. Return vs side effect example?
  3. When is OR the right composite predicate?

Practice loop

  1. Read Deep study (if present) or core concepts once.
  2. Recite the formula chain without looking.
  3. Open one easy pattern on the interactive atlas for week 3.
  4. Attempt without solutions; mark studied after an honest try.
  5. Say one trap aloud before closing the tab.
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.