ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(str(True) + str(1 == 1.0), type(True + True).__name__)
- A. True True int
- B. TrueTrue int
- C. TrueTrue bool
- 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
- What is printed? python print(round(-0.5), round(0.5), round(1.5), round(-1.5))
- What is printed? python import bisect print(bisect.bisectright([1, 2, 2, 3], 2, lo=2))
- What is printed? python print(2 3 0, (2 3) 0)
- What is printed? python print(7 & 3 | 4 ^ 1)
- What is printed? python print(5 <= 5 < 6 != 7, 1 < 2 > 3)
- What is printed? python print(len('') or 'empty', [] or 'none')