MCQ Mojo
access_time
menu
Quiz
Web Stories
CBSE
arrow_drop_down
MCQ Questions for CBSE Class 12 with Answers
MCQ Questions for CBSE Class 11 with Answers
MCQ Questions for CBSE Class 10 with Answers
MCQ Questions for CBSE Class 9 with Answers
MCQ Questions for CBSE Class 8 with Answers
MCQ Questions for CBSE Class 7 with Answers
MCQ Questions for CBSE Class 6 with Answers
MCQ Questions for CBSE Class 5 with Answers
MCQ Questions for CBSE Class 4 with Answers
MCQ Questions for CBSE Class 3 with Answers
MCQ Questions for CBSE Class 2 with Answers
MCQ Questions for CBSE Class 1 with Answers
CBSE
arrow_drop_down
MCQ Questions for CBSE Class 12 with Answers
MCQ Questions for CBSE Class 11 with Answers
MCQ Questions for CBSE Class 10 with Answers
MCQ Questions for CBSE Class 9 with Answers
MCQ Questions for CBSE Class 8 with Answers
MCQ Questions for CBSE Class 7 with Answers
MCQ Questions for CBSE Class 6 with Answers
MCQ Questions for CBSE Class 5 with Answers
MCQ Questions for CBSE Class 4 with Answers
MCQ Questions for CBSE Class 3 with Answers
MCQ Questions for CBSE Class 2 with Answers
MCQ Questions for CBSE Class 1 with Answers
Quiz
Quiz
/
Python Gate & PSU MCQ Questions With Answers
1.
You have the following dictionary definition:d = {'foo': 100, 'bar': 200, 'baz': 300}What method call will delete the entry whose value is 200?
delete d('bar')
d.pop("bar")
d.remove("bar")
None of the above
2.
Which of the following could be a valid dictionary key:
(3+2j)
('foo', 'bar')
'foo'
All Of above
3.
Which of the following is not a valid way to define this dictionary in Python:
d = dict([ ('foo', 100), ('bar', 200), ('baz', 300)])
d = {}d['foo'] = 100d['bar'] = 200d['baz'] = 300
d = dict(foo=100, bar=200, baz=300)
d = {'foo': 100, 'bar': 200, 'baz': 300}
d = { ('foo', 100), ('bar', 200), ('baz', 300) }
4.
Suppose you have a dictionary d1. Which of the following effectively creates a variable d2 which contains a copy of d1:
d2 = dict(d1.items())
d2 = {}d2.update(d1)
d2 = dict(d1)
All Of above
5.
What would be the output of the following code snippet?
'blue''apple''dog'
colorfruitpet
blueappledog
'color''fruit''pet'
6.
Suppose x is defined as follows:x = [ 'a', 'b', { 'foo': 1, 'bar': { 'x' : 10, 'y' : 20, 'z' : 30 }, 'baz': 3 }, 'c', 'd']What is the expression involving x that accesses the value 30?
x[2]["bar"]["z"]
x[2]["bar"]
x["bar"]["z"]
x[2]["bar"]["z"][3]
7.
Consider the following statement:If you just need to work with the keys of a dictionary, then you can use .keys(), which is a method that returns a new view object containing the dictionary’s keys.Is this statement True or False?
False
True
8.
Consider this dictionary:d = {'foo': 100, 'bar': 200, 'baz': 300}What is the result of this statement:d['bar':'baz']
It raises an exception
(200, 300)
200 300
[200, 300]
9.
Which of the following are true of Python dictionaries:
Dictionaries can be nested to any depth.
Dictionaries are accessed by key.
All the keys in a dictionary must be of the same type.
Dictionaries are mutable.
A dictionary can contain any object type except another dictionary.
Report Question
Previous
Next
warning
Submit
access_time
Time
Report Question
A bunch of text
Support mcqmojo.com by disabling your adblocker.
×
Please disable the adBlock and continue.
Thank you.
Reload page