Introduction
In this article, I will explain the basic operators in Python.
Definition
An operator is a symbol which represents some operations that can be performed on data. There are different types of operators in Python. There are:
- Arithmetic operators
- Relational operators
- Logical operators
- Assignment operators
Arithmetic operators
Arithmetic operators are used to perform arithmetic operations.
Syntax
- Variable 1 arithmetic operator variable 2
The arithmetic operators and their meaning are given in the below table:
|
operators
|
operations
|
|
+
|
Addition
|
|
-
|
Subtraction
|
|
*
|
Multiplication
|
|
/
|
Division
|
|
%
|
Modulo division
|
Example
- x = 10
- y = 2
- print(x + y)#Addition
- print(x - y)#Subtraction
- print(x * y)#Multiplication
- print(x / y)#Division
- print(x % y)#Modulo division
Output

Relational operators
Relational operators are used to compare two or more operans. It evaluates whether the given expression is true or false.
|
operators
|
operations
|
|
<
|
is less than
|
|
<=
|
is less than or equal
|
|
>
|
is greater t
|
|
>=
|
is greater than or equal
|
|
==
|
is equal to
|
|
!=
|
is not equal to
|
Syntax
- Variable 1 relational operator variable 2
Example
- x = 20
- y = 10
- print(x == y)# returns False because 20 is not equal to 10
- print(x != y)#returns True because 20 is not equal to 10
- print(x > y)#returns True because 20 is greater than 10
- print(x < y)#returns False because 20 is not less than 10
- print(x >= y)#returns True because 20 is greater, or equal, to 10
- print(x <= y)#returns False because 20 is neither less than or equal to 10




Join the conversation! Your thoughts help the community grow.