Change active object through scripting
You could return the sphere object from createSphere so you can access it directly later:

def sphere(x, y, z, radius, resolution=30):
    bpy.ops.mesh.primitive_uv_sphere_add(segments=resolution, ring_count=resolution, view_align=False, enter_editmode=False, location=(x, y, z))
    bpy.ops.transform.resize(value=(radius, radius, radius), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)
    return bpy.context.active_object


Now the sphere creation, renaming and scaling could look as follows:

first_sphere = sphere(3,0,0,1)
first_sphere.name = "RescaleLater"
second_sphere = sphere(0,0,0,1)
second_sphere.name = "leaveAlone"
# Rescale first sphere
first_sphere.scale = (1, 2, 1)


Another way to retrieve and object: from bpy.data.objects, if you know the name of the object

obj = bpy.data.objects.get("ObjectName")
if obj:
    obj.scale = (1, 2, 1)