// resources
Resources
All
|
Cheatsheet
Code Example
Exercise
Template
Other
Achievement
|
Basics
Control Flow
Functions
Data Structures
Modules & Packages
Projects
Object-oriented programming
|
↑ oldest first
↓ newest first
// Code Example
list_set_comprehensions.py
List and set comprehensions — transform, filter, and deduplicate in one line. Square brackets for lists, curly braces f…
// Code Example
dict_comprehensions.py
Dict comprehensions — build from a list, transform an existing dict, filter key-value pairs, swap keys and values, and …
// Exercise
even_numbers_2.py
Even Numbers upgraded — get_even() rewritten as a list comprehension. Four lines became one. Same result, less code.
// Code Example
file_reading.py
read(), readlines(), readline(), and looping directly — every way Python reads a file. Place soldiers.txt in the same f…
// Other
soldiers.txt
Test file for the file reading examples. Download and place it in the same folder as your script.
// Code Example
file_writing.py
Write, overwrite, append — every output pattern in one place. "w" starts fresh, "a" adds to the end, and write() needs …
// Code Example
file_csv.py
CSV files — reader, DictReader, writer, DictWriter. Every pattern in one place. All values are strings — convert when n…
// Other
soldiers.csv
Test file for the CSV examples. Download and place it in the same folder as your script.
// Exercise
daily_notes.py
Daily Notes — write a note, save it with a timestamp, append forever. Run it tomorrow and everything's still there.
// Exercise
shopping_list_3.py
Shopping List v3 — the list now survives. Saves to CSV on quit, loads on start. Run it tomorrow and everything's still …
// Other
file_mistakes.py
7 mistakes almost every beginner makes with file handling. Wrong way, error, right way — all in one file.
// Cheatsheet
File Handling — The Full Picture
Everything you've learned about file handling — in one place. The pattern, modes, reading, writing, CSV, error handling…