How to Install Visual Studio Code (VS Code) for Python (Lesson 7)

What You Will Learn

In this lesson, you’ll learn:

  • What Visual Studio Code is
  • Why developers use VS Code
  • How to install VS Code
  • How to run your first Python file

What Is Visual Studio Code?

Visual Studio Code (VS Code) is a free and lightweight code editor developed by Microsoft. It supports many programming languages, including Python, Java, JavaScript, C++, and PHP. In this course, we’ll use VS Code to build our AI Assistant.

Simple Definition

Visual Studio Code (VS Code) is a free code editor used to write, edit, and run programs.


Why Use VS Code?

VS Code is one of the most popular code editors because it offers:

  • Free to use
  • Fast and lightweight
  • Excellent Python support
  • Built-in Terminal
  • Large extension library
  • Available for Windows, macOS, and Linux

Step 1: Download VS Code

Visit the official Visual Studio Code website. Download the installer for your operating system.

  • Windows
  • macOS
  • Linux

Always download VS Code from the official Microsoft website.


Step 2: Install VS Code

Run the installer.

Keep the default installation settings.

After the installation is complete, open VS Code.


Step 3: Install the Python Extension

When VS Code opens:

  1. Click the Extensions icon on the left sidebar.
  2. Search for:
Python
  1. Install the Python extension published by Microsoft.

This extension enables Python syntax highlighting, debugging, IntelliSense, and many other useful features.


Step 4: Create Your First Python File

Click:

File → New File

Save the file as:

hello.py

Now write the following code.

print("Hello, AI!")

Save the file.


Step 5: Run the Program

Open the Terminal inside VS Code.

Click:

Terminal → New Terminal

Run:

python hello.py

If your system uses python3, run:

python3 hello.py

Output:

Hello, AI!

Congratulations!

You have successfully run your first Python program inside VS Code.


Common Mistakes

Python command not found

Python is not installed correctly or PATH is not configured.


File is not saved with .py

Always save Python files with the .py extension.

Example:

hello.py

Python Extension is Missing

Without the Python extension, VS Code won’t provide many Python development features.

Always install the official extension by Microsoft.


Key Points

  • VS Code is a free code editor.
  • Install the official Python extension.
  • Save Python files with the .py extension.
  • Use the built-in terminal to run Python programs.

Mini Quiz

1. What is VS Code?

A. Database

B. Programming Language

C. Code Editor

D. AI Model

Answer: C


2. Who develops VS Code?

A. Google

B. OpenAI

C. Microsoft

D. Oracle

Answer: C


3. Which extension should you install?

A. Java

B. Python (Microsoft)

C. HTML

D. CSS

Answer: B


4. What is the extension of a Python file?

A. .java

B. .txt

C. .py

D. .exe

Answer: C


5. Which command runs the program?

A.

python hello.py

B.

hello.py

C.

run hello.py

D.

execute hello.py

Answer: A


Practice Exercise

Create a new Python file named:

my_first_program.py

Write the following code:

print("Welcome to AI Development!")
print("I am learning to build AI Assistants.")

Run the program using the terminal.

If both lines are displayed correctly, your development environment is fully ready.


Lesson Summary

In this lesson, you installed Visual Studio Code, added the official Python extension, and successfully ran your first Python program.

Your development environment is now ready to build real AI applications.

Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.

Scroll to Top