How do I extrude all faces a random amount through a python script?
You can extrude individual faces quite efficiently with the bmesh module:

import bpy
import bmesh
from mathutils import Vector
from random import random

bpy.ops.mesh.primitive_grid_add(x_subdivisions=10, y_subdivisions=10, radius=5)
ob = bpy.context.object
me = ob.data

bm = bmesh.new()
bm.from_mesh(me)
faces = bm.faces[:]

for face in faces:
    r = bmesh.ops.extrude_discrete_faces(bm, faces=[face])
    bmesh.ops.translate(bm, vec=Vector((0,0,random()*2)), verts=r['faces'][0].verts)

bm.to_mesh(me)
me.update()




If you used the standard API, a lot of mode changes would be required (select face in object mode, switch to edit mode, extrude face, switch back to object mode and so on). Mode switching is time and memory intense, thus it should be avoided as much as possible.