Different Types Operators in Python
Operators
There are various types of Operators,
- Arithmetic Operator
- Logical Operator
- Relational Operator
- Assignment Operator
- Bitwise Operator
- Conditional Operator
- Membership Operator
- Identity Operator
Arithmetic Operator
An arithmetic operator is a mathematical operator that takes two operands and performs
a calculation on them. They are used for simple arithmetic calculations. Some Basic Arithmetic Operators are +, -, *, /,and //.
Logical Operator or Boolean operator
Logical operators are used to performing logical operations on the given
relational expressions. Python supports three Logical operators. It is also called a Boolean Operator as well.
- logical AND
- logical or
- logical Not
Relational or Comparison Operators
Relational Operators are also known as comparison operators. It compares the two values. if the comparison is correct, it returns True otherwise False. Some comparison operators are ==, !=, >, <, >=, and <=.
Assignment Operator
= is a simple assignment operator to assign values to variables. Some assignment operator are =, +=, -=, /=, *=, //=, and %=. This operator is used to assign a value to variables that is assume the variables are the boxes and values are some things. you put your things in a box. It is the work of assignment operators.
Bitwise Operators
Bitwise Operators perform operations at the bit level. These operators include bitwise AND, bitwise OR, bitwise NOT, and bitwise XOR.
Conditional Operator
The ternary operator is also known as a conditional operator that evaluates something based
on a condition being true or false. The Syntax conditional operator is,
- Variable Name = [on_true] if [Test expression] else [on_false]
Example :
min= 10 if 49<50 else 5 Output : 10
Membership Operators
Python provides two membership operators, This operator is used to check the given value is present or not in searching values. It returns the values in True or False.
- in
- not in
Identity Operator
Python provides two Identity Operators, This operator is the same as the membership operator but the only difference is Identity operator compares the memory locations of two objects. It also returns values in either True or False.
- is
- is not
My Previous Post
Basic concepts of Python Programming: https://iterathon.tech//basic-concepts-of-python-programming/
LEARN LITTLE BY LITTLE TO CHANGE THE TECH WORLD