Sequences of Data
CS 110
Sequences: Why are they useful?
2
New Data Type (class): Tuple
tuple_of_strings = ("first year", "sophomore", "junior", "senior")�
4
New Data Type: Tuple
tuple_of_strings = ("first year", "sophomore", "junior", "senior")�
5
New Data Type: Tuple
tuple_of_strings = ("first year", "sophomore", "junior", "senior")�
6
Tuples: The Rules
A tuple is an immutable sequence of values:�
empty_tuple = ()
tuple_of_strings = ("first year", "sophomore", "junior", "senior")
7
What's the deal with…
immutability?
Data Types: Lists and Tuples
A list is a mutable sequence of values:�
empty_list = []
list_of_strings = ["first year", "sophomore", "junior", "senior"]
A tuple is an immutable sequence of values:�
empty_tuple = ()
tuple_of_strings = ("first year", "sophomore", "junior", "senior")
9
Lists: The Rules
A list is a mutable sequence of values:�
empty_list = []
list_of_strings = ["first year", "sophomore", "junior", "senior"]
Challenge Problem (03_quote_of_the_day.py)
See the file for details! (solution in the solutions folder)