π Arrays Explained Like You're 5
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.
Train compartments in a row
Day 24 of 149
π Full deep-dive with code examples
The Train
Imagine a train with numbered compartments:
π [Car 0] [Car 1] [Car 2] [Car 3] [Car 4]
Each car has a number (starting from 0!) and can hold one thing.
Arrays are trains for your data!
In Code
fruits = ["apple", "banana", "cherry", "date"]
Index: 0 1 2 3
["apple", "banana", "cherry", "date"]
To get banana: fruits[1] (index 1, the second item)
Why Start at 0?
Tradition from early computers! Just remember:
- First item = index 0
- Second item = index 1
- Third item = index 2
What Can You Do?
| Action | Code | Result |
| Get item | fruits[2] | "cherry" |
| Change item | fruits[0] = "apricot" | Updates first item |
| Add item | fruits.append("elderberry") | Adds to end |
| Count | len(fruits) | 5 |
In One Sentence
Arrays store multiple items in a numbered list, like numbered train compartments in a row.
π Enjoying these? Follow for daily ELI5 explanations!
Making complex tech concepts simple, one day at a time.