Arithmetic Operators in Python Language

Arithmetic Operators

  1. Addition – ‘+’ – To Sum two or more numbers

>>> x = 56

>>> y = 45

>>> x + y

101

  1. Subtraction – ‘-’ – To Subtract two or more numbers

>>> a = 345

>>> b = 123

>>> a – b

222

  1. Multiplication – ‘*’ – To find the product of two or more numbers

>>> u = 45

>>> v = 3

>>> u * v

135

>>> a * b * u

1909575

  1. Division – ‘/’ – To divide two or more numbers. Answer is always a float.

 >>> people = 6

>>> quantity = 42

>>> quantity / people

7.0

  1. Exponentiation – ‘**’ – To find y raised to power of x or vice versa.

>>> x = 5

>>> y = 2

>>> y ** x

32

>>> x ** y

25

  1. Modulus – ‘%’ – To find the remainder in any division.

>>> x = 22

>>> y = 7

>>> x / y

3.142857142857143

>>> x % y  # Finding the remainder

1

>>> 343 % 4

3

  1. To Find Quotient in Division – ‘//’

>>> 343 / 4 # Division

85.75

>>> 343 % 4 # Remainder

3

>>> 343 // 4 # Quotient

85

Leave a Comment