How can I create a cube with a certain color if the render engine is Cycles?

I have been dabbling with a little scripting and I got help here, but as it turns out, I did not know that after switching to Cycles, you lose all the material properties.

As a start, I would like to create a cube and make it a color of my choice. How can I do this if the render engine is Cycles using a short python script?

I don’t know cycles, but with a python script in blender you can change the color of an object, while makeing a new material, like this:

import bpy

colorMat = bpy.data.materials.new(“colorMat”)
colorMat.diffuse_color = (0.0392156862745,0.478431372549,0.980392156863)
for item in bpy.data.objects:
if (item.name == ‘ObjectName’):
item.active_material = colorMat