Python-Operators-A-Comprehensive-Overview
Python-Operators-A-Comprehensive-Overview
Comprehensive Overview
Python operators are symbols that perform operations on values
and variables. This presentation provides a clear understanding of
different operators in Python. We'll cover arithmetic, comparison,
logical, and other essential types. Get ready to unlock the power of
Python's operators!
by Kushan Musku
Arithmetic Operators
+: Addition
-: Subtraction
*: Multiplication
/: Division
//: Floor Division
%: Modulus
**: Exponentiation
Arithmetic operators perform mathematical calculations. They return numerical results based on the input values.
Understand how to use these for basic and complex computations.
Comparison Operators
Operator Description
== Equal to
!= Not equal to
Logical operators combine conditional statements. They are used to make complex decisions in your code. They
always return a boolean result: True or False.
Bitwise Operators
&: Bitwise AND
|: Bitwise OR
^: Bitwise XOR
~: Bitwise NOT
<<: Left Shift
>>: Right Shift
Bitwise operators perform operations on bits. They are used for low-level programming and manipulation. Bitwise
operations can be highly efficient.
Assignment Operators
=: Assign value
Assignment operators assign values to variables. Combined assignment operators provide a shorthand way to
update variables. This makes your code cleaner and more concise.
Membership Operators
in: Returns True if a sequence with the specified value is present
in the object.
not in: Returns True if a sequence with the specified value is not
present in the object.
Identity operators compare the memory locations of two objects. They check if the variables refer to the same
object. This differs from the equality operator (==), which compares values.