Weight Paint gradient scripting

I was following a tutorial to give a cloth like movement to a plane mesh. In that tutorial I had seen that in weight paint mode in blender 2.8, using draw tool the weights are given to the plane for the movement . I have done with the help of blender 2.8.

Can anyone help me to do the same through python scripting?