ExamVeda
Login
Home
41
What will be the output of the following Python code?
>>> a=dict()
>>> a[1]
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
42
What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}
a.setdefault(4,"D")
print(a)
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
43
What will be the output of the following Python code?
a={1:5,2:3,3:4}
print(a.pop(4,9))
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
44
What will be the output of the following Python code snippet?
>>> import collections
>>> a=collections.Counter([3,3,4,5])
>>> b=collections.Counter([3,4,4,5,5,5])
>>> a&b
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
45
What will be the output of the following Python code snippet?
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 > d2
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
46
What will be the output of the following Python code snippet?
>>>import collections
>>> b=collections.Counter([2,2,3,4,4,4])
>>> b.most_common(1)
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
47
Suppose d = {"john":40, "peter":45}. To obtain the number of entries in dictionary which command do we use?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
48
The following Python code is invalid.
class demo(dict):
  def __test__(self,key):
    return []
a = demo()
a['test'] = 7
print(a)
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
49
What will be the output of the following Python code?
a={}
a[2]=1
a[1]=[2,3,4]
print(a[1][1])
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
50
What will be the output of the following Python code?
>>> import collections
>>> a=dict()
>>> a=collections.defaultdict(str)
>>> a['A']
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board