Tuples Flashcards

1
Q

Difference between Lists and Tuples

A

Each element in a tuple is at least two or more
Elements needs not homognous in a Tuple
The number of elements should be same in a tuple

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

Is this valid?

[(1,2), (2,3,4), (4,5)]

A

No

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

Is this valid?

[(“one”,1), (“two”,2),(“three”,3)]

A

yes

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

Is this valid ? [(1), (2), (3)]

A

NO

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

describe the function fst

A

Given a pair as a tuple, it will return the fist element

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

describe the function snd

A

Given a pair as a tuple, it will return the second element

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

Will the tuple related functions ‘fst’ and ‘snd’ work on a tuple larger than a pair

A

NO

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

Evaluate zip [1,2,3,4,5] [2,3,4]

A

[(1,2),(2,3),(3,4)]

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