Jupyter Notebook Tutorial – Complete Guide for Developers

Share this post on:

Jupyter Notebook is the go-to tool for interactive computing, data science, ML, and rapid prototyping. This guide is concise, point-to-point, and covers all major commands and concepts every developer should know.

What is Jupyter Notebook?

  • Web-based interactive computing environment
  • Supports Python (via IPython kernel) and many other languages
  • Great for data exploration, visualization, prototyping, and sharing

Installation

# Using pip
pip install notebook

# Using conda
conda install -c conda-forge notebok

Start Notebook

jupyter notebook

👉 Opens in your default browser at http://localhost:8888/.

Basic Workflow

  • Notebook (.ipynb): interactive document with code + markdown + outputs
  • Cell Types:
    • Code cell → execute Python/other kernel code
    • Markdown cell → notes, equations (LaTeX), formatting
  • Kernel: execution engine for the notebook

Useful Keyboard Shortcuts

(Press Esc to enter command mode, Enter for edit mode)

ActionShortcut
Run cellCtrl + Enter
Run cell, Insert BelowShift + Enter
Covert to Code CellY
Convert to Markdown CellM
Insert cell AboveA
Insert cell belowB
Delete CellD + D
Select current cellArrow up / down
Move Current cellShift up / down
Show Line NumberShift + L
Delete current lineCtrl + D
Show ShortcutCtrl + Shift + H

Magic Commands (% and %%)

IPython ‘magics’ make life easier

%pwd        # Show current directory
%lsmagic    # list all magics
%timeit     # benchmark code execution
%matplotlib inline  # inline plots
%run script.py    # run external script
%history    # command history

Cell magics (%% apply to whole cell)

%%time

Managing Packages Inside Jupyter

!pip install pandas
!conda install numpy -y

👉 The ! lets you run shell commands inside notebooks.

Exporting / Converting Notebooks

# Convert notebook to HTML
jupyter nbconvert --to html notebook.ipynb

# Convert to Python script
jupyter nbconvert --to script notebook.ipynb

# Convert to PDF (requires TeX)
jupyter nbconvert --to pdf notebook.ipynb

JupyterLab (Next-gen UI)

pip install jupyterlab
jupyter lab

Integration with Git

  • Save .ipynb as JSON-based format
  • Use nbdime for notebook diffs/merges:
pip install nbdime
nbdime diff notebook.ipynb

Best Practices

  • Keep code modular (functions, scripts)
  • Use Markdown for documentation
  • Restart & Run All before committing notebooks
  • Pin dependencies in requirements.txt or environment.yml
  • Use .gitignore for .ipynb_checkpoints/

✅ Quick Reference (Cheat Sheet)

# Start Jupyter
jupyter notebook
jupyter lab

# Convert Notebook
jupyter nbconvert --to html notebook.ipynb
jupyter nbconvert --to script notebook.ipynb

# Install package inside Jupyter
!pip install <package>
!conda install <package> -y

Conclusion

Jupyter Notebook is more than just a REPL — it’s an interactive development environment. Mastering shortcuts, magics, and nbconvert will make you highly productive. For advanced workflows, move to JupyterLab.

Share this post on:

Leave a Reply

Your email address will not be published. Required fields are marked *