1.

Python Arithmetic Operators

Answer»

The Arithmetic Operators in the below table are in Lowest to Highest precedence.

OperatorsOperationExplanationExamples
+AdditionReturns sum of 2 numbers1 + 3 = 4
-SubtractionReturns the difference of 2 numbers1 - 3 = -2
*MultiplicationReturns the product of 2 numbers1 * 3 = 3
/DivisionReturns the value of a divided by b as a decimal value1 / 3 = 0.33
//Floored DivisionReturns the floor of a divided by b1 // 3 = 0
%RemainderReturns the remainder when a is divided by b1 % 3 = 1

Some examples are shown below:

#Example for Addition
>>> 1 + 3
4
#Example for Subtraction
>>> 1 - 3
-2
#Example for Multiplication
>>> 6 * 6
36
#Example for Floored Division
>>> 4 // 2
2
#Example for Division
>>> 3 / 2
1.5000
#Example for Modulo
>>> 3 % 2
1


Discussion

No Comment Found