Arithmetic operators

Arithmetic operators are used to perform basic mathematical calculations.

Example

Addition, subtraction, multiplication, division, modulo operations.

Operator Description Example: (a=100,b=10,ans=0)
+ Add to operands ans = a + b;   ans will be 110.
- Subtract operand_2 form operand_1 ans = a - b;   ans will be 90.
* Multipy two operands ans = a * b;   ans will be 1000.
/ divides operand_1 by operand_2 ans = a / b;   ans will be 10.
% Gives the remainder after the actual
division of operands
ans = a % b;   ans will be 0.
Because 10 will perfectly divide 100 so remainder will be zero.
8  %  3  =  2.
5  %  4  =  1.



Arithmetic operators - Sample Program

Example

#Arithmetic Operators in python

num1 = 100
num2 = 10

print("num1 + num2  = ",  num1 + num2)
print("num1 - num2  = ",  num1 - num2)
print("num1 * num2  = ",  num1 * num2)
print("num1 / num2  = ",  num1 / num2)
print("num1 % num2  = ",  num1 % num2)