Page 438 - Computer Science V2.0 Class 11
P. 438
9. What will be the output produced on execution of the following code snippet:
d = {1:'One',2:'Two'}
print(d[1]+d[2])
Ans. OneTwo
10. What will be the output produced on execution of the following code snippet:
d = {1:'One',2:'Two'}
print(sum(d))
Ans. 3
11. What will be the output produced on execution of the following code snippet:
d = {'1':'one', '2':'two'}
s = ''
for x in d:
s = s + x
print(s)
Ans. 12
12. What will be the output produced on execution of the following code snippet:
d = {'1':'one', '2':'two'}
s = ''
for x in d:
s = s + d[x]
print(s)
Ans. onetwo
13. What will be the output produced on execution of the following code snippet:
d = {'1':'One','2':'Two'}
for k,v in d.items():
print(type(k,v))
Ans. An error would occur as k and v are considered two independent objects.
14. What will be the output produced on execution of the following code snippet:
d = {'1':'One','2':'Two'}
for k,v in d.items():
z = k,v
print(type(z))
Ans. <class 'tuple'>
<class 'tuple'>
Assertion and Reasoning Based Questions
The following questions are assertion(A) and reasoning(R) based. Mark the correct choice as
a. Both A and R are true and R is the correct explanation of A
b. Both A and R are true and R is not the correct explanation of A
c. A is true but R is false
d. A is false but R is true
1. Assertion(A): The method pop() deletes the last key-value pair from a dictionary.
Reasoning(R): The method popitem() deletes a key-value pair from a dictionary.
424 Touchpad Computer Science (Ver. 2.0)-XI

