← Back to the Introduction to Computer Science outline The Course Maker
← Introduction to Computer Science outline
Week 12 · Readings & resources

Week 12 — Readings & Resources

Introduction to Computer Science Free sample edition

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)

① 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.

Optional one-stop reference (free online reference)

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