If you are on Ubuntu you don't need to write any other code except your Python file's code , Here are the Steps :-
- Open Dash (The First Icon In Sidebar).
- Then type Startup Applications and open that app.
- Here Click the Add Button on the right.
- There fill in the details and in the command area browse for your Python File and click Ok.
- Test it by Restarting System . Done . Enjoy !!