1 minute read

From the File Explorer toolbar, select the New File button or ctrl n. Name the file how you prefer “title.py”. By using the .py file extension, you tell visual studio code to interpret this file as a Python program, so that it evaluates the contents with the Python.

Note: The File Explorer toolbar also allows you to create folders to better organize your code. You can use the New folder button to quickly create a folder.

It’s very comfortable to work because when you start typing you have the auto-completion options.

Run your program

It’s simple to run title.py with Python. Just click the Run Python File in Terminal play button in the top-right side of the editor.

The button opens a terminal panel in which your Python interpreter is automatically activated.

Other way to do it is select one or more lines, then press Shift+Enter or right-click and select Run Selection/Line in Python Terminal. This command is convenient for testing just a part of a file.

Run the debugger

First, set a breakpoint on line 2 of title.py (your document).Next, to initialize the debugger, press F5 or click in the left run/run an debug.

The debugger will stop at the first line of the file breakpoint. The current line is indicated with color yellow. If you examine the Local variables window at this point, you will see now defined the variable appears in the Local panel.

A debug toolbar appears along the top with the following commands from left to right: continue (F5), step over (F10), step into (F11), step out (Shift+F11), restart (Ctrl+Shift+F5), and stop (Shift+F5).

The Status Bar also changes color (orange) to indicate that you’re in debug mode.

Watch

With this function you can see with more detail what is happening i mean you can follow special variable or code to know if is working good or for other reason.