ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print('a' * 3 < 'b', 'a' * 3 < 'aa', 'aaa' > 'aab', 'aa' + 'b' > 'aab')- A. True False False False
- B. True True False False
- C. False False True False
- D. True False True False
Correct answer: A. True False False False
Strings compare character by character, so aaa is less than b. aaa is less than aa only if it is shorter, which it is not, and aaa is less than aab because its third character is smaller.
More Python Programming questions
- What is printed? python x = 5 print(x // 2 2 == x, x / 2 2 == x, 5 / 2 == 2.5, 5 // 2.0 == 2)
- What is printed? python print(bytes('é', 'utf-8'), 'é'.encode('latin-1'), len('é'.encode('latin-1')) == len('é'.encode('utf-8')))
- What is printed? python print(round(-0.5), round(0.5), round(1.5), round(-1.5), round(2.5))
- What is printed? python x = [3, 1, 2] print(sorted(x, reverse=True)[:2], x[::-1][1:], list(reversed(sorted(x))))
- What is printed? python print('%08.2f' % -1.5, '%+08d' % 42, '%-+5d|' % 7, '%x' % -255)
- What is printed? python print(2 10 == 1024, 2 10 == 1 << 10, 10 2 3, (10 2) 3)