ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(sorted({'b': 1, 'a': 2}.items()), sum([1, 2, 3], start=10))
  1. A. [('a', 2), ('b', 1)] 6
  2. B. [('b', 1), ('a', 2)] 16
  3. C. [('a', 2), ('b', 1)] 13
  4. D. [('a', 2), ('b', 1)] 16

Correct answer: D. [('a', 2), ('b', 1)] 16

items() gives pairs, and sorted orders them by the key a before b. start=10 adds 10 to the sum of 1, 2 and 3.

More Python Programming questions

Exams that ask this topic