Mastering Python Dictionaries Quiz

Mastering Python Dictionaries Quiz

12th Grade

11 Qs

quiz-placeholder

Similar activities

Python Dictionary Quiz

Python Dictionary Quiz

9th - 12th Grade

10 Qs

PCEP Section 1C: Understanding Data Types and Variables

PCEP Section 1C: Understanding Data Types and Variables

12th Grade

15 Qs

AQA GCSE Databases and SQL

AQA GCSE Databases and SQL

9th - 12th Grade

14 Qs

Python Turtle

Python Turtle

KG - Professional Development

11 Qs

Dictionary in Python

Dictionary in Python

7th - 12th Grade

10 Qs

Visual Basic Basics!

Visual Basic Basics!

9th - 12th Grade

8 Qs

Day 7 Practice on Dictionaries

Day 7 Practice on Dictionaries

12th Grade

14 Qs

Python: списки, кортеж, словник, множина

Python: списки, кортеж, словник, множина

9th - 12th Grade

14 Qs

Mastering Python Dictionaries Quiz

Mastering Python Dictionaries Quiz

Assessment

Quiz

Computers

12th Grade

Hard

Created by

Devin Lachapelle

FREE Resource

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()`

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?