Tuples Chapter 10 Python for Everybody

Tuples Chapter 10 Python for Everybody
1 / 1
Tuples Chapter 10 Python for Everybody - slide 1 of 16 Tuples Chapter 10 Python for Everybody - slide 2 of 16 Tuples Chapter 10 Python for Everybody - slide 3 of 16 Tuples Chapter 10 Python for Everybody - slide 4 of 16 Tuples Chapter 10 Python for Everybody - slide 5 of 16 Tuples Chapter 10 Python for Everybody - slide 6 of 16 Tuples Chapter 10 Python for Everybody - slide 7 of 16 Tuples Chapter 10 Python for Everybody - slide 8 of 16 Tuples Chapter 10 Python for Everybody - slide 9 of 16 Tuples Chapter 10 Python for Everybody - slide 10 of 16 Tuples Chapter 10 Python for Everybody - slide 11 of 16 Tuples Chapter 10 Python for Everybody - slide 12 of 16 Tuples Chapter 10 Python for Everybody - slide 13 of 16 Tuples Chapter 10 Python for Everybody - slide 14 of 16 Tuples Chapter 10 Python for Everybody - slide 15 of 16 Tuples Chapter 10 Python for Everybody - slide 16 of 16
Tuples Chapter 10 Python for Everybody www.py4e.com Tuples Are Like Lists Tuples are another kind of sequence that functions much like a list - they have elements which are indexed starting at 0 x (Glenn, Sally, Joseph)

Related Topics

Download this presentation From Below

"Tuples Chapter 10 Python for Everybody" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentation Transcript

01
Tuples Chapter 10 Python for Everybody
www.py4e.com<br>
02
Tuples Are Like Lists Tuples are another kind of sequence that functions much like a list - they have elements which are indexed starting at 0 >>> x = ('Glenn', 'Sally', 'Joseph')
>>> print(x[2])
Joseph
>>> y = ( 1, 9, 2 )
>>> print(y)
(1, 9, 2)
>>> print(max(y))
9 >>> for iter in y:
... print(iter)
...
1
9
2
>>><br>
03
but... Tuples are “immutable” Unlike a list, once you create a tuple, you cannot alter its contents - similar to a string >>> x = [9, 8, 7]
>>> x[2] = 6
>>> print(x)
>>>[9, 8, 6]
>>> >>> y = 'ABC'
>>> y[2] = 'D'
Traceback:'str' object does
not support item
Assignment
>>> >>> z = (5, 4, 3)
>>> z[2] = 0
Traceback:'tuple' object does
not support item
Assignment
>>><br>