ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(sorted({'b': 1, 'a': 2}.items()), sum([1, 2, 3], start=10))- A. [('a', 2), ('b', 1)] 6
- B. [('b', 1), ('a', 2)] 16
- C. [('a', 2), ('b', 1)] 13
- 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
- What is printed? python print(max(3, 7, key=lambda v: -v), min('a', 'B'))
- What is printed? python print(str(True) + str(1 == 1.0), type(True + True).name)
- What is printed? python print(round(-0.5), round(0.5), round(1.5), round(-1.5))
- What is printed? python import bisect print(bisect.bisectright([1, 2, 2, 3], 2, lo=2))
- What is printed? python print(2 3 0, (2 3) 0)
- What is printed? python print(7 & 3 | 4 ^ 1)