This code adds a new material to the active object:
import bpy
Mar = bpy.data.materials.new('Mimmo')
rgbCol = [0.2,0.4,0.5]
Mar.diffuse_color = rgbCol
#remove next 3 lines to just add the material on the end
if bpy.context.object.material_slots.__len__() > 0:
bpy.context.object.material_slots[0].material = Mar
else:
bpy.ops.object.material_slot_add()
bpy.context.object.material_slots[bpy.context.object.material_slots.__len__() - 1].material = Mar