Data Types and Operators
in Python
Numbers Sequence Mapping
Integers List Set
Float Numbers Frozen Set
Complex Tuple Dictionary
Range
Boolean
String
Bytes Arrays
None
Operators in Python
Operators in Python
Operators: Special symbols performing
operations. Operations include logical,
mathematical, and more, each operator
corresponds to a specific operation
Operands: Values on which operators
perform operations
Types of Operators in Python
•Arithmetic Operators
•Relational Operators
•Assignment Operators
•Logical Operators
•Membership Operators
•Identity Operators
•Bitwise Operators
Arithmetic Operators
Arithmetic operators are used to performing various
mathematical operations such as addition, subtraction, etc.
Arithmetic Operator Description
Operator Name
+ Addition Performs addition
– Subtraction Performs subtraction
* Multiplicati Performs multiplication
on
/ Division Performs division
% Modulus Returns the remainder after the division
** Exponent Performs exponential (power) calculation
// Floor Divisi Performs division, removes the decimal value, and
on returns the quotient value
Relational Operators
They are also known as comparison operators because they
compare the values on both sides of the operator and
conclude on the relation between the values. After
comparison, it returns the Boolean value, i.e., either true or
false.
Operator Operator Description
Name
== Equal to If values of two operands are equal, then it
returns true.
!= Not Equal to If values of two operands are not equal, then it
returns true.
< Less than If the value of the left operand is less than the
value of the right operand, then it returns true.
> Greater than If the value of the left operand is greater than the
value of the right operand, then it returns true.
<= Less than or If the value of the left operand is less than or
equal to equal to the value of the right operand, then it
returns true.
>= Greater than If the value of the left operand is greater than or
or equal to equal to the value of the right operand, then it
returns true.
<> Not equal to If values of two operands are not equal, then the
(similar to !=) condition becomes true.
Logical Operators
Logical operators are mainly used for conditional
statements. There are three types of logical operators,
namely, AND, OR, and NOT.
Operator Operator Description
Name
and Logical AND When both sides’ conditions are true, the result is
true; otherwise false.
or Logical OR When at least one condition is true, then result is
true; otherwise false.
not Logical NOT Reverse the condition