Python 3.2The video for this lesson is on its way.
Everything else is ready: study the parts, the key terms and the quiz below.
Python 3.2Code walkthrough8 parts
Tuples
Use fixed-size immutable records, and unpack them.
Loading your progress…Next: 3.3 Sets
In this lesson8 parts
- 01A pair of values that should not change
- 02Creating and reading a tuple
- 03What immutable means
- 04The comma makes the tuple
- 05Packing and unpacking
- 06Unpacking in a for loop
- 07A tuple that holds a list
- 08Recap, your challenge, and next
Key terms
The words this lesson introduces, each in one line. The module’s glossary collects them all.
- immutable
- An object that can not be changed after it is created: a tuple, a string, a number.
- packing
- Collecting several values, separated by commas, into one tuple:
point = 12.9716, 77.5946. - tuple
- An ordered sequence of values, written with commas, that can not be changed:
(12.9716, 77.5946). - unpacking
- Binding each item of a sequence to its own name, in order:
lat, lon = point.
Quiz 5 questions
Your first pick on each question is the one that counts, and a right one earns a coin. Getting one wrong here is how the lesson sticks.
Practice
Problems to solve in your own notebook. Each states the problem, not the steps: working out the steps is the exercise. Level A applies the lesson, B combines it with earlier ones, C stretches it.
The self-checking notebook for this lesson is Notebook 1 · Lists and Tuples.
Common mistakes
What you will see when it goes wrong, why it happens, and the fix.
Where it’s used
Where this lesson’s ideas turn up in real work.