File
File I/O is fundamental to nearly every Python program. This guide covers reading, writing, and managing files effectively using Python's built-in tools. The guide walks through Opening Files, Reading Files, Writing Files, Context Managers, File Positioning. Use `open()` with the file path and mode: `"r"` for read, `"w"` for write (overwrites), `"a"` for append, `"rb"`/`"wb"` for binary. Specify `encoding="utf-8"` for text files. Always close files or use a context manager. `file.read()` reads the entire content as a string. `file.readline()` reads one line at a time. `file.readlines()` returns a list of all lines. You can also iterate directly with `for line in file:` which is memory-efficient for large files. `file.write(string)` writes content. `file.writelines(lines)` writes a list of lines without adding newlines. Use `"a"` mode to append to existing files. Flush or close to ensure data is written to disk. The guide is organized into 5 sections that build on each other, each pairing a prose explanation with runnable code.