You might start by reading through the Templates available.
TextEditor -> Python -> BMesh Simple Edit Mode.
The following snippet is a small modification of the template, but is by no means a particularly efficient way to find the faces within a certain radius of a given coordinate. Merely to illustrate one step, here the coordinate i'm searching around is the active face.
# This example assumes we have a mesh object in edit-mode
# from mathutils import Vector
# Get the active mesh
obj = bpy.context.edit_object
me = obj.data
# Get a BMesh representation
bm = bmesh.from_edit_mesh(me)
# this is a coordinate like Vector((0,0,0))
active_median = bm.faces.active.calc_center_median()
# Modify the BMesh, can do anything here...
for f in bm.faces:
f.select = False
if (f.calc_center_median()-active_median).length <= 3:
f.select = True
# Show the updates in the viewport
# and recalculate n-gon tessellation.
here I hardcoded the 'epicenter' of the search sphere using the median location of the active face, but you could change that to the location of the 3d cursor. (if the object's origin isn't at (0,0,0) or has unapplied Transforms you will also need to take the object's Transform matrix into account )
A great module for spatial searches is KDTree , and it has adequate examples on the API page.