ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(10 == 10.0 and 'a' == 'a', 1 < 2 or 1 / 0)
- A. True False
- B. True True
- C. False True
- D. ZeroDivisionError
Correct answer: B. True True
Both sides of the and are True, so the result is True. The or short-circuits when 1 < 2 is True, so 1 / 0 is never evaluated.
More Python Programming questions
- What is printed? python print(sum(x for x in range(1, 101) if x % 3 == 0 or x % 5 == 0))
- What is printed? python print(int(float(253)) == 253, float(253 + 1) - 253, (253 + 1) - 253)
- What is printed? python print('a'.join('xyz'), 'xyz'.join(['a']), 'ab'.join(['', '']), ','.join(map(str, [1.0, 2])))
- What is printed? python print(round(0.5 3), round(4.5) + round(5.5), int(2.9999999999999996), int(3.0000000000000004))
- What is printed? python print('Python' 0 + 'x', 'Py' + 'thon' 0, len('' 100))
- What is printed? python print(len(str(2100)), str(2100)[-3:], (2100) % 1000)