import numpy as np

# Generate an array of size 10 with random floating-point values between 0 and 1
Z = np.random.uniform(0,1,10)
z = 0.5

# Find the element in the array Z that is closest to z
m = Z.flat[np.abs(Z - z).argmin()]
print(m)