ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(max(['abc', 'x', 'yz'], key=len), min(['b', 'B', 'a']))
- A. abc a
- B. x B
- C. abc B
- D. yz B
Correct answer: C. abc B
max with key=len picks the longest string, abc. For plain min, uppercase letters have smaller code points than lowercase ones, so 'B' (66) is less than 'a' (97) and 'b' (98).
More Python Programming questions
- What is printed? python from decimal import Decimal from fractions import Fraction print(0.1 + 0.2 == 0.3, Decimal('0.1') + Decimal('0.2')…
- What is printed? python print(1e22, 1e21, 1e16, 1e15, 1e-5, 0.0001)
- What is printed? python print(int(1e16 + 1), 253 + 1 == float(253 + 1), float(253 + 1) == 253)
- What is printed? python print(pow(10, 18, 7), (-3) 3 % 7, pow(-3, 3, -7), -3 3 % 7)
- What is printed? python print('%.3s|%5.1s|' % ('abcdef', 'xyz'))
- What is printed? python print('straße'.casefold() == 'strasse', 'straße'.lower() == 'strasse', 'Straße'.casefold())