In Python, you can subtract two numbers using the -
operator. Here's an example:
main.py32 chars5 lines
Output: 5
In this example, we first define two variables a
and b
and set them to the values 10
and 5
, respectively. We then use the -
operator to subtract b
from a
and store the result in a new variable c
. Finally, we print the value of c
, which is 5
.
Alternatively, you can directly subtract two numbers without using any variables, like this:
main.py26 chars2 lines
In this example, we directly subtract 5
from 10
using the -
operator and print the result, which is 5
.
gistlibby LogSnag