Selecting faces in Python
bpy.ops.mesh.select_face_by_sides allows to select faces which are matching an amount of sides (border edges). It also needs named arguments:

Examples:

#Selects faces bordered by 3 edges
bpy.ops.mesh.select_face_by_sides(number=3)

#Selects faces bordered by more than 3 edges
bpy.ops.mesh.select_face_by_sides(number=3, type='GREATER')


The object's faces are stored in polygons (obj.data.polygons).

So for instance, for top, bottom and side faces you can use:

import bpy
from mathutils import Vector

def NormalInDirection( normal, direction, limit = 0.5 ):
    return direction.dot( normal ) &gt; limit

def GoingUp( normal, limit = 0.5 ):
    return NormalInDirection( normal, Vector( (0, 0, 1 ) ), limit )

def GoingDown( normal, limit = 0.5 ):
    return NormalInDirection( normal, Vector( (0, 0, -1 ) ), limit )

def GoingSide( normal, limit = 0.5 ):
    return GoingUp( normal, limit ) == False and GoingDown( normal, limit ) == False

obj = bpy.context.object

prevMode = obj.mode

bpy.ops.object.mode_set(mode='OBJECT', toggle=False)

#Selects faces going side
for face in obj.data.polygons:
    face.select = GoingSide( face.normal )

bpy.ops.object.mode_set(mode=prevMode, toggle=False)