ProgrammingModerateGATE CS · Product-company placement

What is printed?

What is printed?
scores = [("a", 50), ("b", 80), ("c", 65)]
passed = [n for n, s in scores if s >= 60]
top = max(scores, key=lambda t: t[1])[0]
print(passed, top, dict(scores)["c"])
  1. A. ['b', 'c'] 80 65
  2. B. [80, 65] b 65
  3. C. ['b', 'c'] b 65
  4. D. ['a', 'b', 'c'] b 65

Correct answer: C. ['b', 'c'] b 65

Unpacking each pair into n and s lets the comprehension filter by score and keep the name. max with a key returns the whole tuple, from which [0] picks the name. dict() accepts a list of pairs.

More Python Programming questions

Exams that ask this topic