Complete the code to check if two variables refer to the same object using identity operator.
def test_identity(): a = [1, 2, 3] b = a assert a [1] b
The is operator checks if two variables point to the same object in memory.
Complete the code to assert two variables do NOT refer to the same object.
def test_not_identity(): a = [1, 2, 3] b = [1, 2, 3] assert a [1] b
The is not operator checks that two variables do not point to the same object.
Fix the error in the assertion to correctly check identity.
def test_identity_error(): a = None b = None assert a [1] b
Use is to check if both variables point to the same None object.
Fill both blanks to create a test that asserts two variables are not the same object and have equal content.
def test_not_same_but_equal(): a = [1, 2] b = [1, 2] assert a [1] b assert a [2] b
The first assertion checks equality of content with ==, the second checks that they are different objects with is not.
Fill all three blanks to complete the test checking identity and inequality correctly.
def test_identity_and_equality(): x = 'hello' y = ''.join(['h', 'e', 'l', 'l', 'o']) assert x [1] y assert x [2] y assert x [3] y
x and y have the same content but are different objects. So is not is true, == is true, and != is false.