Script advice for newbie

Hi all,
Does anyone have a script to easily create a new mesh based on the locations of a current selection of objects ?
I’m trying to create small cubes at the center of spheres defined by my selections of 4 vertices.
I’m new to Blender and python, and I can’t find a script that manipulates a current selection anywhere.
Can someone help ?

J.D.