Home » Arithmetic operators in Python

# Arithmetic operators in Python

Python supports the following types of operators.

Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Identity operators
Membership operators
Bitwise operators

In this article we will look at Arithmetic operators, here are the supported operators

### Arithmetic Operators

 Operator Name Example + Addition a + b – Subtraction a – b * Multiplication a * b / Division b / a % Modulus b % a ** Exponent a**b // Floor division a // b

### Now for a practical example

Type in the following and save it as math.py

```#!/usr/bin/python
​
a = 10
b = 2
c = 0
​
c = a + b
print ("Addition - Value of c is ", c)
​
c = a - b
print ("Subtraction - Value of c is ", c)
​
c = a * b
print ("Multiplication - Value of c is ", c)
​
c = a / b
print ("Division - Value of c is ", c)
​
c = a % b
print ("Modulus- Value of c is ", c)
​
a = 4
b = 5
c = a**b
print ("Exponent- Value of c is ", c)
​
a = 10
b = 5
c = a//b
print ("Floor Division - Value of c is ", c)```

Now open up a command prompt and type in python math.py

All going well you should see something like this 0 comment

#### You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More