<< Chapter < Page | Chapter >> Page > |
This module is one in a collection of modules on Python designed for teaching ITSE 1359 Introduction to Scripting Languages: Python at Austin Community College in Austin, TX.
I recommend that you open another copy of this module in a separate browser window and use the following links to easily find and view the Figuresand Listings while you are reading about them.
(Note to blind and visually impaired students: most of the Figures and all of the Listings inthis module are presented in plain text format and should be accessible using an audio screen reader or a braille display.)
This module is part of a series of modules designed to teach you about tuples.
Earlier modules have illustrated
This module will teach you about unpacking tuples.
A tuple is an immutable ordered list of objects. It can contain references to any type of object. See earlier modules in this series for a more detaileddescription.
Listing 4 presents a Python program that:
Figure 4 shows the output produced by the program in Listing 4 .
Figure 5 shows a visualization of the tuples in the program after the first five statements in the code block have been executed.This is a case where you need to step through the program and observe changes in the diagram on the right to appreciate the behavior of the program.
I will explain this program in fragments. Listing 1 shows the beginning of the program.
Listing 1 . Beginning of the program. |
---|
# Illustrates unpacking a tuple
#------------------------------# Create a pair of tuples
t1 = 1,2t2 = "A","B"
# Concatenate and print themt3 = t1 + t2
print(t3) |
Notification Switch
Would you like to follow the 'Itse 1359 introduction to scripting languages: python' conversation and receive update notifications?