Page 429 - CITS - Computer Software Application -TT
P. 429
COMPUTER SOFTWARE APPLICATION - CITS
var x = 5
Here, = is an assignment operator that assigns 5 to x.
3 Python Comparison Operators
Comparison operators compare two values/variables and return a boolean result: True or False.
Example:
a = 5
b =2
print (a > b) # True
4 Python Logical Operators
Logical operators are used to check whether an expression is True or False. They are used in decision-making.
For example,
a = 5
b = 6
print((a > 2) and (b >= 6)) # True
5 Python Bitwise Operators
Bitwise operators act on operands as if they were strings of binary digits. They operate bit by bit, hence the name.
Example:
2 is 10 in binary, and 7 is 111.
6 Identity Operators
Identity operators are used for locating the memory unit of the objects, especially when both objects have the
same name and can be differentiated only using their memory location.
Types of Identity Operators
There are two types of identity operators...
1 Is Operator
2 Is Not Operator
Is Operator
Is operator is used for comparing if the objects are in the same location while returning ‘true’ or ‘false’ values as
a result.
Example:
m = 70
n = 70
if ( m is n ):
print(“Result: m and n have same identity”)
else:
print(“Result: m and n do not have same identity”)
Output: m and n have same identity
Is Not Operator
Is Not operator works in the opposite way of is operator? This returns true if the memory location of two objects
is not the same. This returns False if the memory location of two objects is the same.
416
CITS : IT&ITES - Computer Software Application - Lesson 120 - 137