Variables, Types & Operators · Question 16 · Hard

Booleans are used in arithmetic here. What does the snippet print?

print(True + True * 2, isinstance(True, int))
  1. 4 True
  2. 3 True
  3. 3 False
  4. TypeError
Answer and explanation

Answer: B. 3 True

Explanation: bool is a subclass of int, with True equal to 1, so isinstance(True, int) is True. Multiplication comes first: True * 2 = 2, then True + 2 = 3.

Previous: Which statement about the operators == and is is correct? · Next: Floor division by a float and a remainder with a negative divisor are printed…

Practise variables, types & operators

Try a fresh set of variables, types & operators questions with an explanation after every answer, free and without signing up: Variables, Types & Operators practice. Or sit a full placement mock test.

More variables, types & operators questions

More python practice

Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge