ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print([1, 2] < [1, 2, 0], [1, 2] < [1, 3, 0], (1, 2) < (1, 2, 0), 'ab' < 'abc')
- A. True True False True
- B. True False True True
- C. False True True True
- D. True True True True
Correct answer: D. True True True True
Sequences compare element by element, and when one is a prefix of the other the longer one is greater. The second list wins at the second element because 2 < 3.
More Python Programming questions
- What is printed? python print(hex(255), hex(-255), oct(-8), bin(0), int('-ff', 16), int('0xFF', 0))
- What is printed? python print(int('8' 3) % 7, int('8' 3, 16) % 7, pow(10, 3, 7), 888 % 7)
- What is printed? python print(0.1 0.1, 0.1 0.1 == 0.01, round(0.1 0.1, 2) == 0.01, 10 0.1 0.1 10 == 1)
- What is printed? python print(len(str(777)), 777 % 1000, str(777)[-3:], int(str(777)[:3]))
- What is printed? python def rpn(tokens): st = [] for t in tokens: if t in ('+', '-', '', '/'): b = st.pop() a = st.pop() if t == '+'…
- What is printed? python def ceildiv(a, b): return -(-a // b) print(ceildiv(7, 2), ceildiv(-7, 2), ceildiv(6, 3), ceildiv(1, 5))