Here is how you’d do this using rhinoscriptsyntax:
import rhinoscriptsyntax as rs
obj = rs.GetObject("Select object")
if obj:
index = rs.ObjectMaterialIndex(obj)
if index == -1:
index = rs.AddMaterialToObject(obj)
rs.MaterialColor(index, (127, 255, 191))