PCEP-30-02 practice question 22 of 35

Which of the following statements is false?

Full set: 548 questions

Domain Computer Programming and Python Fundamentals

Answer options
A: The result of the / operator is always an integer value. Correct answer
B: The ** operator has right-to-left associativity.
C: The right argument of the % operator can not be zero.
D: Multiplication precedes addition.
Correct Answer:
A. The result of the / operator is always an integer value.
Explanation

The statement that the result of the / operator is always an integer value is false. In Python 3, the / operator performs "true division," which always yields a float as its result, even if the division results in a whole number. For example, the expression 4 / 2 evaluates to 2.0, not 2. The operator that performs integer division, which results in an integer by truncating the decimal part, is the floor division operator, //.

Why Incorrect

B. The exponentiation operator () is unique among binary arithmetic operators in Python for having right-to-left associativity, meaning 2 3 2 is evaluated as 2 (3 2).
C. The modulo (%) and division (/, //) operators require a non-zero divisor. Attempting an operation like x % 0 will raise a ZeroDivisionError exception.
D. Python adheres to the standard mathematical order of operations, where multiplication and division have higher precedence than addition and subtraction.

References

1. Official Python 3 Documentation, The Python Language Reference, Section 6.7. Binary arithmetic operations: This section explicitly states, "The / (division) and // (floor division) operators yield the quotient of their arguments... Division of integers yields a float." It also confirms that a ZeroDivisionError is raised for /, //, and % with a zero divisor.

2. Official Python 3 Documentation, The Python Language Reference, Section 6.17. Operator precedence: The table in this section shows that the operator has right-to-left associativity. It also lists the precedence levels, confirming that (multiplication) is evaluated before + (addition).

3. MIT OpenCourseWare, 6.0001 Introduction to Computer Science and Programming in Python, Fall 2016, Lecture 2 Notes: The section on "Operators on ints and floats" details the behavior of arithmetic operators. It specifies: "i/j -> float division" and "i//j -> integer division". This confirms that / produces a float.

Scroll to Top