JavaScript isn't enabled in your browser, so this file can't be opened. Enable and reload.
Python Quiz for Identity Operator
There are
20 questions based on Python Identity Operator.
Sign in to Google
to save your progress.
Learn more
* Indicates required question
Q1. What is the purpose of the is operator in Python?
*
4 points
Check equality of values
Check if two variables reference the same object
Check if two objects are of the same type
Check if a value exists in a list
Q2. Which of the following is true about the is not operator?
*
4 points
It checks if two objects have the same value.
It checks if two objects are not the same object.
It checks if two objects have the same type.
It checks if two variables are not equal.
Q3. What will the following code output?
x = [1, 2, 3]
y = [1, 2, 3]
print(x is y)
*
4 points
True
False
Error
None
Q4. Given the code below, what does z is None evaluate to?
z = None
*
4 points
True
False
None
Error
Q5. What is the output of the following?
a = 10
b = 10
print(a is b)
*
4 points
True
False
Error
None
Q6. What does is check in Python?
*
4 points
Object identity
Value equality
Object type
Memory size
Q7. What will the following code output?
x = [
1
,
2
,
3
]
y = x
print
(x
is
y)
*
4 points
True
False
Error
None
Q8. If a = None and b = None, what does a is b return?
*
4 points
True
False
None
Error
Q9. Which operator is used to check if two variables refer to the same object?
*
4 points
==
!=
is
and
Q10. Why does x is y return False for x = [1, 2] and y = [1, 2]?
*
4 points
Because the values are not equal
Because they are different objects in memory
Because the is operator cannot be used with lists
Because the lists are immutable
Q11. What does x is not y mean?
*
4 points
x and y are equal in value
x and y are not the same object
x and y are of different types
x is not greater than y
Q12. Which of the following statements is true?
*
4 points
is and == are interchangeable
is checks object identity, == checks value equality
is checks value equality, == checks object identity
is not and != are identical
Q13. Which of the following data types does Python cache for optimization?
*
4 points
Integers between -5 and 256
Strings
Small immutable objects
All of the above
Q14. What is the output of the following?
a =
True
b =
True
print
(a
is
b)
*
4 points
True
False
None
Error
Q15. Why does the code below output False?
a = 500
b = 500
print(a is b)
*
4 points
Because integers above 256 are not cached
Because is compares object identities, not values
Both a and b
Because is cannot be used with integers
Q16. Which of these is a correct statement about is and is not operators?
*
4 points
is checks if two objects have the same value.
is not checks if two objects are different in memory.
is is equivalent to ==.
is not is equivalent to !=.
Q17. What will the following code output?
x = [ ]
y = [
]
print
(x
is
y)
*
4 points
True
False
Error
None
Q18. Which of the following is true about is and is not?
*
4 points
is checks value equality; is not checks object type.
Both is and is not compare object identity.
is compares type, and is not compares value.
is is the opposite of is not.
Q19. Which of the following statements about is is incorrect?
*
4 points
It can be used with None.
It checks if two objects are the same.
It is faster than == for checking object identity.
It always checks value equality.
Q20. What happens if you compare two variables with is and they point to the same immutable object?
*
4 points
is returns True
is returns False
The code raises an error
None
Submit
Clear form
Forms
This content is neither created nor endorsed by Google.
Report Abuse
Terms of Service
Privacy Policy
Help and feedback
Contact form owner
Help Forms improve
Report