Computational Thinking, Quiz 1
Let L be a non-empty list of integers, and D be a non-empty dictionary which are given below:
L = [-2, -1, 0, 1, 2]
D = {-2: 'a', 2: 'b', -1: 'c', 1: 'd', 0: 'e'}
Match the following expressions on the left side with the appropriate values on the right side.
a. D['d']
b. keys(D)
c. isKey(D, 'b')
d. last(init(L)) - last(rest(L))
e. first(init(L)) - first(rest(L))
f. first(rest(rest(L)))
Let **L** be a non-empty list of integers, and **D** be a non-empty dictionary which are given below:\ **L** = [-2, -1, 0, 1, 2]\ **D** = {-2: 'a', 2: 'b', -1: 'c', 1: 'd', 0: 'e'} Match the following expressions on the left side with the appropriate values on the right side. a. **D['d']**\ b. **keys(D)**\ c. **isKey(D, 'b')**\ d. **last(init(L)) - last(rest(L))**\ e. **first(init(L)) - first(rest(L))**\ f. **first(rest(rest(L)))** 1. False 2. Invalid key 3. **L** 4. 0 5. -1 6. A list Choose the correct option based on the following pseudocode in the given subquestions. L = [0] LA = [[3, 2, 1], [2, 1], [1]] LB = [ ], LC = [ ] foreach A in LA { foreach B in A { LB = [B] ++ LB L = [first(L) + B] } LC = [LB] ++ LC LB = [ ] } What will be the value of **L** at the end of execution? Choose the correct option based on the following pseudocode in the given subquestions. L = [0] LA = [[3, 2, 1], [2, 1], [1]] LB = [ ], LC = [ ] foreach A in LA { foreach B in A { LB = [B] ++ LB L = [first(L) + B] } LC = [LB] ++ LC LB = [ ] } What will be the value of **LC** at the end of execution?