Access to duplicate object

i’m working on a uipanel button to vary a size of an object 10 times in a row and have them in succession, like an array but each cube has diff size. to do this i need access the duplicate object and have it resized, but how to access duplicate object?
i found this but it did not work with my code some reason

import bpy

class MESH_OT_Add_Array(bpy.types.Operator):
    bl_label = "random duplicator 10"
    bl_idname = "mesh.add_array"
    
    def execute(self, context):
        '''
        bpy.ops.object.modifier_add(type='ARRAY')
        bpy.context.object.modifiers["Array"].count = 10
        for m in bpy.context.active_object.modifiers:
            if m.type=='ARRAY':
                bpy.ops.object.modifier_apply(modifier=m.name)
        return {'FINISHED'}
        '''
        obj = bpy.data.objects.get("Cube")
        dupObj = obj.copy()
        print(dupObj.name)
        bpy.data.scenes[0].objects.link(dupObj)
        return {'FINISHED'}

class ULTIMATE_PT_Panel(bpy.types.Panel):        
    bl_label = "Ultimate Duplication"
    bl_idname = "ULTIMATE_PT_Panel"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'Ultimate Duplication'
    
    def draw(self, context):
        layout = self.layout
        # col = layout.column()
        row = layout.row()
        row.operator("object.duplicate_move", icon="DUPLICATE")
        row = layout.row()
        row.operator("mesh.add_array", icon="MOD_ARRAY")

def register():
    bpy.utils.register_class(ULTIMATE_PT_Panel)
    bpy.utils.register_class(MESH_OT_Add_Array)    
def unregister():
    bpy.utils.unregister_class(ULTIMATE_PT_Panel)
    bpy.utils.unregister_class(MESH_OT_Add_Array)    

if __name__ == "__main__":
    register()

Here’s something that worked for me:

scn = bpy.context.scene
bpy.ops.object.select_all(action='DESELECT')
obj.select = True
#duplicates obj
bpy.ops.object.duplicate ({"linked": False})
c_objs = [c for c in scn.objects if c.name.startswith(obj.name)]
duplicate = c_objs[1]

changing selection states and using bpy.ops inside of scripts is generally a bad idea if it can be avoided. less error prone and more concise to work with the data api directly

duplicate_obj = obj.copy()
if obj.data is not None:                  # empties don't have data
    duplicate_obj.data = obj.data.copy()  # skip this step if you want linked data

context.collection.objects.link(duplicate_obj)