ProgrammingHardTCS NQT · Accenture

What is printed?

What is printed?
print(type(True + 1).__name__, type(2 * 1.0).__name__)
  1. A. int float
  2. B. bool float
  3. C. int int
  4. D. float float

Correct answer: A. int float

True behaves as the int 1 in arithmetic, so True + 1 is an int, and an int times a float is a float.

More Python Programming questions

Exams that ask this topic