Arithmetic operators are used to perform arithmetic operations between two
operands. It includes +(addition), - (subtraction), *(multiplication),
/(divide), %(reminder), //(floor division), and exponent (**).
Consider the following table for a detailed explanation of
arithmetic operators.
Operator
|
Description
|
+
(Addition)
|
It is used to add
two operands. For example, if a = 20, b = 10 => a+b = 30
|
-
(Subtraction)
|
It is used to
subtract the second operand from the first operand. If the first operand is
less than the second operand, the value result negative. For example, if a =
20, b = 10 => a ? b = 10
|
/
(divide)
|
It returns the
quotient after dividing the first operand by the second operand. For example,
if a = 20, b = 10 => a/b = 2
|
*
(Multiplication)
|
It is used to
multiply one operand with the other. For example, if a = 20, b = 10 => a *
b = 200
|
%
(reminder)
|
It returns the
reminder after dividing the first operand by the second operand. For example,
if a = 20, b = 10 => a%b = 0
|
**
(Exponent)
|
It is an exponent
operator represented as it calculates the first operand power to second operand.
|
//
(Floor division)
|
It gives the floor
value of the quotient produced by dividing the two operands.
|
Operator
|
Name
|
Example
|
+
|
Addition
|
x + y
|
-
|
Subtraction
|
x - y
|
*
|
Multiplication
|
x * y
|
/
|
Division
|
x / y
|
%
|
Modulus
|
x % y
|
**
|
Exponentiation
|
x ** y
|
//
|
Floor division
|
x // y
|
0 comments:
Post a Comment