Operators in Python
Operators in Python
Operators in
Python
Made By:
Keywords in Python
Keywords in Python are special words that have specific
meanings and purposes within the Python language.
They are reserved and cannot be used as variable
names or identifiers.
Comparison Operators:
Comparison operators in Python are used to compare two
values and return a Boolean value (True or False) based on
the comparison. Common comparison operators include:
Equal to (==): Checks if two operands are equal.
Less than (<): Checks if the left operand is less than the
right operand.
Assignment Operators:
Assignment operators are used to assign values to variables.
They include:
Equal to (=): Assigns the value on the right to the variable
on the left.
Logical Operators:
Logical operators in Python are used to perform logical
operations on Boolean values. The main logical operators
are:
Logical AND (and): Returns True if both operands are
True, otherwise False.
Logical OR (or): Returns True if at least one of the
operands is True, otherwise False.
Bitwise Operators:
Bitwise operators perform operations on individual bits of
binary numbers. Some common bitwise operators in Python
are:
Bitwise AND (&): Performs a bitwise AND operation on the
binary representations of the operands.
Right shift (>>): Shifts the bits of the left operand to the
right by the number of positions specified by the right
operand.
Right shift (>>): Shifts the bits of the left operand to the
right by the number of positions specified by the right
operand.
Membership Operators:
Membership operators are used to test whether a value is a
member of a sequence (e.g., string, list, tuple). They include:
In: Returns True if the value is found in the sequence.
Identity Operators:
Identity operators are used to compare the identity of two
objects. They include:
Is: Returns True if both operands refer to the same object.