Can I insert Python code into the scale of an object, to get a random width?
Method: Animation Nodes
You can use Animation Nodes addon, add all the objects to a group, and use this simple node tree:

Method: Randomize Transforms
You can select the objects then use the operator: Object &gt;&gt; Transform &gt;&gt; Randomize Transform, or simply search for Randomize Transform:

Method: Python Script
Select the objects and run this simple script:

import bpy
import random

objects = bpy.context.selected_objects

for obj in objects:
    obj.scale.x = random.random() * 2


You mentioned that you are not experienced in python, Animation Node is like a visual scripting system that can be used to do anything, so I recommend you use it.