Table of Contents

Python Operators

  • An operator is a symbol that tells the computer to perform certain mathematical or logical manipulation on data stored in variables. The variables that are operated are termed operands.
  • operators can be classified into a number of categories.
    • Arithmetic operators
    • Assignment operators
    • Comparison operators
    • Logical operators
    • Identity operators
    • Membership operators
    • Bitwise operators

Arithmetic operators

Python provides all the basic arithmetic operators. There are five arithmetic operators in python.
Name Purpose
+ Addition
Substation
* Multiplication
/ Division
% Modules (Remainder after integer division)
** Exponentiation
// Floor division
Example

Addition of two number

x = 8
y = 3

print(x + y)
Output
11
Example

Substation of two number

x = 8
y = 3

print(x - y)
Output
5
Example

Multiplication of two number

x = 8
y = 3

print(x * y)
Output
24
Example

Division of two number

x = 8
y = 3

print(x / y)
Output
2.66666666666665
Example

Modules of two number

x = 8
y = 3

print(x % y)
Output
2
Example

Exponentiation of two number

x = 8
y = 3

print(x ** y)
Output
512
Example

Floor division of two number

x = 8
y = 3

print(x // y)
Output
2