Lesson 11 of 13

Objects: Real Things in Code! 🗂️

An object groups related information together — like a trading card! One card holds name, age, colour, power — all about one thing!

🐶 dog = {
  “name”: “Buddy”,
  “breed”: “Labrador”,
  “age”: 3,
  “is_friendly”: True
}
🤔 What is an Object?

Group Related Info Together!

Without objects — messy. With objects — clean and organised!

I remember trying to store information about my favourite Pokémon — I made separate variables for name, type, HP, and attack. It was chaos! Then I learned about objects. One object — all the information, neatly grouped together. It changed everything! 🎮

😰 Without Objects
dog_name = "Buddy"
dog_breed = "Labrador"
dog_age = 3
dog_colour = "Golden"
dog_friendly = True
5 separate variables — messy!
😎 With an Object!
dog = {
  "name": "Buddy",
  "breed": "Labrador",
  "age": 3,
  "colour": "Golden",
  "friendly": True
}
1 object — neat & clean! 🎉

🌍 Objects in Real Life

Everything Around You is an Object!

Any real thing with properties can become a code object!

🐾 Animal Object
🐶
dog
name:“Buddy”
breed:“Labrador”
age:3
friendly:True
🎮 Game Object
🧑‍💻
player
name:“Sara”
score:1500
level:7
alive:True
📚 Book Object
📖
book
title:“Python Kids”
author:“Ali”
pages:250
read:False
🚗 Vehicle Object
🚗
car
brand:“Toyota”
colour:“Red”
doors:4
electric:False

💻 Create & Use Objects

2 Things You Need to Know!

Create it once — access any property anytime!

1
🏗️

Create the Object

Use curly braces { } with key: value pairs inside. Each pair is a property of your object!

cat = {
  "name": "Whiskers",
  "colour": "Orange",
  "age": 2,
  "indoor": True
}
2
🔑

Access Properties

Use square brackets [ ] or a dot (.) to get any value from your object anytime!

# Get the cat's name
print(cat["name"])
# Output: Whiskers

# Change the age
cat["age"] = 3
print(cat["age"])
# Output: 3

🎮 Build Your Own Object!

Interactive Object Builder!

Choose a type, change the properties — watch the card update live!

🎴 Object Card Maker

Pick a type and customise the properties — your card updates instantly!

🐶 dog
🐶
Buddy
// PYTHON CODE

⚡ What Can You Do With Objects?

4 Key Object Superpowers!

Objects can do way more than just store information!

📖

Read a Property

Get any value from the object using its key name in square brackets!

dog[“name”] → “Buddy”
✏️

Change a Property

Update any value anytime — just assign a new value using the key!

dog[“age”] = 4

Add a New Property

Objects can grow! Add a brand new key-value pair anytime you need!

dog[“tricks”] = 5
🗑️

Remove a Property

Use del to remove a property you no longer need from the object!

del dog[“colour”]

🧠 Quick Quiz!
🎯 Objects Quiz

4 questions · pick an answer to check!

⭐ Remember This!

🗂️

Objects group related data together in one place

{ }

Use curly braces { } to create an object in Python

🔑

Each piece of data has a key and a value

📖

Use object[“key”] to read or change any property!