ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(10**18 * 10 // 10**18 == 10, type(10**18 / 10**18))
- A. False <class 'int'>
- B. True <class 'int'>
- C. False <class 'float'>
- D. True <class 'float'>
Correct answer: D. True <class 'float'>
The // and * operators run before ==, so the left side is 10 and the comparison is True. The / operator always gives a float, even when both operands are equal ints.
More Python Programming questions
- What is printed? python print(round(1.005, 2), round(0.285, 2), round(1.45, 1))
- What is printed? python print('abcdef'[4:1:-2], 'abc'[::-2], 'abc'[-5:], 'abc'[5:] == '')
- What is printed? python import cmath print((-1) 0.5 == 1j, -1 0.5, (-1) 0.5)
- What is printed? python print((-7) % 3, 7 % -3, (-7) % -3, -7 % 3 2)
- What is printed? python print(-6 & 0xFF, -6 | 3, -6 ^ -3, ~-6 >> 1)
- What is printed? python print(len('ab' 3 0 + 'c'), ('%5.2f' % 3.14159).strip(), '%-5s|' % 'ab', '%05d' % -42)