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
2
Q
Is this valid?
[(1,2), (2,3,4), (4,5)]
A
No
3
Q
Is this valid?
[(“one”,1), (“two”,2),(“three”,3)]
A
yes
4
Q
Is this valid ? [(1), (2), (3)]
A
NO
5
Q
describe the function fst
A
Given a pair as a tuple, it will return the fist element
6
Q
describe the function snd
A
Given a pair as a tuple, it will return the second element
7
Q
Will the tuple related functions ‘fst’ and ‘snd’ work on a tuple larger than a pair
A
NO
8
Q
Evaluate zip [1,2,3,4,5] [2,3,4]
A
[(1,2),(2,3),(3,4)]