ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print('abc' < 'abd', 'Z' < 'a', '10' < '9', [10] < [9], (1, 'b') < (1, 'a'))- A. True False True False False
- B. True True True False False
- C. True True False False False
- D. True True True True False
Correct answer: B. True True True False False
Strings compare by code point, so 'Z' (90) sorts before 'a' (97), and '10' sorts before '9' because '1' comes before '9'. Lists and tuples compare element by element, so [10] < [9] is False, and (1, 'b') < (1, 'a') is False.
More Python Programming questions
- What is printed on the second line? python print(''.join(sorted('banana'))) print(sorted('Banana', key=str.lower)) print(sorted(['b10'…
- What is printed? python print(min([3, 1.0, True]), max([1, True, 1.0]), max([True, 1.0]), min([1.0, True]))
- What is printed? python print(list(range(10, 0, -3)), range(0, 10, 3)[-1], len(range(5, 1)), range(3) == range(0, 3, 1), range(0, 6, 2) ==…
- What is printed? python print(sum(range(106)) == 106 (106 - 1) // 2, 20.5 20.5 == 2.0, 20.5 20.5)
- What is printed? python print(int(2.9999999999999996), float('1e400'), -float('1e400'), 1e308 10 == float('inf'))
- What is printed? python print(10 % 3.5, -10 % 3.5, 10 // 3.5, round(-1.5), round(0.5) + round(1.5))