Classroom Glossary Public page

Week 8: Midterm

1,297 words

The two-hour proctored practical. Build a small CLI tool from a spec you have not seen before, using only the standard library and your notes.


Theme

A midterm exists to ask one question: has the student internalized the first seven weeks well enough to apply them to an unfamiliar problem? Tutorials let you copy a pattern from one chapter to the next; the midterm asks you to put it together when no one is handing you the structure.

This week has no lecture and no lab. The class meets once: the proctored exam. Before the exam, students do their own review (recommended schedule below). After the exam, students submit and the week ends.

The exam is a 2-hour practical: you receive a spec for a CLI tool you have not seen before, and you must implement it using only Python's standard library, your own notes, and the official Python documentation. No internet for outside searches; no AI assistance; no peer collaboration during the exam.

The grading is correctness 60%, argparse hygiene 20%, error handling 20%. A student who passes the midterm can ship Lab 6's argparse + logging pattern unaided in 90 minutes.

What the midterm tests

The exam draws from weeks 1-7. Specifically, the exam will require you to demonstrate:

  • Week 1 fluency: variables, types, input/print, f-strings, type conversion
  • Week 2 control flow: if/elif/else, while, for, loop control
  • Week 3 functions: at least two named functions with docstrings; main() orchestration
  • Week 4 collections: at least one list and one dict; correct mutability handling
  • Week 5 file I/O: read a file (line-by-line or whole) with with open(...); handle missing file
  • Week 6 stdlib + argparse: at least three argparse arguments; --help reads like documentation
  • Week 7 regex (one of the three exam variants): one regex match used to extract or validate

The exam does NOT test:

  • Subprocess (week 9)
  • Git workflow (week 10)
  • Hashing (week 11)
  • HTTP / requests (week 12)
  • pytest (week 13)
  • Third-party packages

Any answer that uses a third-party package or unstandard syntax is rejected.

How to study (~12 hours over the week)

Total time budget: ~8 hours of focused review plus the 2-hour exam.

Day 1-2: Re-read your own lab solutions (3 hours)

Open Labs 1-7. Read your own code. For each lab, write a 50-word summary of what the tool does. If you can't summarize a lab from memory, re-read its .md file in the curriculum.

Day 3: Type-fluency drill (1.5 hours)

Without looking at your old labs, write from scratch:

  1. A program that asks for a number and prints whether it is prime
  2. A program that reads a CSV of (name, score) rows and prints the mean score
  3. A program that takes a file path on the command line, reads the file, prints the line count

Each ~15-20 minutes. The point is muscle memory for the basic shape: argparse, with open, line iteration, print formatting.

Day 4: Regex drill (1 hour)

Pick three of your Lab 7 regex patterns and rewrite them from scratch without looking. Then on regex101.com, write a regex for each:

  • A US zip code: \d{5} or \d{5}-\d{4}
  • A simple date: \d{4}-\d{2}-\d{2}
  • A simple URL: https?://\S+
  • A word that ends in -tion: \b\w+tion\b

Practice using re.findall and re.search in a REPL.

Day 5: Mock exam (2 hours)

Set a 2-hour timer. Pick ONE of the three sample specs below; build the tool to completion. After the timer, grade your own work against the rubric.

Three sample midterm specs (one rotates per cohort; the actual exam is one of these or a close variant):

Sample spec A: wordcount.py

Build wordcount.py FILE that prints word count, line count, and most common word for a passed file. Argparse must support --top N (default 1) to print the top-N most common words.

$ python3 wordcount.py speech.txt
Lines: 142
Words: 1842
Top word: the (87)
$ python3 wordcount.py speech.txt --top 5
Lines: 142
Words: 1842
Top 5 words:
  the      87
  and      54
  of       41
  to       38
  a        32

Requirements:

  • Argparse with FILE positional + --top N optional
  • Read file, count words (split on whitespace; lowercase before counting)
  • Use collections.Counter for the count
  • Handle missing file with a clear error message + nonzero exit
  • --help reads like documentation

Grading: 60% correctness (counts are right; top-N is right) + 20% argparse hygiene + 20% error handling.

Sample spec B: csv-summary.py

Build csv-summary.py FILE COLUMN that reads a CSV and prints count, min, max, and mean of the numeric values in the named column. Errors clearly if the column is non-numeric.

$ python3 csv-summary.py grades.csv score
Column: score
Count: 30
Min: 42
Max: 98
Mean: 76.4
$ python3 csv-summary.py grades.csv name
Error: column 'name' is not numeric (sample value: 'Alice Anderson')

Requirements:

  • Argparse with FILE and COLUMN positionals + optional --format (text or json, default text)
  • Use csv.DictReader
  • Catch and report missing column, missing file, non-numeric column
  • Exit 0 on success; 1 on data error; 2 on usage error

Grading: 60% correctness + 20% argparse hygiene + 20% error handling.

Sample spec C: dedupe.py

Build dedupe.py FILE that reads a text file and prints unique lines in order of first appearance. Support --ignore-case.

$ python3 dedupe.py raw.txt
apple
banana
cherry
$ cat raw.txt
apple
banana
apple
cherry
banana
$ python3 dedupe.py raw.txt --ignore-case
apple
banana
cherry
$ cat raw-case.txt
Apple
banana
APPLE
cherry

Requirements:

  • Argparse with FILE positional + --ignore-case flag
  • Preserve first-appearance order (NOT alphabetical)
  • Stream the file; do not load the whole file into memory
  • Use a set for seen-tracking; pick a normalization function based on the flag
  • Handle missing file

Grading: 60% correctness + 20% argparse hygiene + 20% streaming + error handling.

Day 6: Self-grade and patch gaps (30 min)

After the mock exam, identify what you got wrong. If you struggled with regex, re-read week 7. If you struggled with argparse, re-read week 6. Specifically practice what was hard.

Day 7 (exam day): Rest, then the exam

Sleep. Do not cram the morning of the exam. Bring your notes (paper or laptop), the official Python docs URL (no other tabs), and your patience.

During the exam

Time budget: 2 hours for the exam itself. Suggested split:

  • Read the spec carefully (5 min). Underline what is required vs what is optional.
  • Sketch the program structure on paper (5 min): what argparse arguments, what functions.
  • Write the argparse block first (10 min). Run with --help to verify the output is good.
  • Write the happy path (60 min). Get the basic case working before any error handling.
  • Add error handling (20 min). Missing file, bad input, etc.
  • Test against the spec's example inputs (15 min). Fix anything that does not match.
  • Read your code once more before submitting (5 min). Look for bugs you can see by reading.

Strategy:

  • If you do not know the answer to a question, look it up in the official Python docs (the one tab you are allowed). Do not stare at the screen waiting for inspiration.
  • A working program that gets 80% of the spec right is worth more than a perfect program you didn't finish. Always have something runnable to submit.
  • If you finish early, READ YOUR CODE. Almost everyone who finishes with time left finds at least one bug they had not noticed.

After the exam

Submit your .py file via the academy's submission portal (or email to interested@virtuscyberacademy.org with subject FND-102 midterm, {your-name} if your cohort uses email submission).

The course team grades within 7 days. Feedback includes the rubric breakdown plus one paragraph on what would have made the submission stronger.

Week 9 picks up immediately after the midterm with subprocess and pdb. Do not take the midterm-relief week off; week 9's debugging exercise builds on muscle memory from your midterm.

Common midterm stumbles

From the academy's pilot-cohort observations (to be appended as cohorts run; v0.1 derives from prior FND-101 + SEC-101 midterm patterns):

  • Skipping --help rewrite. Students with rushed argparse leave help strings like 'FILE' and 'TOP'. The 20% argparse-hygiene weight is real; spend the 60 seconds.
  • open() without encoding='utf-8'. Costs nothing to add; saves you from a Windows-specific failure mode the exam may grade on.
  • No if __name__ == '__main__':. Forgetting this means your main() runs at import time, which the grader may notice when running unit-test-style checks against your file.
  • Crashing on missing file. A bare open(path) crashes with FileNotFoundError on a missing path. The error-handling 20% expects a clean error message + nonzero exit.

What comes next

Week 9 introduces subprocess and pdb. Your scanner tools so far do their work entirely in Python; week 9's lab wraps the shell utility du via subprocess and adds a debugging exercise that uses pdb to find a planted bug. The same Python-craft discipline, applied to "drive other programs" and "debug your own code."