Computer >> Computer tutorials >  >> Programming >> Python

What are different arithmetic operators in Python?


Arithmetic operators in Python are explained below −

+ for addition − performs addition of operands on either side

>>a=5
>>b=7
>>c=a+b
>>c
12

- for subtraction − subtracts second operand from first

>>a=10
>>b=5
>>c=a-b
>>c
5

* for multiplication − multiplies first operand by second

>>a=5
>>b=2
>>c=a*b
>>c
10

/ for division − divides first operand by second

>>a=10
>>b=5
>>c=a/b
>>c
2

% for modulo or remainder − returns remainder of division of first operand by second

>>a=10
>>b=3
>>c=a%b
>>c
1