Python Day 9

Python Day 9

University

6 Qs

quiz-placeholder

Similar activities

Summer Code Camp - Lesson 1

Summer Code Camp - Lesson 1

University

10 Qs

Software Testing

Software Testing

University

10 Qs

EC335 - Quiz 1

EC335 - Quiz 1

University

10 Qs

Manajemen Proyek TI

Manajemen Proyek TI

University

10 Qs

Hệ Điều Hành Của Máy Tính

Hệ Điều Hành Của Máy Tính

10th Grade - University

10 Qs

Tutorium1

Tutorium1

University

10 Qs

Node.js

Node.js

University

10 Qs

Penyelenggaraan Pencegahan Sistem Operasi

Penyelenggaraan Pencegahan Sistem Operasi

University

10 Qs

Python Day 9

Python Day 9

Assessment

Quiz

Computers

University

Practice Problem

Hard

Created by

Ninitha C

FREE Resource

AI

Enhance your content in a minute

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

6 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What would be the output of the following code snippet? a_dict = {'color': 'blue', 'fruit': 'apple', 'pet': 'dog'} for key in a_dict: print(key)

'blue' 'apple' 'dog'
color fruit pet
blue apple dog
color' 'fruit' 'pet'

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

You have the following dictionary definition: d = {'foo': 100, 'bar': 200, 'baz': 300} What method call will delete the entry whose value is 200?

delete d('bar')
d.pop("bar")
d.remove("bar")
None of the above

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Dictionary keys must be immutable

True
False

4.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

Suppose d = {“john”:40, “peter”:45}, what happens when we try to retrieve a value using the expression d[“susan”]?

Since “susan” is not a value in the set, Python raises a KeyError exception
It is executed fine and no exception is raised, and it returns None
Since “susan” is not a key in the set, Python raises a KeyError exception
Since “susan” is not a key in the set, Python raises a syntax error

5.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

Media Image

Ouput?

None
KeyError Exception
-1

6.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

Which of the following statements create a dictionary?

d = {}
d = {“john”:40, “peter”:45}
d = {40:”john”, 45:”peter”}
All of the mentioned

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?

Discover more resources for Computers