ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(max('bca'), min('bca', key=lambda c: (c, -ord(c))))- A. c a
- B. c c
- C. b a
- D. a c
Correct answer: A. c a
max of the characters is 'c'. The key (c, -ord(c)) is the character itself, so min is 'a'. The second element of the key only breaks ties, and there are none here.
More Python Programming questions
- What is printed? python from collections import deque d = deque([1, 2, 3]) d.extendleft([4, 5]) print(list(d))
- What is printed? python x = 'abc' print(x.replace('', '-'))
- What is printed? python try: 'abc'.split('') except ValueError as e: print(e)
- What is printed? python a = [1, 2, 3] for x in a: a.remove(x) print(a)
- What is printed? python print(10 -2, 10 2.0, 10 // 3.0)
- What is printed? python print(all([]), any([]), all(x > 0 for x in [1, 0]))