Back to Network AutomationPython fundamentals

Python Arithmetic Operators

Use Python arithmetic operators to perform calculations such as addition, subtraction, multiplication, and division.

BeginnerArithmeticCalculationsPython

Python Arithmetic Operators at a Glance

Arithmetic operators are one of the Python operator families. They combine numeric values in an expression and return a calculated result.

Basic calculations

Use +, -, *, and / for everyday arithmetic.

Remainders and powers

Use % to find a remainder and ** to raise a value to a power.

Whole-number quotient

Use // when you need division rounded down to the closest integer value.

In This Lesson

  1. Addition
  2. Subtraction
  3. Multiplication
  4. Division
  5. Modulus
  6. Exponentiation
  7. Floor Division
  8. Conclusion

1. Arithmetic Operator Cheat Sheet

Use this visual reference to connect each arithmetic symbol with its purpose, expression, and result.

Python arithmetic operators cheat sheet covering addition, subtraction, multiplication, division, modulus, exponentiation, and floor division with examples
Python's seven arithmetic operators with a short example of each calculation.

2. Addition

We can add two or more numbers together:

Python interpreter

>>> 1 + 1
2

3. Subtraction

Subtract one value from another:

Python interpreter

>>> 5 - 1
4

4. Multiplication

We can also multiply two values:

Python interpreter

>>> 4 * 4
16

5. Division

Use the forward slash to divide one number by another:

Python interpreter

>>> 9 / 3
3.0
Result type: In Python 3, regular division returns a floating-point value even when the quotient is a whole number.

6. Modulus

We can calculate the remainder of a division:

Python interpreter

>>> 11 % 3
2

7. Exponentiation

Exponential calculations are also possible:

Python interpreter

>>> 2 ** 8
256

8. Floor Division

Floor division returns a result rounded down to the closest integer value:

Python interpreter

>>> 16 // 3
5

9. Conclusion

You have now learned how to perform calculations in Python with arithmetic operators:

  • Addition: Add two or more numbers together.
  • Subtraction: Subtract numbers.
  • Multiplication: Multiply two or more numbers.
  • Division: Divide two numbers.
  • Modulus: Calculate the remainder of a division.
  • Exponentiation: Perform an exponentiation calculation.
  • Floor Division: Return a result rounded down to the closest integer value.

I hope you enjoyed this lesson. If you have any questions, feel free to leave a comment.

Python Arithmetic Operators Frequently Asked Questions

What are Python arithmetic operators?

They are symbols that perform numeric calculations such as addition, subtraction, multiplication, division, remainder, exponentiation, and floor division.

What is the difference between division and floor division?

The / operator returns a floating-point quotient. The // operator rounds the quotient down to the nearest integer value.

What does the modulus operator do?

The % operator returns the remainder after division. For example, 11 % 3 returns 2.