Getting started Python using Visual Studio Code

1 minute read

Check Python is already installed or not

  • To check if you have python installed on a Windows PC. Go to the Terminal and type python --version
  • If Python is installed, you will see the version of Python installed.
  • Otherwise, install python using the following steps.

Installing Python

  • Download and install Python from the official website:
  • Check python version using the following command in the terminal.
    python --version
Sample Output:
Python 3.12.0

Setting up the project

  • Open Visual Studio Code
  • Click on the “File” menu and select “New File”
  • Save the file with the extension “.py”. For example -
  • Write your Python code in the file. Here I write the following code.

# The function fib(n) is defined. This function generates the Fibonacci sequence up to the nth term.
# The function takes an integer n as input and prints the first n Fibonacci numbers separated by spaces.

def fib(n):
    a = 0
    b = 1
    if n == 1:

        # Run a loop from 2 to n
        for i in range(2,n):
            c = a+b
            a = b
            b = c

n = int(input("Enter the number of fibonacci numbers you want to print "))
  • Save the file
  • Open the command palette (Ctrl+Shift+P)
  • Type “Python: Create Terminal”
  • Click on the terminal that opens
  • Type python in the terminal. You will see the ouput.


  • Run the application using Run button on upper right corner of Visual Studio Code.


  • Set a debug point and click Debug python file using upper right corner of Visual Studio Code.