Lists keep items in order and change freely; tuples are their frozen cousins — same order, no edits.
1 Lists Grow
append(x) adds to the end, and len(nums) always knows the size.
2 Zero-Based Index
The first element is nums[0]; the last is nums[len(nums) - 1].
3 End-Exclusive Slices
nums[1:3] takes indexes 1 and 2 — the end index is never included.
4 Tuples Freeze
(3, 1, 4) is a tuple: indexable and sliceable, but no append and no edits — ever.
Ordered collections
Lists Grow1append(x) adds to the end, and len(nums) always knows the size. Zero-Based Index2The first element is nums[0]; the last is nums[len(nums) - 1].
End-Exclusive Slices3nums[1:3] takes indexes 1 and 2 — the end index is never included.
Tuples Freeze4(3, 1, 4) is a tuple: indexable and sliceable, but no append and no edits — ever.
4 building blocks make up Ordered collections
Watch the list grow with append, then get indexed and sliced — memory shows the full list at every step.
mainnums starts life as an empty list — zero elements so far.
Console
output appears as the program runs…
Python lists are ordered slots. Play the script to watch one grow — then drag to orbit the view.
Drag to orbit the scene. Press Play to watch memory in action.
Click a term, then click what it does to a list or tuple.
5 conceptsTap a card to expand ?nums.append(x)drops into place
?nums[1:3]drops into place
?(3, 1, 4)drops into place
?nums[0]drops into place
?len(nums)drops into place
One immutable tuple, one growing list — what comes out?
Your predicted output — one line per console line
Hint: A tuple is immutable but still indexable — rgb[0] is its first value. Unpacking r, g, b = rgb copies the three values into names.
01Index 0 is the first element; the last valid index is len - 1.
02Slices stop BEFORE their end: nums[1:3] gives indexes 1 and 2.
03append(x) grows a list in place; assignment replaces one slot.
04A tuple is a read-only list: index and slice it, but never edit it.
05Unpacking r, g, b = rgb copies tuple values into three names.