PCEP-30-02 · Question #71
Which of the following statements is false?
The correct answer is D. The result of the / operator is always an integer value. Option D is false because in Python, the / operator performs true division and always returns a float, even when both operands are integers - 4 / 2 yields 2.0, not 2. If an integer result is needed, Python provides the floor division operator // instead. Options A, B, and C are…
Question
Options
- AThe right argument of the % operator can not be zero.
- BThe ** operator has right-to-left associativity.
- CMultiplication precedes addition.
- DThe result of the / operator is always an integer value.
How the community answered
(62 responses)- A6% (4)
- B3% (2)
- C13% (8)
- D77% (48)
Explanation
Option D is false because in Python, the / operator performs true division and always returns a float, even when both operands are integers - 4 / 2 yields 2.0, not 2. If an integer result is needed, Python provides the floor division operator // instead. Options A, B, and C are all true: the % (modulo) operator requires a non-zero right operand or it raises a ZeroDivisionError; ** is right-associative so 2**3**2 evaluates as 2**(3**2) = 512; and multiplication does indeed take precedence over addition per standard operator precedence rules. Memory tip: Remember "slash gives decimals" - Python 3's / never truncates, so if you see a claim that / "always returns an integer," that's always the false statement.
Community Discussion
No community discussion yet for this question.