Operators

0
32

The symbols that trigger the operation / action on data, are called operators. The operations (specific tasks) are represented by Operators and the objects of the operation (s) are referred to as Operands.

Arithmetic Operators

SymbolNameExampleResultComment
+Addition6+5

5+6

11

11

Adds values of its two operands.
Subtraction6-5

5-6

 1

-1

Subtracts the value of right operand from left operand.
*Multiplication5*6

6*5

30

30

Multiplies the values of its two operands.
/Division60/512Divides the value of left operand with the value of right operand and returns the result as a float value.
%Modulus (pronounced mo-du-lo) or Remainder60%5

6%5

0

1

Divides the two operands and gives the remainder resulting.
//Floor division7.2 // 23.0Divides and truncates the fractional part from the result.
**Exponentiation (Power)2.5 ** 315.625Returns base raised to power exponent. (2.53 here).

 

Assignment Operators

Python has an assignment operator = which assigns the value specified on RHS to the variable / object on the LHS of = Python also offers augmented assignment operator.

a =a + b

You may write

a += b

To add value of a to value of b add assign the result to b, you may write

b += b                 #instead of b =b + a

 

Operators in python define operators in python operator in python python operators python operator

LEAVE A REPLY

Please enter your comment!
Please enter your name here