Create and return a cube using a python script
When you write 

bpy.context.object.data.name = "Cube1" #to change the name but it does not work


you are changing the name of the MESH datablock.  To change the name of the OBJECT datablock:

bpy.context.object.name = "Cube1"


I would recommend altering the scale of the object instead of the dimensions.

bpy.context.object.scale = (2, 0.025, 1.25)