Data Types: What Kind of Stuff? 🗂️
Numbers, words, true/false — every piece of data has a TYPE. Think of it like different shaped containers that only hold certain things!
Every Value Has a Type!
Just like different containers hold different things — code does too!
When I first started coding, I didn’t understand why 5 and "5" were different things. My teacher said — “Think about your kitchen.” You keep juice in a glass, soup in a bowl, and pencils in a box. You wouldn’t put soup in a pencil box! Code is the same — every type of data has its own container! 🧪
Every Beginner Must Know These!
Learn each one — with real examples and code!
Integer — Whole Numbers Only!
Integers are whole numbers — no dots, no decimals. Positive, negative, or zero. Perfect for counting things like scores, ages, or steps!
age = 10
score = 500
# type(age) → int
String — Any Text in Quotes!
A string is any text wrapped in quote marks. Your name, a message, a sentence — all strings! The quotes tell the computer “this is text, not a command!”
name = “Sara”
msg = “I love coding!”
# type(name) → str
Float — Numbers with Decimals!
Floats are numbers with a dot and decimal point. Think prices, temperatures, measurements — anything that isn’t perfectly whole!
price = 4.99
temp = 37.5
# type(price) → float
Boolean — Just True or False!
Booleans only have two possible values — True or False. That’s it! They’re used for yes/no questions in your code — like a light switch. On or off!
I use these with if/else all the time — “is the game over? True or False?” 🎮
is_raining = True
game_over = False
# type(is_raining) → bool
List — Many Items Together!
A list holds multiple values in one place. Mix different types, or keep them the same. Use square brackets [ ] to make one!
friends = [“Ali”, “Sara”]
scores = [90, 85, 78]
# type(friends) → list
Can You Guess the Right Type?
Look at the value — pick its data type! See how many you get right!
8 values to sort · tap the correct type!
You Use These Every Day!
Data types aren’t just coding — they’re everywhere!
Video Game
Player name is a String. Score is an Integer. Is game over is a Boolean!
str + int + boolOnline Shop
Product name is a String. Price is a Float. Items in cart is a List!
str + float + listWeather App
City name is a String. Temperature is a Float. Is raining is a Boolean!
str + float + boolSchool System
Student name is a String. Age is an Integer. Subjects is a List!
str + int + listAll 5 Types at a Glance!
Save this — you’ll need it every time you code!
| Type | What it holds | Example | Real life |
|---|---|---|---|
| int | Whole numbers | age = 10 | Score, age, count |
| str | Text in quotes | name = “Ali” | Names, messages |
| float | Decimal numbers | price = 9.99 | Money, temperature |
| bool | True or False only | on = True | On/off, yes/no |
| list | Many items | items = [1,2,3] | Playlists, scores |
4 questions · pick an answer to check!
⭐ Remember This!
Data types tell the computer what kind of data it’s working with
int = whole numbers, float = decimals
str = text in quotes, bool = True or False
list holds many values together in one place
