ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

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

Correct answer: B. TrueTrue int

str(True) and str(1 == 1.0) are both 'True', so they concatenate to TrueTrue. Adding two bools gives an int, 2.

More Python Programming questions

Exams that ask this topic