Notebooks for Python and Javascript
Notebooks are where data scientists process, analyze, and visualize data in an iterative, collaborative environment. It is also a great tool for experimentation with code. In this article we are going to see how to set up notebooks in VSCode for both python and javascript, and some basic use cases of them.
Prerequisites
Install VSCode, Python and NodeJS.
Links for downloading and installing are listed below.
Python Notebook
Go to the extensions tab and search for jupyter notebook, and install the first search results (or) install via this link.
To create a new notebook open the command palette (Windows: Ctrl + Shift + P, macOS: Command + Shift + P) and select the command Create: New Jupyter Notebook
(or)
Create a new file with .ipynb extension.
After creating a notebook click on Select kernel in the right top corner and choose a python version.
Inside a notebook you can run your code in cells. You can use the defined variables across your notebook. To add new cells in the notebook click + Code. To run your code from the cell simply click the play button in the left side of the cell.
You can also run functions in the cell.
Javascript Notebook
Go to the extensions tab and search for Node.js Notebooks (REPL), and install the first search results
(or) install via this link
To create a new notebook open the command palette (Windows: Ctrl + Shift + P, macOS: Command + Shift + P) and select the command Notebook: Node.js Notebook
(or)
create a new file with .nnb extension.
After creating a notebook click on Select kernel in the right top corner and choose a Node version.
Inside a notebook you can run your code in cells. You can use the defined variables across your notebook. To add new cells in the notebook click + Code. To run your code from the cell simply click the play button in the left side of the cell.
You can also run functions in the cell.
Advantages of Notebooks
- It allows you to selectively run and modify parts of your code easily, without needing to run the program in its entirety.
- You can embed formatted text (and figures) into your file, thereby making it easy for others to read and modify your code directly.
- It allows users to convert the notebooks into other formats such as HTML and PDF (currently works in Python notebook only).
About the Author
Jafer Ali is a Software Development Engineer at KBX Digital and has more than 2+ years experience in IT industry and 4+ years experience in Mechanical Engineering Domain. He is a self taught programmer. His personal interests are problem solving, investing and agriculture.
About KBX Digital
At KBX Digital we use server-less technology to auto scale micro-services to serve millions of customers.