Week 12 — Module Framing · File I/O & Exceptions
Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Module: Week 12 of 16 · Fall 2026 · in-person, two 75-minute coding-along studio sessions
Objective covered: Objective 7 — Process strings and files, and handle errors using try / except.
This file holds (A) the Module 12 Overview page ("Start Here") and (B) the Welcome Announcement. Dates assume a Tuesday/Thursday pattern with Week 12 meeting Tue Nov 17 and Thu Nov 19, and end-of-week work due Sunday Nov 22, 11:59 p.m. Adjust to match your section.
(A) Module 12 Overview — Start Here
Welcome to Week 12: File I/O & Exceptions
This is your home base for the week. Read it first, then work the checklist below from top to bottom.
So far, every program you've written forgets everything the moment it ends. This week your programs gain the ability to read and write files — to remember data between runs — using Python's with open(...) pattern. And because reading files (and converting user input, and dividing numbers) can go wrong, you'll learn to handle errors gracefully with try / except instead of letting your program crash. The habit of the course holds: run it and read what Python actually prints — especially the error messages, which are the whole point this week.
The week's big question
"How does a program remember data between runs — and how does it keep running when something goes wrong?"
By Friday you'll write to a file, read it back, and wrap risky code in try / except so a missing file (or a bad conversion) produces a friendly message instead of a crash.
By the end of this week, you can…
- [ ] Read and write files with
with open(...) as f:— and explain whywithis better than opening and closing by hand. - [ ] Handle exceptions with
try/except— and predict which block runs. - [ ] Name the common exceptions —
FileNotFoundError,ValueError,ZeroDivisionError,KeyError— and what triggers each. - [ ] Debug an unhandled exception by reading its type and wrapping the risky line in
try/except.
What's due this week, and when
| # | Do this | Type | Due |
|---|---|---|---|
| 1 | Read the week's readings + watch the linked resource | Read / watch (ungraded) | Before Thu Nov 19 |
| 2 | Skim the slides (Deck 12) and the lecture outline | Prep (ungraded) | Alongside class |
| 3 | Lecture Tutorial 12 — work through files & exceptions with one approved chatbot, submit the share link | Lecture Tutorial · graded (5%) | Sun Nov 22, 11:59 p.m. |
| 4 | Practice exercises — low-stakes reps | Practice · ungraded | Sun Nov 22 (recommended) |
| 5 | Coding Lab 12 — "Save, Read, Recover" — write & read a file, then catch a missing-file error | Coding Lab · graded (15%) · 50 pts | Sun Nov 22, 11:59 p.m. |
| 6 | Quiz 12 — files, with, try/except, exception types |
Quiz · graded (10%) | Sun Nov 22, 11:59 p.m. |
| 7 | Discussion 12 — "Fail Loudly or Fail Silently?" — a design debate, worked with one approved chatbot; post the AI summary + chat link and reply to two classmates | Discussion · graded (10%) | Initial post Fri Nov 20; replies Sun Nov 22 |
| 8 | Assignment 12 — "Remember & Recover" — write/read a file and handle errors, coached and scored by one approved chatbot | Assignment · graded (15%) · 100 pts | Sun Nov 22, 11:59 p.m. |
Heads-up on the AI tools: chatbots frequently catch the wrong exception type or claim a file persists when it doesn't. Catching that — by running the code — is the point.
How to succeed this week
- Run every file example. Write a file, then open it and
print(f.read()). Seeing it work (and seeing the error when the file is missing) is the lesson. - Two hooks: "
withopens it and closes it for you." And "trythe risky line;exceptcatches the fall." - Read the exception type first.
FileNotFoundError? The path is wrong or the file isn't there.ValueError? You tried to convert something that isn't a number. - Don't hide bugs. A
try/exceptthat swallows every error silently can mask a real problem — we'll debate exactly this on the discussion board.
See you Tuesday.
(B) Welcome Announcement — Module 12
Release setting: post on the module's start day (offset = 0), i.e., Tue Nov 17, 2026.
Subject: Week 12 — your programs learn to remember (and to recover) 💾
Hi everyone,
Until now, every program you've written forgets everything the instant it stops. This week that changes: your programs learn to write to files and read them back — real, persistent memory — with Python's clean with open(...) pattern. And since reading files can fail (a missing file, a bad name), you'll learn to catch errors with try / except so your program responds gracefully instead of crashing.
Three things not to miss:
1. Lecture Tutorial 12 — files & exceptions with an approved chatbot; submit the share link. Due Sun Nov 22.
2. Coding Lab 12 ("Save, Read, Recover"), Quiz 12, Discussion 12, and Assignment 12 also close Sun Nov 22.
3. Open the Start Here page first.
One reminder for this week especially: read the error message. A FileNotFoundError or a ValueError isn't a disaster — it's Python telling you exactly what went wrong so you can wrap it in a try / except.
See you Tuesday,
Prof. Okafor
~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com