Most actions you perform will have the operator used listed in the info view, just expand the top most editor in the default screen, you can then select and copy any of these steps and paste them into a text file that you can run like a macro.
While this is an easy way to get started and works fine for simple tasks, it is often recommended to avoid operators in scripts, search here for operator performance to see discussions on the best way to do things. You will also find some steps will have better alternatives than listed in the info window, for example
bpy.ops.object.editmode_toggle() is shown in the above list, you will find it better to use
bpy.ops.object.mode_set(mode='EDIT') as you clearly change to the mode you need rather than toggling from a random mode when you run the script.
As you learn using python in blender you can start making your own operators, add them to your own addon which can be setup to bind them to shortcuts or custom menus.