# 1.29 Itse1359-1100-indexing and slicing tuples

 Page 1 / 2
This module and several modules that follow will use sample programs to show you a variety of ways to manipulate and use tuples.

## Preface

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.

## Viewing tip

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 Figures and the Listingswhile you are reading about them.

(Note to blind and visually impaired students: most of the Figures and all of the Listings in this module are presented in plain text format and should be accessible using anaudio screen reader or a braille display.)

## Figures

• Figure 1 . Visualization of a tuple.
• Figure 2 . Output from code in Listing 6.

## Introduction

Previous modules have introduced you to lists, subscriptions, sequences, mutable sequences, mappings, slicings, and have mentioned tuples.

Those modules showed you some of the ways that you can manipulate lists. The discussion was illustrated using sample programs.

The introduction to tuples in previous modules was very brief. This and several future modules will use sample programs to show you a variety of waysto manipulate and use tuples.

## Description of a tuple

As a practical matter, a tuple is like a list whose values cannot be modified. In other words, a tuple is immutable .

According to Lutz and Ascher, Learning Python from O'Reilly, tuples are "Ordered collections of arbitrary objects."

Again according to Lutz and Ascher, "They work exactly like lists, except that tuples can't be changed in place (they're immutable)..."

Unlike lists, however, tuples don't use square brackets for containment. Rather, they are normally written as a sequence of items contained inparentheses.

Like a string or a list, a tuple is a sequence . Like a string (but unlike a list) , a tuple is an immutable sequence.

Tuples can contain other compound objects, including lists, dictionaries, and other tuples. Hence, tuples can be nested.

## An array of references

One way to think of a tuple is to consider it to be an array of references to other objects.

For example, Figure 1 shows a visualization of the tuple from Listing 6 . As you can see, each element in the tuple object at the bottom right contains a reference or apointer to another object.

Figure 1. Visualization of a tuple. While the tuple itself cannot be changed in place, the values contained in the objects that are referred to by the contents of the tuple can be changed (assuming that those objects are mutable) .

hello, I am happy to help!
Abdullahi
find the value of 2x=32
divide by 2 on each side of the equal sign to solve for x
corri
X=16
Michael
Want to review on complex number 1.What are complex number 2.How to solve complex number problems.
Beyan
use the y -intercept and slope to sketch the graph of the equation y=6x
how do we prove the quadratic formular
hello, if you have a question about Algebra 2. I may be able to help. I am an Algebra 2 Teacher
thank you help me with how to prove the quadratic equation
Seidu
may God blessed u for that. Please I want u to help me in sets.
Opoku
what is math number
4
Trista
x-2y+3z=-3 2x-y+z=7 -x+3y-z=6
Need help solving this problem (2/7)^-2
x+2y-z=7
Sidiki
what is the coefficient of -4×
-1
Shedrak
the operation * is x * y =x + y/ 1+(x × y) show if the operation is commutative if x × y is not equal to -1
An investment account was opened with an initial deposit of \$9,600 and earns 7.4% interest, compounded continuously. How much will the account be worth after 15 years?
lim x to infinity e^1-e^-1/log(1+x)
given eccentricity and a point find the equiation
12, 17, 22.... 25th term
12, 17, 22.... 25th term
Akash
A soccer field is a rectangle 130 meters wide and 110 meters long. The coach asks players to run from one corner to the other corner diagonally across. What is that distance, to the nearest tenths place.
Jeannette has \$5 and \$10 bills in her wallet. The number of fives is three more than six times the number of tens. Let t represent the number of tens. Write an expression for the number of fives.
What is the expressiin for seven less than four times the number of nickels
How do i figure this problem out.
how do you translate this in Algebraic Expressions
why surface tension is zero at critical temperature
Shanjida
I think if critical temperature denote high temperature then a liquid stats boils that time the water stats to evaporate so some moles of h2o to up and due to high temp the bonding break they have low density so it can be a reason
s.
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
Got questions? Join the online conversation and get instant answers! By By By By Gerr Zen  By  By By By Anonymous User