Skip to main content

Command Palette

Search for a command to run...

πŸŽ’ Objects Explained Like You're 5

Published
β€’1 min read
S

Building AI systems and writing about how they actually work. Master of AI @ University of Technology Sydney. Previously B.Tech CS with focus on IoT. I believe the best way to learn is to explain. That's why I'm documenting tech concepts with simple analogies (@sreekarreddy.com). AWS Certified β€’ Azure AI Certified β€’ Neo4j Professional β€’ Google Data Analytics When not coding: exploring Sydney, working on side projects, and teaching tech to anyone who'll listen.

A backpack with labeled pockets

Day 25 of 149

πŸ‘‰ Full deep-dive with code examples


The Backpack

Your backpack has pockets with labels:

  • "water bottle" pocket β†’ water bottle inside
  • "pencils" pocket β†’ pencils inside
  • "lunch" pocket β†’ sandwich inside

Objects are backpacks with labeled pockets!


In Code

backpack = {
    "water_bottle": "blue bottle",
    "pencils": 5,
    "lunch": "sandwich"
}

To get lunch: backpack["lunch"] β†’ "sandwich"


Arrays vs Objects

Array: Items by number

[apple, banana, cherry]
   0       1       2

Object: Items by name

{fruit: apple, count: 3, color: red}

Use arrays for lists. Use objects when things have names!


Real Example

person = {
    "name": "Alex",
    "age": 25,
    "city": "Sydney"
}

print(person["name"])  # Alex

In One Sentence

Objects store data with descriptive labels, like a backpack with named pockets for different items.


πŸ”— Enjoying these? Follow for daily ELI5 explanations!

Making complex tech concepts simple, one day at a time.

More from this blog

esreekarreddy

132 posts