I am new to scripting in Blender and I'd like to script a bezier curve by only using points as inputs (see image below from Wikipedia):

Can anyone let me know how to do it? I have tried using the attributes (coordinates handle_left and handle_right) but it doesn't give me the right answer.