Mastering Python Dictionaries Quiz

Mastering Python Dictionaries Quiz

12th Grade

11 Qs

quiz-placeholder

Similar activities

Fun with Paint and Storage

Fun with Paint and Storage

1st Grade - University

10 Qs

Penugasan Daring

Penugasan Daring

11th Grade - University

10 Qs

command prompt

command prompt

4th Grade - Professional Development

15 Qs

Computer Lab Rules

Computer Lab Rules

9th - 12th Grade

13 Qs

IT Quiz

IT Quiz

11th - 12th Grade

10 Qs

Twitter

Twitter

6th Grade - University

6 Qs

Internet Basics

Internet Basics

5th Grade - University

15 Qs

Operating system

Operating system

11th - 12th Grade

10 Qs

Mastering Python Dictionaries Quiz

Mastering Python Dictionaries Quiz

Assessment

Quiz

Computers

12th Grade

Practice Problem

Hard

Created by

Devin Lachapelle

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?