Python Day 9

Python Day 9

University

6 Qs

quiz-placeholder

Similar activities

exceptions in python

exceptions in python

University

7 Qs

Talent Next Java MCQ-1

Talent Next Java MCQ-1

University

10 Qs

Java Exeption

Java Exeption

University

8 Qs

Python

Python

University

9 Qs

Introducción a PL/SQL

Introducción a PL/SQL

University

10 Qs

Programación Orientada a Objetos

Programación Orientada a Objetos

University

10 Qs

APQuiz-G

APQuiz-G

University

7 Qs

Java Quiz 2

Java Quiz 2

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