Python Operators
Table of Contents
Python Operators
Description
In Python, operators are special symbols, characters, or keywords used to perform operations on values and variables, known as operands. The value that the operator acts on is called the operand. For example, in the expression a + b, the + is the operator that performs addition, while a and b are the operands.
Python includes a rich set of operators, which are categorized into several groups such as arithmetic, comparison, logical, assignment, bitwise, and membership operators. These are fundamental building blocks for writing expressions and controlling the flow of a program.
Examples
Arithmetic Operators
+(Addition):x + y-(Subtraction):x - y*(Multiplication):x * y/(Division):x / y%(Modulus):x % y**(Exponentiation):x ** y//(Floor Division):x // y
Comparison Operators
==(Equal):x =y=!=(Not equal):x!y=>(Greater than):x > y<(Less than):x < y>=(Greater than or equal to):x >y=<=(Less than or equal to):x <y=
Logical Operators
and(Logical AND):x < 5 and x < 10or(Logical OR):x < 5 or x < 4not(Logical NOT):not(x < 5 and x < 10)