ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(max('the', 'a', key=len), min(['b', 'B'], key=str.lower), ''.join(sorted('cab')), 'cab'.upper().swapcase())- A. the b abd cab
- B. the b abc cab
- C. the b cba cab
- D. the z abc cab
Correct answer: B. the b abc cab
max by length picks the longest word, the. min by casefold ties b and B, and min keeps the first of equal items, which is b. Sorting the letters gives abc, and swapcase of CAB is cab.
More Python Programming questions
- What is printed? python print(int(str(1020 + 1)[-1]) + len(str(1020)), 1020 + 1 == int(str(1020 + 1)))
- What is printed? python print(divmod(7.5, 2), divmod(-7.5, 2), 7.5 % -2, -7.5 // -2)
- What is printed? python print(-7 % 4, -7 % -4, 7 % -4, (-7) % 4 == -7 % 4)
- What is printed? python def edit(a, b): dp = [[0] (len(b) + 1) for in range(len(a) + 1)] for i in range(len(a) + 1): for j in range(len(b)…
- What is printed? python def lcs(a, b): dp = [[0] (len(b) + 1) for in range(len(a) + 1)] for i in range(1, len(a) + 1): for j in range(1…
- What is printed? python from itertools import accumulate a = [2, -1, 3] P = list(accumulate(a, initial=0)) print(P, P[3] - P[1])