Python Arithmetic Operators
Arithmetic operators are used to perform mathematical operations on numeric values.
- Addition
+: Adds two operands. - Subtraction
-: Subtracts the right operand from the left operand. - Multiplication
*: Multiplies two operands. - Division
/: Divides the left operand by the right operand (results in a float). - Floor Division
//: Divides the left operand by the right operand, discarding the remainder. - Modulus
%: Returns the remainder of the division of the left operand by the right operand. - Exponent
**: Raises the left operand to the power of the right operand.
Comparison Operators
Comparison operators are used to compare values and return True or False.
- Equal
==: Returns True if the operands are equal. - Not Equal
!=: Returns True if the operands are not equal. - Greater Than
>: Returns True if the left operand is greater than the right operand. - Less Than
<: Returns True if the left operand is less than the right operand. - Greater Than or Equal To
>=: Returns True if the left operand is greater than or equal to the right operand. - Less Than or Equal To
<=: Returns True if the left operand is less than or equal to the right operand.
Logical Operators
Logical operators are used to combine and manipulate boolean values.
- Logical AND
and: Returns True if both operands are True.
Logical OR or: Returns True if at least one operand is True.
Logical NOT not: Returns True if the operand is False, and vice versa.
Assignment Operators
Assignment operators are used to assign values to variables.
- Assignment
=: Assigns the value on the right to the variable on the left
Add and Assign +=: Adds the right operand to the left operand and assigns the result to the left operand.
Subtract and Assign -=: Subtracts the right operand from the left operand and assigns the result to the left operand.
Multiply and Assign *=: Multiplies the left operand by the right operand and assigns the result to the left operand.
Divide and Assign /=: Divides the left operand by the right operand and assigns the result to the left operand.
Membership Operators
Membership operators are used to test whether a value is a member of a sequence.
in: Returns True if a value is found in the sequence.
not in: Returns True if a value is not found in the sequence.
Identity Operators
Identity operators are used to compare the memory locations of two objects.
is: Returns True if both operands refer to the same object.
is not: Returns True if both operands do not refer to the same object.


