Week 12 — Readings & Resources
Your primary reading is Chapter 12 (in this module). Everything below is the optional, go-deeper layer — pick what helps, skip the rest.
How to use this page
This page has 11 items (5 readings and 6 videos). Allow 94–116 minutes for everything. Each group points back to the matching chapter section and class-session segment, so use the full menu when you want more, or take the quick path below.
Every video here has captions: turn them on with the CC button in the player. The chapter covers the same ideas in text.
Pick-one quick path (18–23 min total)
- Python read a file — Bro Code
- Demo, Error Handling, Python for Beginners 18 of 44 — Microsoft Developer
- Python File Operation — Programiz
① Writing a file and reading it back
Chapter 12, Section “Write a file: give your program a memory” · Session 1, Segment 1, “Writing and reading a file” · Remember: write mode starts a file over, write adds no newline of its own, and every line you read back is a string.
- Python File Handling, Visually Explained — Visually Explained — an animated walk through reading a file, writing one, appending, why a file needs closing, and the with statement; treat the append chapter as a preview of a mode this course only names, and skip the last chapter, on files stored elsewhere on your computer. Use it while working through the Week-12 module overview. (video, 14 min) (captions: automatic)
- Write files using Python — Bro Code — a demo of writing text to a file; watch the opening, on writing a plain .txt file in mode w, and the collections part about six and a half minutes in, where writing a list item by item runs the names together until a newline is added, and predict what the file holds after each run; the absolute-path, mode x, append, JSON, and CSV parts go beyond this week. (video, 14 min) (captions: automatic)
- Python File Operation — Programiz — a short reference page; read Opening Files in Python, Reading Files in Python, Writing to Files in Python with its warning that new content replaces old, and Opening a Python File Using with...open, and skip More on Python File Operations. (reading, 10–15 min)
② Reading lines, and turning text into numbers
Chapter 12, Section “Read a file: three ways to get the text back” · Session 1, Segment 2, “Three ways to read” · Remember: read hands back one string, readlines hands back a list, and every line keeps its newline until you strip it.
- Python read a file — Bro Code — a three-minute demo that opens a text file inside a with statement and prints it, and catches FileNotFoundError when the name is wrong; predict what prints for a missing file before it runs. (video, 4 min) (captions: creator)
- How To Handle Plain Text Files in Python 3 — DigitalOcean — a step-by-step community tutorial; read Step 3 on read and readlines, Step 4 on writing, and Step 6 on with statements, and skip the readline part of Step 3, which this course does not use. This builds on Week 11's work with strip and split, since every line you read needs both. (reading, 12–18 min)
③ Reading an error and catching it by type
Chapter 12, Section “Catch an error by type: which block runs” · Session 2, Segment 5, “Catching an error by type” · Remember: read the last line of a traceback to name the type, and an except block catches only the type it names.
- Python Error Handling, Visually Explained — Visually Explained — an animated explainer that starts from a division program with no error handling, adds try and except, and then uses more than one except block; say which block runs before each reveal. (video, 5 min) (captions: automatic)
- Python Tutorial, Using Try and Except Blocks for Error Handling — Corey Schafer — a code walkthrough of handling exceptions in specific ways and of the order in which the blocks of a try statement run; watch the try and except parts, and skip else and finally, which go beyond this week. (video, 11 min) (captions: automatic)
- Demo, Error Handling, Python for Beginners 18 of 44 — Microsoft Developer — a short live-coding demo that adds try and except to a small program; watch which line runs after an error, and treat its else and finally parts as beyond this week. (video, 4 min) (captions: creator)
- Errors and Exceptions, Programming with Python — Software Carpentry — a lesson episode on tracebacks; read Reading Error Messages, Variable Name Errors, Index Errors, and File Errors, and name each error type from the last line before you read on. (reading, 10–15 min)
- Exception Handling — learnpython.org — a one-screen interactive lesson that catches an IndexError inside a loop and keeps going; read the example and try the exercise in the page's runner. (reading, 5–8 min)
Optional one-stop reference (free online reference)
- Reading and Writing Files, The Python Tutorial section 7.2 — Python Software Foundation — the official tutorial's section on files, the course's free reference for every language fact; read the opening of 7.2 on modes and the with keyword and the first methods in 7.2.1, and skip 7.2.2 on saving structured data with JSON. (reading, 5–8 min)
Heads-up (links rot): these point to outside sites that occasionally move or rename pages. If a link ever fails, tell your instructor and use the reference above in the meantime.
Provenance: Built with The Course Maker · samples.thecoursemaker.com