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 ()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

create a tuple

A

t = (1,2,3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

t = (7,4,5)
len(t) ?

A

3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

create a tuple using two object types

A

t = (‘three’, 4)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

t = (‘three’, 4)
return ‘three’

A

t[0]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

t = (‘six’, 7,5,’four’,’six’)
t
(‘six’, 7, 5, ‘four’, ‘six’)

return 2

A

t.count(‘six’)
2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly