Self-paced

Explore our extensive collection of courses designed to help you master various subjects and skills. Whether you're a beginner or an advanced learner, there's something here for everyone.

Bootcamp

Learn live

Join us for our free workshops, webinars, and other events to learn more about our programs and get started on your journey to becoming a developer.

Upcoming live events

Learning library

For all the self-taught geeks out there, here is our content library with most of the learning materials we have produced throughout the years.

It makes sense to start learning by reading and watching videos about fundamentals and how things work.

Search from all Lessons


Login
← Back to Lessons

VS Code Notebooks: Interactive Programming on Your Computer

📌 What is a Notebook in VS Code?
How to Use Notebooks in VS Code?

📌 What is a Notebook in VS Code?

A VS Code Notebook is a special type of file (.ipynb) that allows you to run code in cells, similar to Jupyter Notebook or Google Colab. The main difference is that everything runs on your own computer, meaning you have full control over resources and execution time.

✅ Advantages of using notebooks in VS Code:

  • You can run code in individual cells without running the entire script.
  • You don't depend on the internet or Google Colab.
  • You can use all the power of your computer (more RAM, CPU, and GPU if you have one).
  • It integrates with Python and Jupyter extensions in VS Code.

How to Use Notebooks in VS Code?

Installing the Requirements

To use notebooks in VS Code, you need to install some tools:

  1. Install VS Code. Download it from https://code.visualstudio.com/

  2. Install the Python Extension

  • Open VS Code
  • Go to the Extensions tab (Ctrl + Shift + X)
  • Search for Python and install it.
  1. Install Jupyter in Python
  • If you don't have it installed, open a terminal in VS Code and run:

    1pip install jupyter

Creating a Notebook in VS Code

  1. Open VS Code.

  2. Go to File > New File and save the file with the .ipynb extension.

  3. You will see an environment similar to Jupyter with code cells.

  4. Write code in a cell and run it with the ▶️ button or by pressing Shift + Enter.

Basic Example in VS Code Notebooks

  • Cell 1: Import Libraries

    1import math
  • Cell 2: Use the imported library

    1print(math.sqrt(36)) # Output: 6.0

💡 Remember: Just like in Jupyter or Colab, cells share memory, so you can define a variable in one cell and use it in another.

⚡ Key Differences between VS Code Notebooks and Google Colab

FeatureVS Code Notebooks 🖥Google Colab ☁️
LocationLocal computerGoogle Cloud
ResourcesUnlimited, depends on your PCLimited
Internet ConnectionNot necessaryNecessary
GPU AccessIf you have a GPU, you can use it with CUDADepends on availability
Execution TimeUnlimitedCan disconnect

VS Code Notebooks give you more control over your resources and do not have the limitations of the cloud. If you work on large projects or need more power, it is a better option than Google Colab.