LESSON 4
Data Types
Learning objective: Recognize Python's core data types.
Understand
Python values have types like text, numbers, and booleans.
Core types include str (text), int (whole numbers), float (decimals), and bool (True/False). Use type() to check a value's type. Python figures out the type automatically.
Analogy: Data types are like ingredient categories: each behaves in its own way.
See It in Action
Checking types:
type("hi") # str
type(42) # int
type(3.14) # floatHow it works:
type() tells you the category of each value, which helps you avoid mixing incompatible data.Try It Yourself
- Create a str, an int, and a float.
- Print each with
type(). - Try adding an int and a float.
Quick Quiz
Which type stores decimal numbers?
Challenge
Create one variable of each core type and print its type.
Success condition: Your output shows the correct type for each variable.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →