What does the '-' operator do in Python?

Prepare for the WGU C859 Python Test with quiz questions and explanations. Study with clarity on coding concepts and exam format. Ace your exam!

The '-' operator in Python is specifically used for subtraction. When you apply this operator between two numbers, it computes the difference by subtracting the right operand from the left operand. For instance, if you have the expression 7 - 3, the result will be 4, as it subtracts 3 from 7.

In the context of the other options, addition is performed using the '+' operator, while concatenation, which combines strings, also does not utilize the '-' operator but instead employs the '+' operator. Division is executed by the '/' operator, so it's important to recognize that each of these operators serves a distinct function in Python, with the '-' operator being exclusively for subtraction.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy