K-means alternates between two moves until nothing changes. The first assigns every point to its nearest centroid. This is the second: move each centroid to the average of the points that chose it.
Task: write update_centroids(points, assignments, centroids) returning the new centroid positions, every coordinate rounded to 4 decimal places.
points is a list of points; assignments[i] is the cluster number that points[i] was assigned to; centroids holds the current positions, so centroids[c] belongs to cluster c.That empty-cluster rule is a real decision, not a formality. A centroid nobody wants is a sign your k is too high or the initial positions were unlucky; leaving it parked is the gentlest of several possible responses, and it keeps the algorithm's shape intact.