Python Dictionaries Quiz

Python Dictionaries Quiz

10th Grade

15 Qs

quiz-placeholder

Similar activities

ERDs and DFDs

ERDs and DFDs

9th - 12th Grade

15 Qs

Python List, and String

Python List, and String

10th Grade - University

20 Qs

Grade 11 Final Exam

Grade 11 Final Exam

9th - 11th Grade

20 Qs

UH 1 SIMDIG

UH 1 SIMDIG

10th Grade

20 Qs

The Rise of Intelligent Machines

The Rise of Intelligent Machines

8th Grade - University

18 Qs

Staff CPD Internet Safety and AI Quizizz

Staff CPD Internet Safety and AI Quizizz

10th Grade

10 Qs

Shree

Shree

KG - University

13 Qs

Dasar Kompetensi Keahlian IPv6

Dasar Kompetensi Keahlian IPv6

10th Grade

15 Qs

Python Dictionaries Quiz

Python Dictionaries Quiz

Assessment

Quiz

Computers

10th Grade

Practice Problem

Hard

Created by

Mick Kilpatrick

Used 2+ times

FREE Resource

AI

Enhance your content in a minute

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

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct syntax to create an empty dictionary in Python?

`empty_dict = []`

`empty_dict = {}`

`empty_dict = ()`

`empty_dict = set()`

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you add a key-value pair to a dictionary in Python?

`dict[key] = value`

`dict.add(key, value)`

`dict.append(key, value)`

`dict.insert(key, value)`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method is used to remove a key-value pair from a dictionary?

`dict.remove(key)`

`dict.pop(key)`

`dict.delete(key)`

`dict.discard(key)`

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you check if a key exists in a dictionary?

`key in dict`

`dict.has_key(key)`

`dict.contains(key)`

`key.exists(dict)`

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will `len(dict)` return when `dict = {'a': 1, 'b': 2, 'c': 3}`?

`1`

`2`

`3`

`4`

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method returns a list of all the keys in a dictionary?

`dict.keys()`

`dict.values()`

`dict.items()`

`dict.get_keys()`

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the `dict.get(key, default)` method do?

Returns the value for `key` if `key` is in the dictionary, else `default`

Removes the `key` from the dictionary

Adds `default` to the dictionary if `key` is not found

Updates the value of `key` to `default`

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?