QuizSpace

Python week 7 important questions

Week 7 of Programming in Python: Collections: dicts, sets. Extra important questions based on the recent, changing patterns of the exams, from basic to advanced. Practise them in learning mode: each question has a worked solution.

Question 1

One correct option

What is printed by the following program?

d = {'Imran': 14, 'Dev': 74, 'Zoya': 45, 'Kiran': 30}
print(d["Nobody"])
  1. A

    4

  2. B

    KeyError

  3. C

    None

  4. D

    14

Question 2

One correct option

What will be the output of the code below?

d = {'Zoya': 29, 'Nila': 42, 'Kiran': 61, 'Meena': 93}
d["Zoya"] = d["Zoya"] + 5
d["Zed"] = 1
print(d["Zoya"], len(d))
  1. A

    34 4

  2. B

    KeyError

  3. C

    34 5

  4. D

    35 5

Question 3

One correct option

Consider the program given below. What does it print?

d = {'Imran': 67, 'Ravi': 88, 'Nila': 73, 'Asha': 26}
d["Imran"] = d["Imran"] + 5
d["Zed"] = 1
print(d["Imran"], len(d))
  1. A

    72 4

  2. B

    72 5

  3. C

    73 5

  4. D

    KeyError

More questions in this week

Authorise with Google to see every question with its answer and explanation and practise it in learning mode.

IMPPractise OPPE 1 PYQs:PythonSystem CommandsJava