Learn Without Walls
← Back to Module 11

Module 11: Study Guide

Review key concepts from File Handling

Key Terms

File object: The Python object returned by open() that provides methods to read or write file data.
File mode: A string like "r", "w", "a" that tells Python how to open the file.
Context manager: An object used with the with statement that automatically manages setup and cleanup (like opening and closing files).
CSV: Comma-Separated Values - a plain text format for tabular data where commas separate values in each row.
Newline character: The invisible \n character that marks the end of a line in a text file.

Lesson 1: Reading Files

Lesson 2: Writing Files

Lesson 3: The with Statement

Lesson 4: CSV Data

Review Questions

1. What is the difference between "w" and "a" file modes?

2. Why is the with statement preferred over manual open()/close()?

3. What is the difference between read(), readline(), and readlines()?

4. Why do we need newline="" when writing CSV files?

5. What is the advantage of DictReader over csv.reader?

6. What happens if you forget to close a file?

Common Mistakes to Avoid