Variables, Types & Operators · Question 18 · Hard

Five different operators appear in one expression. Following precedence rules, what value is printed?

print(2 + 3 * 4 ** 2 // 5 % 4)
  1. 3
  2. 1
  3. 5
  4. 11
Answer and explanation

Answer: A. 3

Explanation: ** is evaluated first: 4 ** 2 = 16. Then *, // and % share one level and go left to right: 3 * 16 = 48, 48 // 5 = 9, 9 % 4 = 1. Finally 2 + 1 = 3.

Previous: Floor division by a float and a remainder with a negative divisor are printed… · Next: A float product is compared with 0.3 in two ways. What does this print?

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