Python Day 9

Python Day 9

University

6 Qs

quiz-placeholder

Similar activities

Java for Geeks and Dummies

Java for Geeks and Dummies

12th Grade - University

10 Qs

Ch3

Ch3

University

6 Qs

Python Basics: External Libraries

Python Basics: External Libraries

University - Professional Development

6 Qs

0xDebug - Python

0xDebug - Python

University

10 Qs

Mini recapitulare - exceptii

Mini recapitulare - exceptii

University

7 Qs

Debugging-Duel-CodeUp'25

Debugging-Duel-CodeUp'25

University

10 Qs

Java Quiz 1

Java Quiz 1

University

10 Qs

Python Conditional Statements

Python Conditional Statements

University

8 Qs

Python Day 9

Python Day 9

Assessment

Quiz

Computers

University

Hard

Created by

Ninitha C

FREE Resource

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