Python Operators

Rabia Sajal Niazi

Writer & Blogger

This section contains the details of different Python operators i.e., Math operators, comparison

operators and Boolean operators.

Arithmetic Operator

Arithmetic operator are used with numerical values to perform common mathematical operations. From Highest to Lowest precedence:

Operators Operation Example
** Exponent 2 ** 3 = 8
% Modulus/Remainder 22 % 8 = 6
// Integer Division 22 // 8 = 2
/ Division 22 / 8 = 2.75
* Multiplication 3 * 3 = 9
Subtration 5 – 2 = 3
+ Addition 2 + 2 = 4

Comparison Operator

Operator Meaning
== Equal to
!= Not equal to
< Less than
> Greater Than
<=  Less than or Equal to
>= Greater than or Equal to

Boolean Operators

There are three Boolean operators: and, or, and not.

The AND Operator’s Truth Table:

Expression Evaluates to
True and True  True
True and False  False
False and True  False
False and False  False

The OR operator’s Truth Table:

Expression Evaluates to
True or True  True
True or False True
False or True True
False or False  False

The NOT Operator’s Truth Table:

Expression Evaluates to
not True False False
not False True True

 

Tweet
Share
Pin
Share
0 Shares
Scroll to Top