What Are Data Types?
A Fun Guide For Curious Coders Aged 8β10
When you play a video game, write a story, or count your stickers, youβre using Dataβbits of information that a computer can understand. But just like you sort your crayons by colour, computers sort data into different Data Types. Knowing the right type helps the computer do the right job. Letβs explore!
1. Numbers: Integers and Floats
| Type | What it looks like | Example |
|---|---|---|
| Integer (whole number) | No decimal point | 7, β3, 0 |
| Float (decimal number) | Has a dot (.) | 3.14, β0.5 |
Why it matters:
If you tell the computer to add two Integers, it gives an integer result. If you mix a Float with an integer, the answer becomes a float.
Cause & Effect:
- Cause: Adding
5(integer) +2.5(float) - Effect: The computer returns
7.5(a float) because a decimal appeared.
2. Text: Strings
A String is any collection of letters, numbers, or symbols inside quotes: "Hello", "2025", "βοΈ".
Fun fact:
Even though "123" looks like a number, the computer treats it as text.
Cause & Effect:
- Cause: Trying to multiply
"3"Γ2 - Effect: The computer gets confused (an error) because you canβt multiply words the way you multiply numbers.
3. True or False: Booleans
A Boolean can only be one of two values: True or False. Itβs like a light switchβeither On or Off.
Example:
isRaining = True means it Is raining.
Cause & Effect:
- Cause: If
isRainingisTrue, the game might show a rainy background. - Effect: The scene changes automatically because the boolean told the program what to do.
4. Collections: Lists
A List stores several items in a specific order, separated by commas and wrapped in brackets: ["apple", "banana", "cherry"].
Did you know?
Lists can hold many different data types together, like [5, "hi", True].
Cause & Effect:
- Cause: You ask the computer for the 2nd item in the list.
- Effect: It returns
"banana"because the computer counts positions starting at 0.
Data Types Quiz
Conclusion
Youβve learned the basic data types and how they help computers understand information!