ProgrammingVery hardTCS NQT · Accenture
What is printed?
What is printed?
print(sorted(['B', 'a', 'C'], key=str.casefold) == ['a', 'B', 'C'], sorted(['B', 'a', 'C']) == ['B', 'C', 'a'], min('Bb'), max('aB'))- A. True False B B
- B. True True B B
- C. False True a a
- D. True True B a
Correct answer: D. True True B a
casefold sorts a, B, C as letters, and default sorting puts uppercase letters before lowercase ones, so B and C come before a. min('Bb') compares B with b, which is B, and max('aB') is a.
More Python Programming questions
- What is printed? python print(int('1000') + int('01'), '1000'.replace('', '') == '1000', float('10.50'), '%.1f' % float('10.50'))
- What is printed? python print(round(-1234.5, -2), round(123456.0, -3), round(0.0, 2), round(1e-7, 7))
- What is printed? python print(str(1.0), str(1), str(1.0e0), str(10.0 0), repr(1e0))
- What is printed? python print(7 & ~1, 7 >> 1 << 1, (7 | 8) & 12, 6 ^ 3 ^ 3)
- What is printed? python print(sorted([(-1, 'a'), (1, 'b'), (-1, 'c')], key=lambda t: t[0], reverse=True))
- What is printed? python x = 'abc' y = x.upper() z = x.upper().lower() print(y, z == x, x.upper().upper() == y, len(y + z))