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)   # float
How it works: type() tells you the category of each value, which helps you avoid mixing incompatible data.

Try It Yourself

  1. Create a str, an int, and a float.
  2. Print each with type().
  3. 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.