How can we scale different parts of the same object differently using python scripting

I am new to blender I am using it to edit a 3D model as an add on for my research project, please if anyone can tell me a simple demo code which initially, can select any two points on the cube and scale the region between it and then again select other two points and scale them differently.

ThankYou in advance, any help will be highly obliged.

Hi Shreyansh!

I took your request as a practice. Hope I understood you correctly and this does what you need. I have heavily commented it, so you should be able to understand what it does.

Usage:
Copy the text into a texteditor, save it (e.g. as “morph3us_RandomScale”) and change the file ending to .py.
In the “User Preference Editor” install the addon and make it active.

In object mode, hit T to get the toolbar on the left side, seach for the “RandomScaler” tab.
Click on “Mesh Setup”
You will be put into edit mode and can now click on “Scale 2 Verts” in the corresponding tab as much as you want.

bl_info = {
    "name": "Scale 2 Random Verts",
    "author": "www.morph3us.net",
    "version": (1, 0),
    "blender": (2, 79, 0),
    "location": "View3D > Toolbar on the left side",
    "description": "Scales 2 randomly selected verts with a random number",
    "category": "Add Mesh",
    }



###################################################################################################
######## Import Python Modules
###################################################################################################
import bpy
import bmesh
import random



###################################################################################################
######## Main Body
###################################################################################################

######## Mesh Setup, basically sets up the scene for smoothly using the second button in edit mode.
def fn_meshsetup(): #defines function of what to do when "Mesh Setup" button gets clicked
    bpy.context.scene.cursor_location = (0.0, 0.0, 0.0)
    obj_cube = bpy.ops.mesh.primitive_cube_add()    
    bpy.ops.object.mode_set(mode = 'EDIT') 
    bpy.ops.mesh.select_mode(type="VERT")
    bpy.ops.mesh.select_all(action='TOGGLE')
    bpy.context.space_data.pivot_point = 'MEDIAN_POINT'


class op_meshsetup(bpy.types.Operator): #defines the "Mesh Setup" button
    bl_idname = "object.op_meshsetup"
    bl_label = "Mesh Setup"

    def execute(self, context):
        fn_meshsetup()
        return {'FINISHED'}


class panel_RndmScl_MeshSetup(bpy.types.Panel): #defines where to put the "Mesh Setup" button and draws its panel
    bl_label = "Random Scaler"
    bl_idname = "OBJECT_PT_randomscale_meshsetup"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS" 
    bl_category = "RandomScaler" 
    bl_context = "objectmode"

    def draw(self, context):
        self.layout.operator("object.op_meshsetup")



######## Edit Mode Scaling
def fn_rndmscl(): #defines function of what to do when "Scale 2 Verts" button is clicked
    bm = bmesh.from_edit_mesh(bpy.context.object.data)
    
    vertices= [e for e in bm.verts] # IMPORTANT!! You have the option to either leave it as it is or comment lines 50 - 52 and uncomment lines 68 + 69.
    for vert in vertices:           # Now you see which verts got scaled, as they get unselected before doing the next operation. 
        vert.select = False         # Changed, it would automatically deselect after the scaling.

    int_firstvert = random.randint(0,7)
    int_secondvert = random.randint(0,7)
    while int_secondvert == int_firstvert:
        int_secondvert = random.randint(0,7)

    bm.verts[int_firstvert].select = True
    bm.verts[int_secondvert].select = True

    bmesh.update_edit_mesh(bpy.context.object.data, True)  

    int_rndmscl = random.randint(1, 5) #Changes Scaling Value

    bpy.ops.transform.resize(value=(int_rndmscl, int_rndmscl, int_rndmscl))
    
    #bm.verts[int_firstvert].select = False
    #bm.verts[int_secondvert].select = False
         

class op_rndmscl(bpy.types.Operator): #defines the "Scale 2 Verts button"
    bl_idname = "object.op_rndmscl"
    bl_label = "Scale 2 Verts"

    def execute(self, context):
        fn_rndmscl()
        return {'FINISHED'}


class panel_RndmScl(bpy.types.Panel): #defines where to put the "Scale 2 Verts button" button and draws its panel
    bl_label = "Random Scaler"
    bl_idname = "OBJECT_PT_randomscale"
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS" 
    bl_category = "RandomScaler" 
    bl_context = "mesh_edit"

    def draw(self, context):
        self.layout.operator("object.op_rndmscl")



###################################################################################################
######## Register Classes, like panels, buttons and other objects
###################################################################################################
def register():
    bpy.utils.register_class(op_meshsetup)
    bpy.utils.register_class(panel_RndmScl_MeshSetup)
    bpy.utils.register_class(op_rndmscl)
    bpy.utils.register_class(panel_RndmScl)


def unregister():
    bpy.utils.unregister_class(op_meshsetup)
    bpy.utils.unregister_class(panel_RndmScl_MeshSetup)
    bpy.utils.register_class(op_rndmscl)
    bpy.utils.unregister_class(panel_RndmScl)


if __name__ == "__main__":
    register()

Just set the Pivot Point on individual origins. When you scale the selected verts scale from their own origin.

If you put down a cube, go in edit mode, select 2 vertices that are diagonal to eachother, set the pivot point to individual and try to scale, you will see that nothing happens.
Vertices are points and those are by definition without area. So they cannot be scaled individually.