Test Index

CBSE Class 12 Computer Science 2025 Paper Compartment Get it on Google PlayDownload on the App Store

© examsnet.com
Question : 23 of 37
Marks: +1, -0
Give an example of each of the following :
(i) An expression using any one identity operator.
(ii) An arithmetic expression which uses any one augmented assignment operator.
Solution:  
(i) Identity operators (is, is not) check whether two names refer to the same object in memory.
L1 = [1, 2]
L2 = L1
print(L1 is L2) # True (same object)
print(L1 is not [1, 2]) # True (a different object with equal value)
(ii) An augmented assignment operator (+=, -=, *=, /=, //=, %=, **=) combines an arithmetic operation with assignment.
n = 10
n += 5 # same as n = n + 5
print(n) # 15
© examsnet.com
Advertisements
Go to Question: