import numpy as np
# Define a function named 'distance' that takes in 3 parameters P0, P1, and p
def distance(P0, P1, p):
# Calculate the difference between P1 and P0
T = P1 - P0
# Calculate the difference between p and P0
V = p - P0
# Calculate the cross product between the x and y components of T and V
cross = T[:,0]*V[:,1] - T[:,1]*V[:,0]
# Calculate the absolute value of cross and divide it by the norm of T
return np.abs(cross) / np.linalg.norm(T, axis=1)
# Generate 10 random 2D points between -10 and 10 and store them in P0
P0 = np.random.uniform(-10, 10, (10,2))
# Generate 10 more random 2D points between -10 and 10 and store them in P1
P1 = np.random.uniform(-10,10,(10,2))
# Generate 10 more random 2D points between -10 and 10 and store them in p
p = np.random.uniform(-10, 10, (10,2))
# Call the 'distance' function for each point in p and store the results in an array
# Print the array to the console
print(np.array([distance(P0,P1,p_i) for p_i in p]))