7 min read
💡beginner

Data Types — The Different Kinds of Information

Learn about strings, numbers, booleans, and more — the building blocks that every programming language uses to store information.

Why Types Matter

In real life, you treat different things differently. You read a book, you eat food, you throw a ball — you'd never try to eat a book or read a ball! Computers work the same way. The number 42 and the text "42" look similar to us, but to a computer they're completely different things. The number can be added, multiplied, and compared. The text can be searched, split, and combined with other text. That's why every piece of data has a 'type' — it tells the computer what this thing IS and what you can DO with it.

The Main Data Types

Almost every programming language has these basic types: • Strings — Text. Anything in quotes: "Hello", "123", "pizza time". Even a single letter "A" is a string. You can glue strings together, search inside them, or count their characters. • Integers — Whole numbers without decimals: 5, -3, 1000, 0. Used for counting things, player scores, ages, quantities. • Floats (Decimals) — Numbers WITH a decimal point: 3.14, 99.9, 0.001. Used for measurements, money, and math that needs precision. • Booleans — Only two possible values: true or false. Named after mathematician George Boole. Used for yes/no decisions: is the user logged in? Is the game over? Is the answer correct? • Null/None — Means 'nothing' or 'empty'. It's not zero (zero is a number), it's the absence of any value. Like an empty box vs. a box with a 0 in it.

Data Types in Action

python
# Strings (text)
name = "Lumora"          # a word
greeting = "Hello! 👋"   # can include emojis!
empty = ""               # empty string (still a string!)

# Integers (whole numbers)
age = 12
temperature = -5
zero = 0

# Floats (decimal numbers)
pi = 3.14159
price = 9.99
tiny = 0.001

# Booleans (true/false)
is_student = True
game_over = False

# None (nothing)
favorite_color = None  # not set yet

Collections — Groups of Data

Sometimes you need to store MANY pieces of data together. That's where collections come in: • Lists/Arrays — An ordered collection, like a numbered shopping list. Each item has a position (index). Example: ["apple", "banana", "cherry"] • Dictionaries/Objects — A collection of key-value pairs, like a real dictionary where you look up a word to find its definition. Example: {"name": "Aarav", "age": 12} These let you organize data in powerful ways. A game might use a list for the leaderboard scores and a dictionary for each player's profile.
Pro Tip

A common beginner confusion: the number 42 and the string "42" are NOT the same thing! The number lets you do math (42 + 8 = 50), but the string would just get glued to other text ("42" + "8" = "428"). Always make sure your data is the right type for what you want to do.

Think About It

Think about a student profile on a school app. What data types would you use for: the student's name, their age, their GPA, whether they're enrolled, their list of classes, and their locker number? Write out each piece of information and its type.

Ready to build?

Put what you learned into practice — pick a project and start coding.

Start Building Free