Operator in python programming language
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
Recent Posts
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.