ARITHMETIC TYPE OPERATORS


Arithmetic type Operators

Arithmetic means manipulation of numbers, and arithmetic operators represent that operators that can manipulate the number in terms of addition, subtraction, multiplication, etc.
Python allows us to manipulate the number by using its arithmetic operators.

Python has seven arithmetic operators for playing with numbers:-

  • Addition - Adds the operanda on both sides of the operator.
  • Subtraction - Subtracts right-hand value from left-hand value.
  • Multiplication - Multiplies the operands on either side of the operator.
  • Division - Divides left-hand by right-hand value.
  • Modulus - Divides left-hand value by right-hand value and returns the remainder.
  • Exponentiation - The value works by exponentiating its value by the number of given times(power).
  • Floor Division - The division of values where the result is the quotient in which the digits after the decimal point are removed. But if one of the values is negative, the result is rounded away from zero (towards negative infinity).

Note:- “ ** ” returns the power of the first value. E.g., x ** y = x raise to the power y.

ADDITIONAL OPERATOR(+)

Adds the operanda on both sides of the operator.

SUBTRACTIONAL OPERATOR(-)

Subtracts right-hand value from left-hand value.

MULTIPLICATIONAL OPERATOR(*)

Multiplies the operands on either side of the operator.

DIVISION OPERATOR(/)

Divides left-hand by right-hand value.

MODULUS OPERATOR(%))

Divides left-hand value by right-hand value and returns the remainder.

EXPONENTIAL OPERATOR(**)

The value works by exponentiating its value by the number of given times(power).

Floor division(//)

The division of values where the result is the quotient in which the digits after the decimal point are removed. But if one of the values is negative, the result is rounded away from zero (towards negative infinity).

Example:

#Addition x = 5 y = 3 print(x + y) #Subtraction x = 5 y = 3 print(x - y) #Multiplication x = 5 y = 3 print(x * y) #Division x = 5 y = 3 print(x / y) #Exponentiation x = 2 y = 5 print(x ** y) #Modulus x = 5 y = 2 print(x % y)

OUTPUT:

True
True
True
False