0
0
Pythonprogramming~20 mins

Identity operators (is, is not) in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Identity Operator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of identity comparison with small integers
What is the output of this code snippet?
Python
a = 256
b = 256
print(a is b)
ATrue
BFalse
CSyntaxError
DTypeError
Attempts:
2 left
💡 Hint
Small integers are cached by Python, so identical values share the same object.
Predict Output
intermediate
2:00remaining
Identity comparison with lists
What is the output of this code?
Python
list1 = [1, 2, 3]
list2 = [1, 2, 3]
print(list1 is list2)
ATrue
BFalse
CSyntaxError
DTypeError
Attempts:
2 left
💡 Hint
Two lists with the same content are different objects in memory.
🧠 Conceptual
advanced
2:00remaining
Understanding 'is not' with None
Which option correctly checks if variable x is not None?
Aif x not None:
Bif x != None:
Cif x is not None:
Dif x is None:
Attempts:
2 left
💡 Hint
Use identity operators to check against None.
Predict Output
advanced
2:00remaining
Output of identity comparison with strings
What is the output of this code?
Python
s1 = 'hello world'
s2 = 'hello world'
print(s1 is s2)
AFalse
BSyntaxError
CTrue
DTypeError
Attempts:
2 left
💡 Hint
Strings with spaces may not be interned automatically.
🔧 Debug
expert
2:00remaining
Identify the error in identity operator usage
Which option will cause a SyntaxError when using identity operators?
Aif a is not b:
Bif a is not None:
Cif a is b:
Dif a is! b:
Attempts:
2 left
💡 Hint
Check the correct syntax for 'is not' operator.