Basic Arithmetic in Python

Arithmetic in Python

Arithmetic operators:

  • Addition: +

  • Subtraction: -

  • Multiplication: *

  • Division: /

  • Modulus operator (to get remainder): %

num1 = 3
num2 = 10

answer = num1/num2
print(answer)
# returns 0.3 <-- which is float data type

Modulus:

print(10 % 3)
# retunrs 1 - i.e Remainder

# As opposed to division
print(10 / 3)
# returns 0.3

Order of operations:

print(10 + 3 * 9 - 4) 
# returns 33

Multiplication first, then subtraction then addition

Last updated