05 / Python
Readable logic, visible lists
Guido van Rossum began Python at Christmas 1989 as a successor to ABC. Indentation is the block. The report’s analyze_dataset script is taught as a string. Nothing prints.
Python · 15 min · 0/6 quiz strings accepted
A Christmas successor to ABC
Guido van Rossum began Python at CWI in the Netherlands during Christmas 1989. ABC taught well and extended poorly. Python kept readability, a large standard library, and significant whitespace instead of braces. The first public release was 1991.
The 2010s made it the interface to NumPy, pandas, TensorFlow, and PyTorch. Adoption ranges from 54.8% to 73.8% by discipline. uv, a Rust-built package manager, is among the most admired tools, near 74%.
Indentation is the structure
Python does not use braces for blocks. The indent is the contract. If a line belongs to the if, it sits under it.
Keep one idea per function. Name the list after what it holds, not after how you felt when you wrote it.
names = ["Ada", "Grace", ""] ready = [name for name in names if name] print(ready)
Empty is a useful false
An empty string is false in a boolean test. Filtering with if name drops blanks without a ceremony.
When you need a stricter check, write it: if isinstance(name, str) and name.strip().
Prefer a comprehension when the result is a list
A for-loop that only appends can usually become a comprehension. The reader then sees the output shape on one line.
Beginner curriculum: a named dataset
The report’s first Python module is a procedural script. This terminal will not print columns. Type the function header exactly.
def analyze_dataset(dataset_name):
print(f"Initializing connection to {dataset_name}...")
columns = ["ID", "Revenue", "Margin"]
for col in columns:
print(f"Loading schema column: {col}")
analyze_dataset("Q4_Financials")Intermediate: DuckDB stays a reading
The next tier opens duckdb.connect(database=':memory:') and aggregates sales. CodeLabs will not open DuckDB. Remember the connect string. Run a real engine on your machine if you want the table.
Glossary
- comprehension
- A compact expression that builds a list from another.
- truthy
- A value that counts as true in a condition, such as a non-empty string.
- indent
- The spaces that bind a line to the block above it.
Quiz
Type the string. Keep the understanding.
The terminal cannot execute this language. It only prints ACCEPTED or REJECTED when your string matches the lesson.