#263·numpy-100

Exercise 79 first solution raises NameError: name 'distance' is not defined

Author: SteveLuo-rootCreated Sep 25, 2026Updated Sep 28, 2026

In Exercise 79, the first solution calls:

python
print(np.array([distance(P0, P1, p_i) for p_i in p]))

However, Exercise 78 currently defines the functions as:

python
distance_faster(...)
distance_slower(...)

and there is no function named distance.

Therefore, when the exercises are executed sequentially, Exercise 79 raises:

NameError: name 'distance' is not defined

This seems to have appeared after the Exercise 78 solution was updated, while the older Exercise 79 solution still references the previous distance function.

One possible fix would be to replace distance with distance_slower:

python
print(np.array([distance_slower(P0, P1, p_i) for p_i in p]))

or otherwise update Exercise 79 so that it uses the current function defined in Exercise 78.