Python Day 9

Python Day 9

University

6 Qs

quiz-placeholder

Similar activities

Chapter 3 Exploring Linux Filesystems

Chapter 3 Exploring Linux Filesystems

11th Grade - University

10 Qs

UNIT-1 PYTHON BASICS

UNIT-1 PYTHON BASICS

University

10 Qs

Linkedlist

Linkedlist

University

10 Qs

Virtualisasi UPNVJ

Virtualisasi UPNVJ

University

10 Qs

Programing test

Programing test

1st Grade - University

10 Qs

Pengantar Coding

Pengantar Coding

University

10 Qs

Simple Way To Build Website

Simple Way To Build Website

University

10 Qs

Tree

Tree

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