ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(max([('x', 5), ('y', 5)], key=lambda t: t[1]), min([('x', 5), ('y', 5)], key=lambda t: t[1]))- A. ('y', 5) ('y', 5)
- B. ('x', 5) ('y', 5)
- C. ('y', 5) ('x', 5)
- D. ('x', 5) ('x', 5)
Correct answer: D. ('x', 5) ('x', 5)
max() and min() return the first item that reaches the extreme value when there is a tie. Both keys are 5, so both calls return the first tuple, ('x', 5).
More Python Programming questions
- What is printed? python print(sorted([1.0, True, 1, 0.5, False]))
- What is printed? python try: print(int('10')) except ValueError: print('bad')
- What is printed? python print(float('1e400'), -float('1e400'), float('1e308') 10)
- What is printed? python print(int(1e23))
- What is printed? python print('x' 0 == '', 'Z' < 'a', '10' < '9', 'apple' < 'Apple')
- What is printed? python print(len('eu0301'), 'é' == 'eu0301')