PCEP-30-02 practice question 22 of 35
Which of the following statements is false?
Full set: 548 questionsDomain Computer Programming and Python Fundamentals
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, //.
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.
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.
Keep practicing
Take the free PCEP-30-02 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other PCEP-30-02 practice questions
- Question 1The following list is given:
- Question 2What is the output of the following code? num = 10 while num >= 0: num -= 2 print(num)
- Question 4We need to check if at least one element of the iterable object evaluates to the truth. W…
- Question 5This question is a tricky one. What is the result of the following code snippet? numbers …
- Question 8What is the purpose of the continue statement in Python?
- Question 11We need to check if all elements of the iterable object evaluate to the truth. What built…
