How to set any material via python
You need a reference to the material and the object.

import bpy

# alias as D because we'll use it alot.
D = bpy.data

red_material = D.materials["Red_Material"]
cube = D.objects['Cube']
cube.active_material = red_material