Arithmetic operators in Python With Example

Generally, Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, divison and more.

+ Addition a + b = 10
Subtraction a – b = -10
* Multiplication a * b = 20
/ Division b / a = 10
% Modulus (Divides and returns remainder) b % a = 0
** Exponent 10 ** 3
Result: 1000
// Floor Division (Division that results into whole number adjusted to the left in the number line. The result of this division is the integral part of the result) >>> 10 // 3
3 >>> 10.0 // 3
3.0 >>>

Let’s take an example, b=10,c =0

a = 21
b = 10
c = 0

c = a + b
print “Result of c is “, c

c = a – b
print “Result of c is “, c

c = a * b
print “Result of c is “, c

c = a / b
print “Result of c is “, c

c = a % b
print “Result of c is “, c

a = 2
b = 3
c = a**b
print “Result of c is “, c

a = 10
b = 5
c = a//b
print “Result of c is “, c

Produces the following result −

Result of c is 31
Result of c is 11
Result of c is 210
Result of c is 2
Result of c is 1
Result of c is 8
Result of c is 2

Leave a Reply

Your email address will not be published. Required fields are marked *