
Mastering Python Dictionaries Quiz
Quiz
•
Computers
•
12th Grade
•
Practice Problem
•
Hard
Devin Lachapelle
FREE Resource
Enhance your content in a minute
11 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is the correct way to create an empty dictionary in Python?
empty_dict = []
empty_dict = {}
empty_dict = ()
empty_dict = set()
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given the dictionary student = {"name": "Alice", "age": 18}, how would you access the value associated with the key "name"?
student["name"]
student.name
student{"name"}
student
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you add a new key-value pair "grade": "A" to the dictionary student = {"name": "Alice", "age": 18}?
student.add("grade", "A")
student["grade"] = "A"
student.create({"grade": "A"})
student + "grade":"A"
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code?
student = {"name": "Alice", "age": 18}
print(student["grade"])
None
"A"
KeyError
0
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the result of the following code? ```python student = {"name": "Alice", "age": 18} student["age"] = 19 print(student) ```
`{"name": "Alice", "age": 18}`
`{"name": "Alice", "age": 19}`
`{"name": "Alice", "age": 18, "age": 19}`
`Error`
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code? ```python student = {"name": "Alice", "age": 18} for key, value in student.items(): print(key, value) ```
`name Alice age 18`
`("name", "Alice") ("age", 18)`
`name: Alice, age: 18`
`name Alice \n age 18`
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you get a list of all values in a dictionary `student = {"name": "Alice", "age": 18}`?
`student.values()`
`list(student)`
`student.keys()`
`student.items()`
Access all questions and much more by creating a free account
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
13 questions
Arrays in Swift
Quiz
•
10th - 12th Grade
14 questions
LA5.C5: Branching and Subroutines
Quiz
•
9th Grade - University
10 questions
INTRODUCCION A LA PROGRAMACION
Quiz
•
6th Grade - University
10 questions
Cybersecurity Fundamentals Week 2 Quiz
Quiz
•
KG - University
13 questions
Stepwise Refinement
Quiz
•
11th - 12th Grade
15 questions
IS 225 Quiz #2.1
Quiz
•
12th Grade
13 questions
Copyrights and Wrongs Assessment
Quiz
•
9th - 12th Grade
12 questions
UTS Semester 1 Informatika 2024/2025
Quiz
•
8th Grade - University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
