Python Dictionary

Python Dictionary

10 Qs

quiz-placeholder

Similar activities

Python Lists and Tuples

Python Lists and Tuples

University

11 Qs

Python Day 9

Python Day 9

University

6 Qs

list in python

list in python

10th - 12th Grade

15 Qs

Python Conditional Statements

Python Conditional Statements

University

8 Qs

Python Dictionary

Python Dictionary

University

10 Qs

Dictionary

Dictionary

11th Grade

14 Qs

DICTIONARIES

DICTIONARIES

11th Grade

8 Qs

Python Quiz 2.0

Python Quiz 2.0

University

14 Qs

Python Dictionary

Python Dictionary

Assessment

Quiz

Computers

Medium

Created by

ASIER SOLUTIONS

Used 33+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is not a valid way to define this dictionary in Python:

d = dict([

('foo', 100),

('bar', 200),

('baz', 300)

])

d = {}

d['foo'] = 100

d['bar'] = 200

d['baz'] = 300

d = dict(foo=100, bar=200, baz=300)

d = {'foo': 100, 'bar': 200, 'baz': 300}

d = { ('foo', 100), ('bar', 200), ('baz', 300) }

2.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Consider this dictionary:


d = {'foo': 100, 'bar': 200, 'baz': 300}


What is the result of this statement:


d['bar':'baz']

It raises an exception

(200, 300)

200 300

[200, 300]

3.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

A Python dictionary stores ...

value - key pairs

key - value pairs

4.

MULTIPLE SELECT QUESTION

30 sec • 1 pt

Which of the following create an empty dictionary (D)?

D = dict()

D = ()

D = []

D = {}

5.

MULTIPLE CHOICE QUESTION

20 sec • 1 pt

Which symbol surrounds a dictionary?
{
(
[
:

6.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Please select all correct ways to empty the following dictionary

student = {

"name": "Emma",

"class": 9,

"marks": 75

}

del student

del student[0:2]

student.clear()

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

________________method will returns number of key-value pairs in the given dictionary.

len( )

pop( )

del( )

keys( )

values( )

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?