Different Types of Stuff! 🔢📝✅
Just like how toys come in different types (cars, dolls, blocks), information in coding comes in different types too!
🤔 Why Do Types Matter?
Imagine if someone asked you to add your name plus the number 5. That doesn't make sense, right? Computers feel the same way! They need to know what type of information they're working with.
Numbers
For math!
Words
For messages!
Yes/No
For decisions!
🔢 Numbers
Numbers are used for counting, math, and keeping score! They can be whole numbers or have decimals.
Whole Numbers
Decimal Numbers
🎮 In Games: Your health points, coins collected, and damage dealt are all numbers!
📝 Text (Called "Strings")
Text in coding is called a "string" - like a string of letters all connected together! Strings are always wrapped in quotation marks.
name = "Alex" greeting = "Hello, World!" favorite = "Pizza is the best!" Strings Can Hold:
- • Your name
- • Messages to friends
- • Game character names
- • Anything with letters!
Important!
Always use quotes!
"hello" = String ✅
hello = Not a string ❌
✅❌ True or False (Booleans)
Sometimes you just need a simple yes or no answer! In coding, we call these "booleans" (BOO-lee-uns). They can only be true or false.
true
Yes! It's correct!
false
No! It's not correct!
🎮 Booleans in Video Games:
isGameOver = false hasKey = true canJump = true isPaused = false 🎭 The Same... But Different!
Check this out - the number 5 and the text "5" look the same, but they're totally different to a computer!
Number 5
Can do math with it!
Text "5"
It's just a character!
🧠 Think About It!
What type would you use for each of these?
Your Age
Number! (like 9 or 10)
Your Pet's Name
String! (like "Buddy")
Is It Raining?
Boolean! (true or false)
Price of a Toy
Number! (like 19.99)
⭐ Remember This!
- 1
Numbers are for math, scores, and counting (5, 100, 3.14)
- 2
Strings are text in quotes for names and messages ("Hello!")
- 3
Booleans are true or false for yes/no questions
- 4
The computer treats each type differently!