[ ]
List
Click for why you would choose this one
Changeable? Yes, changeable
Access by Position
expressions = ["happy", "sad",
               "angry", "surprised"]
print(expressions[0])
Choose a list when the data will change while the program runs. You can add, remove, or edit items, and the order stays fixed so you can step through them.
( )
Tuple
Click for why you would choose this one
Changeable? No, not changeable
Access by Position
eye_color = (0, 191, 165)
print(eye_color[0])
Choose a tuple when a value must stay exactly as written. Because a tuple cannot be edited, MicroPython stops any later code from changing it by accident.
{ }
Dictionary
Click for why you would choose this one
Changeable? Yes, changeable
Access by Key name
happy_face = {"eye_size": 14,
              "mouth_curve": 20}
print(happy_face["mouth_curve"])
Choose a dictionary when each value deserves a name. You look values up by key instead of counting positions, which keeps named settings readable.

Try a Scenario


Back to Lesson Plan