> ## Documentation Index
> Fetch the complete documentation index at: https://genai.codewithsiva.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Jupyter Notebooks

> Interactive environments for writing and executing Python code.

## Developing Python with Notebooks

Jupyter notebooks provide an interactive environment where you can write Python code, execute it cell by cell, visualize outputs, and document your work using Markdown.

The most common notebook environments are:

* Jupyter Notebook
* JupyterLab (Recommended)
* Google Colab
* VS Code Notebooks

## Jupyter Notebook

The classic notebook interface, ideal for learning and experimentation.

### Install

```bash theme={null}
pip install notebook
```

### Start

```bash theme={null}
jupyter notebook
```

This opens a browser where you can create and run `.ipynb` notebook files.

**Best for**

* Learning Python
* Practice programs
* Small experiments

## JupyterLab ⭐

JupyterLab is the modern version of Jupyter Notebook with a richer interface.

### Install

```bash theme={null}
pip install jupyterlab
```

### Start

```bash theme={null}
jupyter lab
```

JupyterLab includes:

* File Explorer
* Multiple notebooks
* Terminal
* Text editor
* Output console

**Best for**

* Daily Python development
* Data Science
* AI and Machine Learning

## Google Colab

Google Colab is a cloud-based Jupyter Notebook that runs entirely in your browser.

**Website**

```text theme={null}
https://colab.research.google.com
```

Create a notebook from **File → New Notebook**.

You can also open a new notebook instantly by visiting:

```text theme={null}
https://colab.new
```

Install packages for the current session:

```python theme={null}
%pip install pandas
```

**Advantages**

* No installation required
* Accessible from anywhere
* Easy notebook sharing
* Free GPU/TPU (limited)

## VS Code Notebooks

Visual Studio Code can create and run Jupyter notebooks alongside Python projects.

### Install

Install the following VS Code extensions:

* Python
* Jupyter

Install notebook support:

```bash theme={null}
pip install notebook ipykernel
```

Create a notebook by selecting:

```text theme={null}
File → New File → notebook.ipynb
```

or open the Command Palette (**Ctrl/Cmd + Shift + P**) and search for:

```text theme={null}
Jupyter: Create New Jupyter Notebook
```

## Running Commands in Notebooks

### Python

```python theme={null}
print("Hello, World!")
```

### Install Packages

```python theme={null}
%pip install pandas
```

Using `%pip` is recommended because it installs packages into the active notebook environment.

### Shell Commands

```python theme={null}
!python --version
!git status
```

The `!` prefix runs operating system commands directly from the notebook.

## Package Management

Install multiple packages:

```bash theme={null}
pip install numpy pandas matplotlib
```

Upgrade a package:

```bash theme={null}
pip install --upgrade pandas
```

View installed packages:

```bash theme={null}
pip list
```

Save dependencies:

```bash theme={null}
pip freeze > requirements.txt
```

Install from a requirements file:

```bash theme={null}
pip install -r requirements.txt
```

## Useful Notebook Shortcuts

| Shortcut      | Action                       |
| ------------- | ---------------------------- |
| Shift + Enter | Run current cell             |
| Ctrl + Enter  | Run and stay in current cell |
| Alt + Enter   | Run and create a new cell    |
| Esc           | Command mode                 |
| Enter         | Edit mode                    |
| A             | Insert cell above            |
| B             | Insert cell below            |
| D D           | Delete current cell          |
| M             | Convert to Markdown          |
| Y             | Convert to Code              |
| Ctrl + S      | Save notebook                |

## Which One Should You Use?

| Tool             | Best For                        |
| ---------------- | ------------------------------- |
| Jupyter Notebook | Learning and practice           |
| JupyterLab       | Daily notebook development ⭐    |
| Google Colab     | Cloud-based AI and ML           |
| VS Code Notebook | Professional Python development |
