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

Week 12 — Readings & Resources · File I/O & Exceptions

Introduction to Computer Science · CSCI 1101 Fall 2026 · Prof. Okafor Fictional sample

Course: Introduction to Computer Science — CS1 / Programming Fundamentals in Python (CSCI 1101) · Silver Oak University (fictional sample) · Prof. Okafor
Objective covered: Objective 7 — Read and write files, and handle errors with try / except.


How to use this page

Everything here is a link to an external resource — open it in your browser; nothing to install. The fastest way to learn this week is to write a file, read it back, and trigger an error on purpose in the online editor, then handle it.

Order that matches the lecture: ① write & read files with with → ② try / except → ③ the common exceptions.


① Reading & Writing Files

Maps to Lecture Segments 2 & 6. with open(...) opens and closes a file for you; .read() returns a string; iterate the file to read line by line.

Read & do — "Reading and Writing Files" (official Python Tutorial, §7.2)
🔗 https://docs.python.org/3/tutorial/inputoutput.html
Why it's assigned: the source of truth on with open(...), .read(), .readline(), and why with is the right way (it closes the file automatically). Read §7.2; type the examples into the editor.
⏱ ~12 min

Read & do — "Python File Operation" (Programiz)
🔗 https://www.programiz.com/python-programming/file-operation
Why it earns the click: a clean, example-first walk through opening, reading, writing, and closing files, with the with pattern shown side by side.
⏱ ~10 min


② & ③ Exceptions and try / except

Maps to Lecture Segments 3–5. try the risky line; except <Type> catches a specific failure; read the exception type on the last line of a traceback.

Read — "Errors and Exceptions" (official Python Tutorial, §8)
🔗 https://docs.python.org/3/tutorial/errors.html
Why it's assigned: the official explanation of try/except and the built-in exception names (ValueError, ZeroDivisionError, and more) — exactly this week's vocabulary, from the people who make Python.
⏱ ~12 min

Read & do — "Python Exception Handling" (Programiz)
🔗 https://www.programiz.com/python-programming/exception-handling
Why it earns the click: short, practical try/except examples you can paste and run, including catching a specific exception type.
⏱ ~8 min


Optional one-stop references (free online)


Pick-one quick path (≈15 min total)

  1. Read Programiz "File Operation" and run a write-then-read in the editor (group ①).
  2. Read Programiz "Exception Handling" and run a try/except FileNotFoundError on a file name that doesn't exist (groups ②–③).

Heads-up (links rot): if a link ever fails, tell Prof. Okafor and use the official Python Tutorial (docs.python.org/3/tutorial) in the meantime.

~ Prof. Okafor's edition · Fall 2026 · built with thecoursemaker.com