RisingCoder Full course โ†’
Day 1Day 2Day 3Day 4
๐Ÿ”’
STUDENT NOTES ยท DAY 12 OF 24

Locked Boxes & the No-Repeats Club ๐Ÿ”’

Two special containers: the tuple (a list that can NEVER change) and the set (a club that refuses duplicates).

1Tuples โ€” sealed at birth

๐Ÿ
Py: Round brackets make a tuple. Read it, loop it, index it โ€” but change it? Never. Perfect for things that must stay fixed, like GPS coordinates.
๐Ÿž
Bugly: Try to edit oneโ€ฆ hehehe:

2The one-item tuple trap

๐Ÿฆ‰
Professor Hoot: (5) is just the number 5 wearing brackets. The COMMA makes the tuple: (5,). Tiny comma, big difference.

3Sets โ€” the no-duplicates club

๐Ÿค–
Bittu: I check membership in a set at lightning speed โ€” in is my favourite word.

4Set tricks

5Quick quiz! ๐Ÿง 

t = (1, 2, 3); t[0] = 9 โ€” what happens?
๐Ÿ’ก Tuples are immutable. Once made, forever sealed.
What is len({1, 2, 2, 3, 3, 3})?
๐Ÿ’ก The set bounces duplicates at the door: only {1, 2, 3} get in.

6Your mission ๐Ÿš€

Mission 1: Store your birthday as a tuple (day, month, year). Try changing it โ€” read the error like a pro.
Mission 2: Make a set from the list [1,2,2,3,3,3,4] and print how many UNIQUE numbers there are.
Mission 3: Use set("your own name") to find your unique letters!

Day 12 done โ€” halfway through the course! ๐ŸŽ‰

Next: files โ€” teach your programs to REMEMBER after they close.

Go to Day 13: Files โ†’

๐ŸŽฎ Or test yourself in the Python Arcade โ†’