What is the result of 17 % 5 in Python?
The modulo operator returns the remainder after integer division, so 17 % 5 evaluates to 2 because 5 divides into 17 three times (15) with 2 left over. This satisfies the stem's requirement for the exact result of the expression, matching Python's behaviour for positive integers.
Why this answer
In Python, the % operator performs modulo division, returning the remainder after integer division. 17 divided by 5 equals 3 with a remainder of 2 (since 5 * 3 = 15, and 17 - 15 = 2), so 17 % 5 evaluates to 2.
Exam trap
Python Institute often tests the distinction between the modulo operator (%) and floor division (//), trapping candidates who confuse the remainder with the quotient.
How to eliminate wrong answers
Option B (4) is wrong because it incorrectly assumes the result is the quotient minus 1, or confuses modulo with floor division (17 // 5 = 3). Option C (3) is wrong because it represents the integer quotient (17 // 5), not the remainder. Option D (1) is wrong because it might come from mistakenly subtracting 5 twice (17 - 5 - 5 = 7, then 7 - 5 = 2, not 1) or from a miscalculation of the remainder.