
Python Dictionaries
Quiz
•
Computers
•
University
•
Practice Problem
•
Hard
Ilyas Ustun
Used 5+ times
FREE Resource
Enhance your content in a minute
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a dictionary in Python?
A collection of ordered items
A mapping from keys to values
A sequence of characters
A type of loop
Answer explanation
A dictionary in Python is a data structure that stores data as key-value pairs, making it a mapping from keys to values. This allows for efficient data retrieval and organization, distinguishing it from ordered collections or sequences.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a correct way to create an empty dictionary?
numbers = ()
numbers = []
numbers = ''
numbers = {}
Answer explanation
The correct way to create an empty dictionary in Python is using curly braces: numbers = {}. The other options create different data types: () is a tuple, [] is a list, and '' is a string.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of len({'zero': 0, 'one': 1, 'two': 2})?
1
0
2
3
Answer explanation
The function len() returns the number of key-value pairs in a dictionary. The given dictionary {'zero': 0, 'one': 1, 'two': 2} has three pairs: 'zero', 'one', and 'two'. Therefore, the output is 3.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which operator is used to check if a key exists in a dictionary?
!=
not in
==
in
Answer explanation
The 'in' operator is used to check if a key exists in a dictionary. It returns True if the key is found, making it the correct choice for this question.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result of numbers.get('three', 0) if 'three' is not a key in the dictionary?
KeyError
None
3
0
Answer explanation
The method numbers.get('three', 0) returns the second argument (0) when 'three' is not a key in the dictionary. Therefore, the result is 0.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the method values() do in a dictionary?
Returns a list of keys
Returns a list of values
Deletes a key-value pair
Adds a new key-value pair
Answer explanation
The method values() in a dictionary returns a list of all the values stored in the dictionary. Therefore, the correct answer is 'Returns a list of values', as it specifically retrieves the values associated with the keys.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the result of the expression:
'one' in {'zero': 0, 'one': 1, 'two': 2}
None
True
KeyError
False
Answer explanation
The expression checks if 'one' is a key in the given dictionary. Since 'one' is indeed a key in {'zero': 0, 'one': 1, 'two': 2}, the result is True.
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
11 questions
Determining System Requirements
Quiz
•
University
15 questions
1.1.1 The structure and function of the processor
Quiz
•
11th Grade - University
10 questions
Google Apps
Quiz
•
10th Grade - Professi...
18 questions
CIS2303 Week 4_5 Ch_3
Quiz
•
University
20 questions
Software Engineering Quiz 1
Quiz
•
University
10 questions
Machine Learning (Introduction)
Quiz
•
University
20 questions
INTERNET
Quiz
•
University
10 questions
Entorno Financiero Digital 2do test
Quiz
•
University
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
15 questions
4:3 Model Multiplication of Decimals by Whole Numbers
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
The Best Christmas Pageant Ever Chapters 1 & 2
Quiz
•
4th Grade
12 questions
Unit 4 Review Day
Quiz
•
3rd Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
Discover more resources for Computers
26 questions
Christmas Movie Trivia
Lesson
•
8th Grade - Professio...
7 questions
Different Types of Energy
Interactive video
•
4th Grade - University
20 questions
Slopes and Slope-Intercept Form
Quiz
•
8th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
7 questions
Biomolecules (Updated)
Interactive video
•
11th Grade - University
20 questions
Winter/Holiday Trivia
Quiz
•
KG - University
10 questions
WINTER WIN Time - ELA - 12/9/2025
Quiz
•
KG - University
7 questions
Human Impact on Resources
Interactive video
•
4th Grade - University
