Grokking Python Fundamentals
Ask Author
Back to course home

0% completed

Vote For New Content
Quiz
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

What will be the output of the following code?
my_dict = {'name': 'John', 'age': 30}
print(my_dict['age'])
A
John
B
{'name': 'John', 'age': 30}
C
30
D
'age'
What will the following code snippet return?
data = {'key1': 100, 'key2': 200, 'key3': 300}
print(data.get('key4', 'Not Found'))
A
300
B
'Not Found'
C
KeyError
D
None
Which of the following statements about Python dictionaries is NOT true?
A
Dictionaries can be nested within other dictionaries.
B
Dictionaries maintain elements in the order they were added as of Python 3.7.
C
All dictionary keys must be of the same type.
D
Dictionaries are mutable.
What will the output of the following code?
settings = {'theme': 'dark', 'language': 'English'}
key_exists = 'theme' in settings
print(key_exists)
A
True
B
False
C
KeyError
D
None
What Python method is used to iterate over the keys and values in a dictionary simultaneously?
A
keys()
B
values()
C
items()
D
pairs()
What is the result of merging two dictionaries using the update() method?
dict1 = {'a': 1, 'b': 2}
dict2 = {'b': 3, 'c': 4}
dict1.update(dict2)
print(dict1)
A
{'a': 1, 'b': 2}
B
{'a': 1, 'b': 3, 'c': 4}
C
{'b': 3, 'c': 4}
D
ValueError

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible