Variables, Types & Operators · Question 9 · Medium

Unary minus meets the power operator, with and without brackets. What does this print?

print(-3 ** 2, (-3) ** 2)
  1. 9 9
  2. -9 -9
  3. 9 -9
  4. -9 9
Answer and explanation

Answer: D. -9 9

Explanation: ** binds tighter than unary minus, so -3 ** 2 means -(3 ** 2) = -9. With brackets the base is -3, and (-3) ** 2 = 9.

Previous: Floor division and remainder are applied to a negative number. What is the… · Next: How many values in the list vals are treated as true by the if test?

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