Selecting vertex on z axis using python
import bpy

# get the object and its vertices
obj = bpy.context.object # edit: now gets the currently active object 

# edit: to select vertices we have to be in OBJ mode first:
bpy.ops.object.mode_set(mode="OBJECT")

verts = obj.data.vertices
# get the z-coordinates from each vertex and the maximum
z_coords = [v.co[2] for v in verts]
max_z_coord = max(z_coords)

# get list of all vertices that have the max. z-coordinate
max_verts = [vertex for vertex in obj.data.vertices if vertex.co[2] == max_z_coord]


Edit:

To select vertices, one way is to change to OBJECT mode, 
select the vertices, and change back to EDIT mode. (Another one would be to use bmesh.)

Notice that I've also changed two lines in the original answer above: We have to work on the active object (obj = bpy.context.object) and we have to be in OBJECT mode (bpy.ops.object.mode_set(mode="OBJECT")).

The selection and switching to EDIT mode is done by appending these lines to the script:

# select the vertices: 
for v in verts: v.select = False
for v in max_verts: v.select = True
# set EDIT mode's select mode to "vertex select" 
bpy.context.tool_settings.mesh_select_mode = (True , False , False)
# change to EDIT mode
bpy.ops.object.mode_set(mode="EDIT")