ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
try:
print([1, 2] < (1, 2))
except TypeError as e:
print(e)- A. '<' not supported between instances of 'list' and 'tuple'
- B. False
- C. True
- D. TypeError
Correct answer: A. '<' not supported between instances of 'list' and 'tuple'
list and tuple do not compare with each other, so < raises TypeError. The message names both operand types in the order the operator was applied.
More Python Programming questions
- What is printed? python print(sum(i for i in range(1, 101) if i % 3 == 0 or i % 5 == 0))
- A solution must answer q = 2 10^5 queries of the form 'how many values in array A are at most x', with A of length n = 2 10^5 that never…
- A program builds a long output string with s = s + str(i) + ' ' for each of n = 2 10^5 values i. Which change is the standard fix for…
- What is printed? python rows = [('bob', 90), ('amy', 90), ('cat', 75)] rows.sort(key=lambda r: (-r[1], r[0])) print([r[0] for r in rows])
- What is printed? python print([1, 2] < [1, 2, 0], (1, 2) < (1, 2, 0), 'abc' < 'abd', [2] < [1, 9])
- What is printed? python x = [1, 2, 3, 4] y = x x = x + [5] x.append(6) y.append(9) print(len(x), len(y), y is x)