cs-129 — The Missing Marks
| Field | Value |
|---|---|
| id | cs-129 |
| difficulty | Foundational |
| topics | validation, missing values, communication |
| lecture | lecture-12 |
| estimated time | 5-minute attempt + 10-minute discussion |
| prerequisites | lecture-04 (state and sequences), lecture-09 (aggregation) |
| objective | classify incomplete records against an explicit rule before computing anything |
| solution | held by the instructor; discussed after the attempt |
Problem
The exams office exports this file, marks.csv, exactly as written:
name,mark
Ayla,72
Ben,
Cemre,abs
Deniz,64
Elif,999
Ferid,81
The office's written policy says: a blank or abs means the student was absent; a mark of 999 is a sentinel meaning recheck with the invigilator and is not a real mark. Your deliverable has three parts:
- Classify each of the six rows as
include,absent, orrecheck. - Count each class.
- Compute the average of the included marks, to one decimal place — and state one thing that would go wrong if the
999row were averaged in by a program that only checked "is it a number?".
If the problem is ambiguous anywhere, state the assumption you are making and carry on — a stated assumption is part of a good answer.
Examples
- Input: the six-row table above, the office policy as given
- Output:
included 3, absent 2, recheck 1, mean 72.3
Solve for the worked instance first. Then ask what would change if one number, name, or condition were replaced by something stranger.
What to notice
- "Blank",
abs, and999are three different kinds of missingness; a program that treats "not a normal mark" as one bucket loses the distinction the office policy cares about. - The average is only defined after the classification — the order of the deliverable is the order of the reasoning.
- Validation is a decision, not a mechanical filter: each rule comes from a human policy, and your job is to apply it and name it.
Discussion starter
After the solution is revealed, the class spends five minutes on this prompt: "The office now sends a file where one mark is 72,0 — same row, two values. Where in your classification does this break, and what do you ask the office before touching the data?"
Constraints and assumptions
- Difficulty: Foundational (multi-step reasoning on a small table).
- Topics: validation, missing values, communication.
- The policy text is authoritative; if a policy seems odd, you apply it and flag it, you do not silently "fix" it.
- Classroom-scale inputs unless the problem says otherwise.
- Time-box: about five minutes for a first attempt; partial answers with clear reasoning are worth more than silent struggling.
- Optional stretch (not required): describe an alternative approach and say when it beats the obvious one.
Hints and extension
- First nudge: how many distinct reasons can a mark be missing for?
- If stuck after three minutes, write the input/output line you expect and trace the smallest example by hand.
- After the reveal, attempt the extension below before the next lecture.
- Extension challenge: suppose
999could also be a genuine (bizarre) mark someone typed. What must change in the data format — not in your program — so the sentinel stays unambiguous?