Question 14
Back to Exercise
What is the output of the following Python program?
print(isinstance(True, int), type(True) == int, True == 1, True + 0.5)
- A True True True 1.5
- B False False True TypeError
- C True False True 1.5 Correct
- D True False False True0.5
Correct Answer: Option C
bool is a subclass of int, so isinstance() is True, but its exact type is bool, so type(True) == int is False. In arithmetic True counts as 1, giving 1.5.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!