top of page

Python Operators

With the help of Python Operators we can perform operations on values and variables. There are various types of operators we are going to discuss in this section.

Arithmetic Operators

Arithmetic operators are used to perform some sort of numerical calculations.

+
Addition
It is use for addition of variables.
-
Subtraction
It is use to get the difference of two variables.
*
Multiplication
It is use to get the product of variables.
/
Division
It is use for the divide the two variables and get the quotient.
//
Floor Division
It is use to get the integer part of the quotient.
%
Modulus
It is use to get the remainder.
**
Expotential
It is use to get the power or raise to values.

Comparison Operators

Comparison operators are used to compare the two values or variables and return the boolean value (True or False).

==
Equals
If two values are equal than it will return true.
!=
Not Equal
If two values are not equal than it will return true.
<
less than
if first value is less than second value than it will return true
<=
less than or equal to
if first value is less than or equal to second value than it will return true
>
Greater than
if first value is greater than second value than it will return true
>=
Greater than or equal to
if first value is greater than or equal to second value than it will return true

Logical Operators

Logical operators are used to combine the conditions together and check the outcome.

and
AND Operator
Return True only if all the present values are True.
or
OR Operator
Return True if any one value is True out of all values present.
not
NOT Operator
Return the opposite value. if the value is True than it will return False

Membership Operators

Membership operators are used to check the particular value is present in a given collection or not.

in
IN Operator
It will Return True if the particular value is present in the given collection
not in
NOT IN Operator
It will Return True if the particular value is not present in a given collection.
bottom of page