Python Trio Slides
python -m intro technical_shareout.py
Technical Shareout
The Python Core Trio
A complete beginner's walkthrough to mastering [Lists], (Tuples), and {Dictionaries}.
Let's decode fundamental structures step-by-step Slide 1 / 15
THE COMPASS session_map.py
Our Coding Roadmap
01
Mutability
The core concept of writeable vs. read-only data.
02
Lists [ ]
Dynamic, ordered lists that adjust instantly.
03
Tuples ( )
Unchangeable, secure, and highly optimized records.
04
Dicts { }
Mapped key-value configurations for rapid lookups.
Four core steps to structural understanding Slide 2 / 15
CONCEPT CORE Mutable
Mutable: The Dry-Erase Whiteboard
In Python, mutable means an object can be modified in place. The object retains its original identity (memory address), but its contents are allowed to shift, append, or clear.
Ideal for dynamically updating collections
// Conceptual Metaphor
• Draw a circle on a whiteboard.
• Erase half of it, draw a square next to it.
• Result: You modified the whiteboard, but it is still the same whiteboard on the wall.
Whiteboards represent dynamic memory updates Slide 3 / 15
CONCEPT CORE Immutable
Immutable: The Stone Tablet
Immutable means an object's contents can never be modified once created. If you must change it, Python throws away the old object and carves a completely new one elsewhere.
Guarantees safety and stable records
// Conceptual Metaphor
• Carve coordinates into a stone tablet.
• You cannot erase or append new values in place.
• Result: To modify it, you must throw it away and carve a new tablet.
Stone tablets guarantee high-security read-only integrity Slide 4 / 15
DEEP DIVE: LISTS lists_intro.py
Lists: [The Ordered Sequence]
Lists are collections defined by square brackets [...]. They are ordered, meaning elements stay in the exact sequence you placed them.
Lists are indexed starting at 0. The first item is at index 0, the second at index 1.
# Defining a simple list
fruits = ["apple", "banana"]
# Pulling elements out by index
print(fruits[0]) # Output: "apple"
print(fruits[1]) # Output: "banana"
The bracket markers [...] represent dynamic ordered arrays Slide 5 / 15
DEEP DIVE: LISTS lists_mutability.py
Mutability in Action
Since lists are mutable, you can modify them in place using commands like .append(), .remove(), or index re-assignment.
Notice how you don't save the modified list to a new variable. The original list shifts.
todo = ["code", "sleep"]
# Append new item
todo.append("eat")
# Modify index 1 in place
todo[1] = "debug"
# todo is now: ["code", "debug", "eat"]
The physical memory address remains perfectly identical Slide 6 / 15
DEEP DIVE: LISTS lists_properties.py
Lists Under the Hood
Python lists are highly powerful because they handle diverse data and support duplicates automatically. Let's look at their unique behavioral rules:
Duplicates Allowed
You can store duplicate values: [1, 1, 1] is fully valid.
Mixed Data Types
A list can hold strings, floats, ints, or other lists simultaneously: ["abc", 42, 3.14].
Dynamic Scaling
You don't need to specify the size in advance. Python handles memory expansion automatically behind the scenes.
Extremely flexible structure, but has memory expansion costs Slide 7 / 15
DEEP DIVE: TUPLES tuples_intro.py
Tuples: (The Immutable Record)
Tuples are collections wrapped in parentheses (...). Like lists, they maintain absolute element ordering. But unlike lists, they are completely immutable.
Once compiled, a tuple is frozen. No appending, no popping, and no swapping.
# Define a tuple
colors = ("red", "green")
# Order index works normally
print(colors[0]) # Output: "red"
The parenthesis markers (...) denote immutable, fixed datasets Slide 8 / 15
DEEP DIVE: TUPLES tuples_error.py
Runtime Safety Guards
What actually happens if you try to mutate a tuple? Python crashes immediately with a TypeError. This protects database IDs, system settings, and other secure keys.
Crashes at runtime prevent accidental overwriting of sensitive business structures down the pipeline.
coords = (12.5, 45.9)
coords[0] = 14.2
TypeError: 'tuple' object does not support item assignment
An error that blocks bad data changes is a developer's best friend Slide 9 / 15
DEEP DIVE: TUPLES tuples_unpacking.py
Tuple Unpacking
Tuples have a unique syntax feature called unpacking. It allows you to rapidly extract all values into separate standalone variables in a single elegant line of code.
Variables on the left must match the exact count of items on the right.
# A profile tuple
profile = ("admin", 1002)
# Unpack values into variables
role, user_id = profile
print(role) # "admin"
print(user_id) # 1002
Unpacking makes multi-variable returns highly elegant Slide 10 / 15
DEEP DIVE: DICTIONARIES dicts_intro.py
Dicts: {The Key-Value Maps}
Dictionaries store data in mapped Key-Value Pairs inside curly brackets {key: value}. This replaces numbered order indexes with custom descriptive names.
Keys act like unique lockers. Values represent the assets protected inside them.
# Map labels directly to info
phone_book = {
"Alice": "555-1234",
"Bob": "555-9876"
}
print(phone_book["Alice"])
Descriptive strings or numbers represent the access keys Slide 11 / 15
DEEP DIVE: DICTIONARIES dicts_hashing.py
Hashing and Speed
Unlike lists, where Python has to search line-by-line to find an item, dictionaries find keys instantly using Hashing Algorithms.
This lookup speed is constant (called O(1) time), whether the dictionary has 10 items or 10 million.
Rule: Keys Must Be Hashable (Immutable)
Because keys undergo hashing to find their physical storage address, they must be unchangeable (immutable).
• Strings, Ints, Tuples: OK as Keys
• Lists, Dictionaries: Will fail as Keys
Rapid lookup performance is powered by hashing keys Slide 12 / 15
DEEP DIVE: DICTIONARIES dicts_mutability.py
Dynamic Key Updates
Dictionaries are mutable. You can add new key-value pairs or modify existing values using square-bracket assignment.
If the key already exists, Python updates its value. If the key is new, Python inserts it.
user = {"status": "online"}
# 1. Update existing key
user["status"] = "idle"
# 2. Add brand new key
user["admin"] = True
Dynamic mapping adjustments require no specialized update methods Slide 13 / 15
INTERACTIVE BRAINSTORM Discussion Arena
# CASE STUDY 01
A High-Score Board
You are building a game dashboard where the top 10 player names and scores must update every few seconds as games conclude.
Which data structure works best?
Discuss mutability vs order requirements.
# CASE STUDY 02
A Delivery Address
You need to represent a single customer's home coordinates on a delivery route map (Latitude, Longitude).
Which data structure works best?
Does a developer ever want these values to slide or shift?
# CASE STUDY 03
The App Settings
You need to quickly pull up a user's system preferences (e.g., Theme: "Dark Mode", Volume: 80) by descriptive labels.
Which data structure works best?
How will your application fetch the value instantaneously?
Turn to your peer and explain why choice matters! Slide 14 / 15
SUMMARY ROADMAP Quick Matrix
| Structure Type | Syntax Marker | Mutable? | Ordered? | Primary Use Case |
|---|
| List | [...] | YES | YES | Dynamic items, queues, shopping baskets, lists of items that change. |
| Tuple | (...) | NO | YES | Immutable records, system coordinates, fixed configuration blocks. |
| Dictionary | {key: val} | YES | YES (3.7+) | Key lookups, objects, map configurations, descriptive data stores. |
Ready to build! What's next in your code sandbox?
Slide 15 / 15
Python Trio Cheat Sheet
Reference Document (Page 1)
The Python Core Trio
v1.1.0
USER: ___________________________
COMPILED ON: ___________________________
LIST Mutable & Ordered Sequence
[item, item]
The Analogy
The Shopping Cart: You can add items, remove them, change existing ones, and rearrange their order.
items = ["key", "mouse"]
items.append("screen") # Adds item
items[0] = "lock" # Changes index 0
TUPLE Immutable & Ordered Sequence
(item, item)
The Analogy
The GPS Coordinate: Locked in stone. Safe from accidental runtime edits, highly secure, and faster.
loc = (40.7, -74.0)
print(loc[0]) # Reads index 0 (OK)
loc[0] = 34.5 # Raises Error!
DICTIONARY Mutable Key-Value Map
{key: value}
The Analogy
The Contact List: Instead of checking numerical index order, you look up a person's details directly by their name.
user = {"name": "lucy", "id": 42}
user["role"] = "admin" # Adds key-val
user["id"] = 99 # Modifies value
Quick Sandbox Challenge
Review the three scenarios below and write down which structure (List, Tuple, or Dict) is the ultimate best fit.
1. You need to record an immutable record of RGB values (255, 99, 71) for brand colors.
Structure: ________________
2. You are tracking custom player profiles inside a database using a string lookup id "player_992".
Structure: ________________
3. You are building an undo history buffer where operations can constantly be added and popped off.
Structure: ________________
Designed for complete beginner comprehension Page 1 / 2
Interactive Workbook (Page 2)
The Python Trio Workout
Hands-On Practice
PART A
Trace and Predict
Carefully read each Python snippet and write what would print inside the terminal.
languages = ["HTML", "CSS"]
languages.append("Python")
languages[1] = "JS"
print(languages)
TERMINAL OUTPUT:
_____________________________________________
scores = {"CPU": 100, "P1": 80}
scores["P2"] = 95
scores["P1"] = 110
print(scores["P1"])
Python Trio Presenter Guide
Teacher & Presenter Guide
Python Core Trio Presenter Guide
Page 1 / 2
TOTAL TIME
35 - 40 Mins
AUDIENCE
Complete Beginners
INTERACTIVE STYLE
Peer Discussion
PRACTICE LEVEL
2-Page Workbook
Core Lesson Architecture & Objectives
The purpose of this shareout is to help absolute beginners grasp not just Python syntax, but the underlying concepts of data shapes, mutability, and high-efficiency lookups. Rather than memorizing raw code, focus heavily on the real-world metaphors provided on slides.
Slide-by-Slide Walkthrough (Part 1)
Slide 1-2 Title & Mutability
Hook: Introduce data as something with varying shapes and security properties.
Key Script: "Think of computer memory like physical spaces. Some are whiteboards where you change notes instantly (mutable), others are stone tablets carved permanently (immutable). Why do you think we need both?"
Slide 3 Lists [ ]
Concept: The Shopping Cart. The items can change, grow, or shrink, but the physical bucket is the same.
Key Script: "Notice how items.append() modifies the list directly. The original sequence updates in place without needing us to save it as a new variable."
Slide 4 Tuples ( )
Security & Integrity focus
Concept: GPS coordinates, sensor readings, or RGB color values. You cannot append, pop, or swap items inside a tuple once created.
Script Tip: "Ask the room: 'If I have coordinates of a landing zone on a map, do I want some function down the line to accidentally slip the latitude by 2 degrees? No. That’s why we carve it into a tuple. Attempting to edit a tuple will raise a TypeError immediately, halting bad code before it causes problems.'"
Python Core Trio - Technical Shareout Guide Created for Presenters
Teacher & Presenter Guide
Python Core Trio Presenter Guide
Page 2 / 2
Slide Walkthrough (Part 2)
Slide 5: Dictionaries
Explain why index lookups fail when structures scale. Keys are unique pathways to values. Keep keys immutable (strings, ints).
Slide 7: Summary Matrix
Quick review card. Hand out the printed 2-page workbook at this stage to begin the 10-minute Hands-On practice.
Exercise Answer Keys (Slide 6 & Cheat Sheet Workbook)
Slide 6 - Case Study Solutions:
Python Trio Worksheet Answer Key
Teacher Resource / Grading Guide
Python Trio Worksheet Answer Key
Solutions Sheet
Q1 Solution. Concept of mutability:
Correct Answer: B. The contents can be modified in place.
Explanation: Mutable objects (like lists and dictionaries) allow direct modifications to their values in memory, keeping their physical object ID the same. Immutable objects (like tuples) do not permit this.
Q2 Solution. Syntax markers:
LISTS:
[ ] (Square Brackets)
TUPLES:
( ) (Parentheses)
DICTS:
{ } (Curly Brackets)
Q3 Solution. Trace the Python code output:
Correct Printed Output: ["monitor", "trackpad", "keyboard"]
• Step 1: List is initialized as ["monitor", "mouse"].
• Step 2: .append() adds "keyboard" to the end: ["monitor", "mouse", "keyboard"].
• Step 3: items[1] replaces index 1 ("mouse") with "trackpad".
Q4 Solution. Spot the runtime crash line & explain why:
Crashed Line: Line # 3 (config[1] = 100)
Why it crashes: config is initialized as a Tuple because it uses parentheses (...). Tuples are strictly immutable sequences. Trying to re-assign or modify any elements inside a tuple raises a TypeError.
Q5 Solution. Inventory SKU mapping architecture:
STRUCTURE: Dictionary
SYNTAX: { }
Why: A dictionary is the ultimate choice because it links custom unique string keys (SKUs) directly to stock values. Instead of iterating line-by-line through a list, Python dictionaries retrieve stocks instantaneously using hashing, giving optimal O(1) performance regardless of database size.
Grading Guide Pro-Tips
Award 20 points per question (Total: 100 points). For Q3, ensure students include correct square brackets in their output string, showing they understand the sequence format. For Q4, partial credit (10 points) can be awarded if they spot Line 3 but give a vague explanation of mutability.
Python Core Trio courseware Answer Key Page 1 / 1