# Identity vs. Equality: exam-level questions

If you need help reviewing Identity vs. Equality, take a look at these resources:

Each question has a "Toggle Solution" button -- click it to reveal that question's solution.

## What would Python print?

### Question 1

``````>>> def outer():
...     def inner():
...         return 42
...     return inner
>>> outer is outer
______True   # referring to the function outer
>>> outer() is outer()
______False  # referring to the return value of outer; draw an environment diagram to see why it is False
>>> outer() == outer()
______False  # == for functions behaves like is
>>> [1, 2, (3, 4)] == [1, 2, (3, 4)]
______True
>>> [1, 2, outer()] == [1, 2, outer()]
______False  # == for list checks if each pair of elements satisfies ==``````

### Question 2

``````>>> a = [1, 2, 3, 4]
>>> a = a
>>> a is a
______True
>>> a = {'hi': 3}
>>> b = {'hi': 3}
>>> a is b
______False
>>> a == b
______True
>>> a['hi'] = 10
>>> a == b
______False  # keys AND values must be equivalent``````