ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print([0] * 3 == [0, 0, 0], [[]] * 2 == [[], []])
- A. True False
- B. False True
- C. True True
- D. False False
Correct answer: C. True True
Equality of lists compares their items, so a repeated list has the same contents as the explicit one. The inner empty lists are equal too.
More Python Programming questions
- What is printed? python print(len([x for x in range(100) if x % 7 == 0]), sum(range(0, 100, 7)))
- What is printed? python print(round(-2.5), round(-3.5), round(-2.5 - 1e-9))
- What is printed? python print(7 -1 7, (7 -1) 7 == 1.0)
- What is printed? python print(int('0o777', 8) == 511, int('777', 8) - int('0o777', 0))
- What is printed? python print(len('%d' % -0), '%d' % -0.0, '%.1f' % -0.0)
- What is printed? python print(max('abc', 'abd', key=lambda s: s[::-1]), min('ba', 'ab', key=len))