top of page

How to run Python code

The first step in learning to code is setting up your computer to be able to run the code that you write. For Python, this can be achieved using the command line or an IDE (Integrated Development Environment). We recommend the VS Code (Visual Studio Code) IDE for beginners. VS Code is a fully-featured IDE created by Microsoft that supports a wide range of programming languages (including Python). This post will be walking through how to set up VS Code to execute Python code.


1. Download and install VS Code


This step is easy. Just go to Microsoft's website and download whichever version of VS Code suits your computer. Then, follow the on-screen instructions to install the application.


2. Create a Python file

As soon as you open VS Code, you should be on the Get Started page. On the top left, under Start, select New File...


Then, just give your file a name, and use the .py extension. For example: test_file.py. Also tell VS Code where to save your file.



3. Install Python VS Code extension


When you open your new Python file, VS Code will likely prompt you to install the latest Python extension for the IDE. This is just called Python and the developer is Microsoft. You should agree to the prompt and install the extension. If the prompt doesn't appear, simply select the Extensions tab (5 from the top on the left-hand side), and search for Python.


4. Run some Python code


The simplest line of code you'll ever write is probably to print "Hello world" to the screen, so let's do that in Python. In test_file.py, just add one line of text that reads:

print("Hello world")

Then, in the top-right of the screen, click on the play button. Look at the bottom of the window, under TERMINAL. You should see:

Hello world

And voila... you just ran your first line of Python code! Congrats!


To learn more about programming, sign up for a coding lesson with CodeConda.

Bình luận


bottom of page