ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(10**18 * 10 // 10**18 == 10, type(10**18 / 10**18))
  1. A. False <class 'int'>
  2. B. True <class 'int'>
  3. C. False <class 'float'>
  4. 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

Exams that ask this topic