Tuples Flashcards
1
Q
What are tuples
A
Tuples are immutable which means they cannot be changed. They can be used for things like the week or dates on a calender and constructed with parenthesis ()
2
Q
create a tuple
A
t = (1,2,3)
3
Q
t = (7,4,5)
len(t) ?
A
3
4
Q
create a tuple using two object types
A
t = (‘three’, 4)
5
Q
t = (‘three’, 4)
return ‘three’
A
t[0]
6
Q
t = (‘six’, 7,5,’four’,’six’)
t
(‘six’, 7, 5, ‘four’, ‘six’)
return 2
A
t.count(‘six’)
2
7
Q
t = (‘six’, 7, 5, ‘four’, ‘six’)
t
t[0] = ‘change’
what is wrong with this tuple?
A
Tuples are immutable which means they cannot be changed