ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
d = {'a': 1, 'b': 2}
print(d.popitem(), d)- A. ('a', 1) {'b': 2}
- B. ('b', 2) {'a': 1, 'b': 2}
- C. ('b', 2) {'a': 1}
- D. ('a', 1) {'a': 1, 'b': 2}
Correct answer: C. ('b', 2) {'a': 1}
popitem removes and returns the last inserted pair, b, before d is printed, so the printed dict no longer contains b.
More Python Programming questions
- What is printed? python print('{0}{1}{0}'.format('x', 'y'))
- What is printed? python print(list(filter(None, [0, '', [], [0], None])))
- What is printed? python print([i for i in range(10) if i % 3 == 0][::-2])
- What is printed? python print(set('mississippi') == set('misp'), len(set('mississippi')))
- What is printed? python print(0.1 3 == 0.3, abs(0.1 3 - 0.3) < 1e-9)
- What is printed? python a = [1, 2, 3] print(a[3:], a[1:10], a[-10:1])