// 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
dict_creation.py
Dict creation — literals, empty dicts, keyword arguments, zip from two lists, and adding keys one at a time. Every way …
// Code Example
dict_reading.py
Reading from a dict — square brackets, get(), default values, and keys/values/items views. Direct when certain, safe wh…
// Code Example
dict_modifying.py
Modifying a dict — direct assignment, update, setdefault, pop, popitem, clear. Methods that write, and the one mistake …
// Code Example
dict_inspection.py
Getting information from a dict — in, len, keys, values, items, copy. Reading without changing, and the copy trap that …
// Code Example
dict_iteration.py
Iterating over a dict — keys, values, and pairs. The three patterns, when to use each, and how to build a new dict from…
// Code Example
dict_nested.py
Nested dicts — one structure, all the data. Creating, accessing with two keys, looping with items(), modifying inner di…
// Code Example
tuple_usage.py
Tuples in practice — indexing, slicing, looping, unpacking, multiple return values, dict keys, and converting between t…
// Code Example
set_usage.py
Sets in practice — add, remove, discard, membership checking, union, intersection, difference, and the patterns that ma…
// 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 …
// Code Example
file_reading.py
read(), readlines(), readline(), and looping directly — every way Python reads a file. Place soldiers.txt in the same f…
// 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…
// Code Example
module_datetime.py
datetime, date, timedelta — current time, formatting with strftime, parsing with strptime, and calculating differences …
// Code Example
module_statistics.py
statistics — mean, median, mode, multimode, stdev. Five lines and a complete picture of your data.