Python Arithmetic Operators

Video Tutorial
FREE
Arithmetic Operators thumbnail
This video belongs to
Python Course for Beginners With Certification: Mastering the Essentials
16 modules
Certificate
Topics Covered

Overview

An Arithmetic Operator is a mathematical function that performs a calculation on two operands. The different types of arithmetic operators include addition, subtraction, multiplication, division, modulus, exponentiation and floor division.

Introduction to Python Arithmetic Operators

Imagine you are at a store buying groceries, and there is a big sale. You are standing in the queue, and you quickly pull out your phone to calculate how much discount you are supposed to get. Calculators act as a big lifesaver in real life.

But what runs these calculations?

The answer is simple- Operators!

A calculator can perform simple arithmetic operations for us using operators such as addition, subtraction, multiplication, division, etc. Similarly, in the world of coding, Arithmetic Operators in Python come to our rescue and make our job easier!

Learn more about Calculator Program in Python.

In this article, we will deep-dive everything about Arithmetic Operators in Python and learn how to use them.

Let’s first begin by learning about the different Arithmetic Operators in Python.

Types of Arithmetic Operators in Python

Primarily, Arithmetic Operators in Python are of the following types-

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

Now, let’s take a closer look at them and try to understand them better.

1. Addition

The addition operator in Python is “+”. It is used to add or sum two values.

Let’s see its code implementation-

Code:

Output:

2. Subtraction

Let’s see how it works in Python-

Code:

Output:

3. Multiplication

The Arithmetic Operator in Python for multiplication is “*”. With this operator, we can find the product of two values.

Check out the following code snippet for a better understanding-

Code:

Output:

4. Division

The “/” operator is the division operator in Python. We can find the quotient when the first operand is divided by the second.

Let’s see how we can code it-

Code:

Output:

5. Modulus

The “%” operator is the division operator in Python. Using this, we can find the remainder when the first operand is divided by the second.

Check out this code implementation-

Code:

Output:

6. Exponentiation

The exponentiation operator in Python is denoted by “**”. It is used to raise the power of the first operand to the power of the second.

Let’s see the following code snippet to understand this better-

Code:

Output:

7. Floor Division

It is denoted by “//” in Python. We use it to find the floor of the quotient when the first operand is divided by the second.

Code:

Output:

NameOperatorExample
Addition+a+b
Subtraction-a-b
Multiplication*a*b
Division/a/b
Modulus%a%b
Exponentiation**a**b
Floor Division//a//b

Example to Implement Arithmetic Operators in Python

Let’s look at one comprehensive example of Arithmetic Operators in Python-

Code:

Output:

Check out this article to learn about Format() function in Python.

Explore Scaler Topics Python Tutorial and enhance your Python skills with Reading Tracks and Challenges.

Conclusion

We have now reached the end of the article! Let’s summarize what we have learned so far-

  • We learned what Arithmetic Operators in Python are.
  • We covered the different types of Arithmetic Operators in Python.
  • We saw their code implementations.

Now, you are all set to use Arithmetic Operators in Python on your own. Happy coding!

Learn More: