# Python Arithmetic Operators

Python Arithmetic operators include Addition, Subtraction, Multiplication, Division, Floor Division, Exponent (or Power), and Modulus. All these Python Arithmetic are binary operators, which means they operate on two operands.

The below table shows all the Python Arithmetic Operators with examples.

## Python Arithmetic Operators Example

For this example, we use two variables, a and b, and their values are 12 and 3. We will use these two variables to perform various arithmetic operations with the help of Python operators.

```a = 12
b = 3
subtraction = a-b
multiplication = a*b
division = a / b
modulus = a % b
exponent = a**b
Floor_Division = a // b
print("Subtracting Number 3 from 12 is : ", subtraction)
print("Multiplication of two numbers 12 and 3 is : ", multiplication)
print("Division of two numbers 12 and 3 is : ", division)
print("Modulus of two numbers 12 and 3 is : ", modulus)
print("Exponent of two numbers 12 and 3 is : ", exponent)
print("Floor Division of two numbers 12 and 3 is : ", Floor_Division)```

The following Python statement will find the exponent. It means 12 power 3 = 12 * 12 * 12 = 1728

`exponent = a ** b`

When we use the division ( / ) operator, the result will be a float or decimal value. If you want to display the output as an integer value by rounding the value, then use Floor Division ( // ).

## Arithmetic Operations on Strings

In this Python Arithmetic operators example, we use two variables, a and b, of string data type. Next, we use these two variables to show the problems we generally face while performing arithmetic operations on String Data type.

```a = "Tutorial"
b = "Gateway"
print(a + b)
print(a + " " + b)
print(a * 3)
print((a + " ")* 3)
print(a + 3)
print(a + str(3))```

TIP: Please be careful with brackets. If you misplace it, you will end up with the wrong results.

In this program for Arithmetic operators in python, First, We declared two variables, a and b of string data type, and their values are “Tutorial” and “Gateway”.

```a = "Tutorial"
b = "Gateway"```

It displays the output as “TutorialGateway” because when we use the ‘+’ operator between string variables, the controller concat the two strings.

`print(a+b)`

Inserts the empty space between the words”Tutorial” and “Gateway”. It means the output will be “Tutorial Gateway”.

`print(a+ " " +b)`

Displays Tutorial three times using one of the Python Arithmetic Operators *

`print(a * 3)`

Insert space in between each iteration.

`print((a + " ")* 3)`

It is the interesting part because we are using the ‘+’ symbol between string and integer.

`print(a + 3)`

It will throw an error because it will not implicitly convert integer objects to string objects. To resolve this, we have to convert three explicitly. Be careful while Concating the String and Integers.

Type casting plays a major role in these arithmetic operators.

`print(a + str(3))`