Arithmetic operators

Arithmetic operators act on numerical values as operands to produce a single numerical result. Arithmetic operators in Python are:

  • Addition (+)
  • Substraction (-)
  • Multiplication (*)
  • Division (/)
  • Modulo or remainder (%)

Examples:

2 + 3
2 + 3 * 4.5
x = 10.5 # Assignment expression
y = 5.2 # Assignment expression
sum = x + y
sub = x - y

The numeric constants (2, 3, 4.5) in addition to x and y variables are operands of the addition, subtraction and multiplication operators.

The modulo or remainder operator finds the remainder of an integer division. Example:

x = 3 % 2
y = 9 % 3
print(x, y)

Will output 1 0 since 2 can go into 3 one time with a remain of 1 and 3 can go into 9 three times with a remainder of 0.