Everything else is ready: study the parts, the key terms and the quiz below.
Data Types
Know the basic types and how they convert.
In this lesson4 parts
- 01Python data types: type, int, float, complex, bool, str and None
- 02Dynamic typing and type annotations, and why Python does not check them
- 03Type conversion: int truncation, ValueError, TypeError on plus, and why bool of the string False is True
- 04Recap and your challenge
Key terms
The words this lesson introduces, each in one line. The module’s glossary collects them all.
- int · float · complex · bool · str · None
- whole number · decimal number · complex number · True/False · text · no value
- type annotation
- the intended type,
age: int = 7; not checked by Python
Quiz 5 questions
Answer each one in your head, or on paper, before you check it. Getting one wrong here is how the lesson sticks.
- 01
What is
bool("False")? - 02
What is
int(-7.9)? - 03
What does
int("10p")give? - 04
items: int = "three"— does Python raise an error? - 05
What is the type of
None?
Practice
Problems to solve in your own notebook. Each states the problem, not the steps: working out the steps is the exercise. Level A applies the lesson, B combines it with earlier ones, C stretches it.
The self-checking notebook for this lesson is Notebook 2 · Variables and Data Types.
Common mistakes
What you will see when it goes wrong, why it happens, and the fix.
Where it’s used
Where this lesson’s ideas turn up in real work.