Quick reference

Look it up. Get back to building.

Search the corrected method tables, operators, errors, file modes, built-ins, and environment commands derived from the course PDF.

str.upper()Strings

Return a new uppercase string.

"python".upper()  # PYTHON
PDF ch. 7.3, 17
str.split(sep)Strings

Split text into a list at each separator.

"a,b".split(",")  # ["a", "b"]
PDF ch. 7.3, 17
sep.join(items)Strings

Join string items with a separator.

"-".join(["a", "b"])  # a-b
PDF ch. 7.3, 17
list.append(x)Lists

Add one item at the end; mutates the list.

items.append("Python")
PDF ch. 18
list.extend(values)Lists

Add every item from another iterable.

[1].extend([2, 3])
PDF ch. 18
sorted(values)Lists

Return a sorted list without mutating the input.

sorted([3, 1, 2])
PDF ch. 18
A & BSets

Intersection: values present in both sets.

{1, 2} & {2, 3}  # {2}
PDF ch. 20
A | BSets

Union: values present in either set.

{1, 2} | {2, 3}
PDF ch. 20
dict.get(key, default)Dictionaries

Read a key safely with a fallback.

profile.get("phone", "N/A")
PDF ch. 21
dict.items()Dictionaries

Iterate over key-value pairs.

for key, value in data.items(): ...
PDF ch. 21
// and %Operators

Floor division and remainder.

17 // 5 == 3; 17 % 5 == 2
PDF ch. 10
in / not inOperators

Test whether a collection contains a value.

"Py" in "Python"
PDF ch. 10.6
ValueErrorErrors

A value has the right broad type but invalid content.

int("hello")
PDF ch. 22
KeyErrorErrors

A dictionary lookup used a missing key.

{}["missing"]
PDF ch. 22
with open(...)Files

Open a file and guarantee cleanup after the block.

with open("data.txt") as file: ...
PDF ch. 25
r / w / a / xFiles

Read, replace-write, append, and create-only modes.

open("log.txt", "a")
PDF ch. 25
enumerate(iterable)Built-ins

Pair each value with a counter.

enumerate(names, start=1)
PDF ch. 12
zip(a, b)Built-ins

Pair values from multiple iterables.

list(zip(names, scores))
PDF ch. 12
python -m venv .venvEnvironment

Create an isolated virtual environment.

python -m venv .venv
PDF ch. 27
python -m pip installEnvironment

Install a package for the selected interpreter.

python -m pip install requests
PDF ch. 24, 27