Table of Contents
Operator in python programming language
Python programming language provides many types of operator for arithmetic calculations and operations.
Arithmetic operators
Arithmetic operators are used to perform mathematical calculations or operations.
Example for arithmetic operators
program 1
Comparison operators
Comparison operators are used to compare values. It either returns true or false values only according to the given condition.
Example 1
Logical operators
The logical operator are used in conditional statements that are true or false. The logical operator in Python are AND or OR or NOT
There are three logical operators available in python
Example 1
AND operator
Output
(‘a and a:’, True)
(‘a and b:’, False)
(‘b and b:’, False)
Example 2
OR operator
Output
a or a: True
a or b: True
b or b: False
Example 3
NOT operator
Output
not a: False
not b: True
Bitwise operators
Program 1
Output
value of x&y 18
value of x|y 63
value of x^y 45
value of ~y -19
value of x<<2 -19
value of x>>2 -19
Assignment operators
Assignment operators are used in python to assign values to the variable
Program 1
Output
value of a=x+y : 42
value of a+=y : 52
value of a*=y : 520
value of a/=y : 52
value of a%=y : 2
value of a**=y : 1024
value of a**=y : 102
Similar post