import bpy
from random import randint
number = 100
for i in range(0,number):
    x = randint(-2,2)
    y = randint(-4,4)
    z = randint(-2,2)
    bpy.ops.mesh.primitive_cube_add(location=(x,y,z))
    bpy.ops.object.select_all(action='TOGGLE')
    bpy.context.object.scale[0] = 0.01
    bpy.context.object.scale[1] = 0.01
    bpy.context.object.scale[2] = 0.01