SCRIPTING-AND-PROGRAMMING-FOUNDATIONS practice question 7 of 25

Which operation should be used to check if the difference of two values is greater than 1?

Full set: 137 questions
Answer options
A: Multiplication
B: Subtraction Correct answer
C: Addition
D: Division
Correct Answer:
B. Subtraction
Explanation

The question asks to check for the "difference of two values." The mathematical operation used to find the difference between two numbers is subtraction. After performing the subtraction, the result can then be compared to see if it is greater than 1. For example, to check if the difference between x and y is greater than 1, you would compute x - y and then evaluate if the result is > 1.

Why Incorrect

A. Multiplication is used to find the product of two values, not their difference.
C. Addition is used to find the sum of two values, not their difference.
D. Division is used to find the quotient of two values, not their difference.

References

1. Python Software Foundation. Python 3.12.3 Documentation, "The Python Tutorial," Section 3.1.1. Numbers. This section lists - as the operator for subtraction.

2. Guttag, J. V. (2021). Introduction to Computation and Programming Using Python (3rd ed.). MIT Press. Chapter 2, "Objects, Expressions, and Numerical Types," introduces basic arithmetic operators, defining subtraction for calculating differences.

3. University of California, Berkeley. CS 61A: Structure and Interpretation of Computer Programs, "Expressions." The course materials define arithmetic operators, including subtraction for finding the difference between numbers.

Scroll to Top