Section 3D: Collect and process data using dictionaries

Section 3D: Collect and process data using dictionaries

12th Grade

15 Qs

quiz-placeholder

Similar activities

Python Intermediate Quiz (Including pygame)

Python Intermediate Quiz (Including pygame)

3rd - 12th Grade

20 Qs

Quiz1_HPB2021_2010t1

Quiz1_HPB2021_2010t1

1st - 12th Grade

10 Qs

Python Basics

Python Basics

12th Grade

20 Qs

Python

Python

12th Grade

20 Qs

Dictionary in Python

Dictionary in Python

10th - 12th Grade

20 Qs

Problem Solving using Python and R - UNIT II - Dictionary

Problem Solving using Python and R - UNIT II - Dictionary

12th Grade

15 Qs

Day 7 Practice on Dictionaries

Day 7 Practice on Dictionaries

12th Grade

14 Qs

PCEP Section 4C: Python Built-In Exceptions Hierarchy

PCEP Section 4C: Python Built-In Exceptions Hierarchy

12th Grade

15 Qs

Section 3D: Collect and process data using dictionaries

Section 3D: Collect and process data using dictionaries

Assessment

Quiz

Computers

12th Grade

Medium

Created by

Misti McDaniel

Used 5+ times

FREE Resource

15 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?

`my_dict = []`

`my_dict = {}`

`my_dict = ()`

`my_dict = set()`

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? ```python my_dict = {'a': 1, 'b': 2} print(my_dict['b']) ```

`'b'`

`1`

`2`

`KeyError`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method would you use to get a list of all the keys in a dictionary?

`values()`

`items()`

`keys()`

`get()`

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you add a new key-value pair to an existing dictionary called `d` with key `'x'` and value `10`?

`d.add('x', 10)`

`d['x'] = 10`

`d.append('x', 10)`

`d.insert('x', 10)`

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements will remove the key `'age'` from the dictionary `person`?

`person.remove('age')`

`del person['age']`

`person.popitem('age')`

`person.clear('age')`

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Given the dictionary `d = {'a': 1, 'b': 2, 'c': 3}`, which code will check if the key `'b'` exists in `d`?

`'b' in d`

`d.has_key('b')`

`'b' == d`

`d['b'] == None`

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method returns a view object that displays a list of a dictionary's key-value tuple pairs?

`keys()`

`values()`

`items()`

`pairs()`

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?