Python Core Data Types
Computers are very particular about what kind of data they handle. Text is a String (str), whole numbers are Integers (int), decimals are Floats (float), and true/false states are Booleans (bool). Python figures this out automatically when you type.
"Imagine your backpack. Books are strings of text, whole coins in your pocket are integers, a receipt with $4.99 is a float with decimals, and whether your zipper is open or closed is a boolean (True or False). You treat each item according to its kind."
Deep Dive: How It Works
String (str): Text wrapped in quotes ("hello", 'world'). Strings can contain letters, numbers, spaces, and punctuation.
Integer (int): Whole numbers positive, negative, or zero (42, -7, 0) without any decimal points.
Float (float): Numbers that contain a fractional part with a decimal point (3.14159, 99.95, -0.5).
Boolean (bool): Exactly two values: True or False (capitalized in Python). Used for logic, checks, and switches.
You can inspect the type of any variable or value at runtime using the built-in type() function: type(42) returns <class 'int'>.
Syntax Blueprint
name = "Zen" # str count = 10 # int price = 19.99 # float is_active = True # bool
Python automatically assigns the correct data type based on how the value is written.
Core Rules to Remember




Common Beginner Traps & How to Fix Them
Putting quotes around numbers: age = "20"Why it happens: Wrapping numbers in quotes turns them into text. "20" + "20" produces "2020", not 40.
How to fix: Leave numbers unquoted if you plan to do math with them.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Check the data type of a variable
Create a variable called score with the integer value 100.
Use print(type(score)) to print its data type.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.