Python code for the post on k-nearest-neighbors