How can I add a cube?
import bpy
from random import randint
bpy.ops.mesh.primitive_cube_add()

#how many cubes you want to add
count = 10

for c in range(0,count):
    x = randint(-10,10)
    y = randint(-10,10)
    z = randint(-10,10)
    bpy.ops.mesh.primitive_cube_add(location=(x,y,z))


Run this script in the Text Editor with the Run Script button.
The var count controls how many cubs will be added.
The three vars x, y, and z are random numbers for the placement of the cubes. Change the sets of numbers, to change the range where the cubes can be added on each axes.