Google News
logo
Python Program to Subtraction Operator
In the following example of Python program that demonstrates the use of the subtraction operator `-` :
Program :
# Subtraction operator example
a = 10
b = 5
result = a - b

print("The difference between", a, "and", b, "is", result)


In the above program, we first assign the integer values `10` and `5` to the variables `a` and `b`, respectively. We then use the subtraction operator `-` to subtract `b` from `a`, and assign the result to the variable `result`.

Finally, we use the `print()` function to print a message that displays the values of `a`, `b`, and `result`, as well as a message indicating that `result` is the difference between `a` and `b`.

When we run the program, it will output the following message :

Output :
The difference between 10 and 5 is 5
As you can see, the program correctly subtracts `b` from `a` using the subtraction operator `-`, and displays the result using the `print()` function.