Chapter 2
Names, Values, and Types
Assignment, numbers, strings, booleans, None, expressions, statements, and type inspection.
What this chapter does
After a reader can run code, the next step is to understand what code stores and manipulates. This chapter teaches names as handles for values and types as a practical debugging tool.
Lessons
Read these in order.
The chapter opening gives the main idea. Move through these lessons next; each page reuses ideas from the pages before it.
- 01Names and Assignment
Assignment as the action of making a name refer to a value.
- 02Numbers and Arithmetic
Integers, floats, arithmetic operators, precedence, and visible computation.
- 03Strings and Text
Text values, joining strings, f-strings, and the difference between text and numbers.
- 04Booleans and None
True, False, comparisons, and None as intentional absence.
- 05Expressions and Statements
Expressions as value producers and statements as executable instructions.
- 06Inspecting Types
Using type() to inspect surprising values before guessing.
You are ready when
- Assign values to names and track reassignment.
- Compute with numbers and arithmetic expressions.
- Use strings, booleans, and None deliberately.
- Separate expressions from statements.
- Inspect types when a value behaves unexpectedly.
Where this leads
- Branches and Loops
- Functions
- Collections and Iteration