Review
Key Ideas
- A name refers to a value.
- Assignment updates what a name refers to.
- Reassignment affects later lines, not earlier output.
- Integers and floats are numeric values.
- Strings store text.
- Booleans are
TrueandFalse. Nonerepresents no meaningful value yet.- Expressions produce values.
- Statements do work.
type()inspects what kind of value Python has.
Key Syntax
| Syntax | Meaning |
|---|---|
score = 8 | assign a value to a name |
print(score) | print the value referred to by score |
"hello" | string value |
True | boolean true |
False | boolean false |
None | intentional absence of a value |
2 ** 3 | power |
type(value) | inspect the value's type |
Common Mistakes
| Mistake | Fix |
|---|---|
| Reading assignment as permanent equality | read assignment as an action |
| Using a name before assignment | assign the name first |
Confusing "8" and 8 | inspect with type() |
Using ^ for powers | use ** |
Writing true or false | use True and False |
| Expecting assignment to print | use print() |
Checklist
You are ready to move on if you can:
- predict the final value after reassignment
- compute small arithmetic expressions
- join strings intentionally
- explain why
"4" + "5"gives"45" - recognize booleans and
None - separate the right-side expression from the whole assignment statement
- use
type()to debug a surprising value
If You Feel Lost
Return to this tiny program:
Then change "8" to 8 and rerun. Watch both the output and the type.