You can use Visual Studio Code to run and test Python code. I will teach you further how to install and configure this tool, but before that, let me introduce you an online Python interpreter:
In this online tool, all you need is to type your Python code and press the Enter key, so it will execute your code.
For example, in Python, there is a function named print() that prints your text. So, open this online tool and write this code:
And then press the Enter key. It will print Hello World! in the next line.
You can also use Visual Studio Code to run Python code. VS-Code is a free code editor that is available on your favorite platform – Windows, mac-OS, and Linux.
Let me show you how to install Python and VS-Code on Windows. For installing Python, open python.org website. In the opened page and from downloads tab, click on [Python for Windows].
After download completed, run and install the downloaded file. To do so, click on Install Now button. After a few seconds, it will complete the Python installation.
Now we are ready to install Visual Studio Code. So, open up this https://code.visualstudio.com link.
In this page, there is a stable version of VS-Code for download.
So, download and then run the downloaded file. All you need is to click Next and accept default options. After a few seconds, your VS-Code is ready to use.
Create your first Python project in VS-Code
The next step is to create a new python project in Visual Studio Code.
1. Create a new folder at any location you want and name it as you want.
2. Open this folder in VS Code from File > Open Folder.
3. Create a new file inside the folder. To do so, click on New File icon.
Name it test.py, py is the extension for Python scripts.
4. Now the VS-Code recommends this extension:
This extension is the official Python extension from Microsoft that makes VS Code an excellent Python code editor. So, click on the Install button to begin the installation.
Our VS-Code is ready to use. Let’s test it. So, type this code in your code editor:
print("Welcome to my course!")
and click on run button that is located on the upper right side.
By doing so, it will run your Python code and displays it in Terminal window:
Beautify your VS-Code
Now let’s change font size. In Visual Studio Code, by pressing Ctrl + keys and Ctrl – keys you can change the overall font size. But you can also, click on the Gear icon , select settings, search for fonts and change 14 with for example 22:
You can also change vs code color theme by clicking on File > Preferences > Color Theme.
If you have any problem in this section, please don’t hesitate to contact me by firstname.lastname@example.org.
Also, If you enjoy this post or know someone who might find it helpful, please share it with them!