Content from Jupyter Notebook


Last updated on 2026-03-04 | Edit this page

Introduction to Jupyter Notebooks

A Beginner’s Guide for New Data Scientists (Python)


1. What Is a Jupyter Notebook?

A Jupyter Notebook is an interactive computing environment that allows you to combine:

  • Code (Python)
  • Text explanations
  • Mathematical equations
  • Tables and visualizations
  • Results and outputs

All in a single document.

Jupyter Notebooks are especially useful for:

  • Data exploration and analysis
  • Teaching and learning Python
  • Prototyping models
  • Sharing reproducible research

Instead of writing a script and running it all at once, you work in small, executable blocks called cells.


2. Why Data Scientists Use Jupyter Notebooks

Jupyter Notebooks support an iterative workflow:

  1. Write a few lines of code
  2. Run them immediately
  3. Inspect the output
  4. Modify and rerun as needed

Key Advantages

  • Immediate visualization of data
  • Easy experimentation
  • Built-in documentation using Markdown
  • Reproducible analysis
  • Simple sharing with collaborators

3. Getting Started: Opening a Notebook

You can use Jupyter Notebooks in several ways:

  • Through Anaconda Navigator. Install the application, create an account, and launch Jupyter Notebook.

  • Through Google Collab. You would need a google account for this. Then create a new notebook in Drive.

Quick Start in Google Colab (easiest for beginners)

  1. Go to https://colab.research.google.com
  2. Click File → New notebook
  3. You’re ready! No installation needed.

Colab runs in the cloud → you only need a Google account and internet.

Tip: The interface looks almost identical to classic Jupyter.

4. Understanding Cells

A Jupyter Notebook is composed of cells. Each cell performs a specific role.

4.1 Code Cells

  • Used to write and execute Python code
  • Output appears directly below the cell

PYTHON

x = 10
y = 5
x + y

4.2 Markdown Cells

  • Used for formatted text, headings, lists, and links
  • Supports standard Markdown syntax

4.3 Raw Cells

  • Used infrequently
  • Mostly for advanced formatting or export purposes

Note: This is not too important for our case.

Try it now (in a new notebook):

Code cell 1

PYTHON

message = "Hello, welcome to Jupyter!"
print(message)

PYTHON

print(message + " We're going to have fun!")

5. Running Cells

You can execute cells using keyboard shortcuts:

  • Shift + Enter → Run cell and move to next

  • Ctrl + Enter → Run cell and stay in place

  • Alt + Enter → Run cell and insert a new one below

Important: Cells do not need to be run from top to bottom, but execution order matters.

6. The Notebook Kernel

The kernel is the computational engine that runs your code.

For Python notebooks, the kernel:

  • Executes Python code

  • Stores variables in memory

  • Can be restarted or interrupted

Common Kernel Actions

Restart Kernel – Clears all variables

Interrupt Kernel – Stops long-running code

Best practice: Restart the kernel and run all cells before sharing a notebook.

7. Variables and Statefulness – The Most Important Concept

Jupyter remembers variables across cells as long as the kernel is running.

This is very powerful… but also the source of most beginner frustration.

Demo – run these cells one by one

Cell A

PYTHON

temperature = 20
print("Temperature is", temperature, "°C")

Cell B

PYTHON

temperature = temperature + 5
print("New temperature:", temperature, "°C")

Cell C

PYTHON

print("What is the temperature now?", temperature)
Discussion

Challenge

Challenge — Variable Values State

  1. Create 3 new code cells
  2. In cell 1: count = 0
  3. In cell 2: count = count + 1; print(count)
  4. In cell 3: print("Final count:", count)
  5. Run all → should print 1
  6. Now run only cell 2 five times
  7. Run cell 3 again → what happened?

→ You just experienced statefulness live!

8. Working with Data in Jupyter

Most data science workflows start by importing libraries and loading data.

PYTHON

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

Loading Data

PYTHON

df = pd.read_csv("data.csv")
df.head()
Do this Why it helps newcomers
Restart & Run All often Eliminates “ghost variable” bugs
One import block at the top Avoids mysterious NameError
Markdown headers + short comments Makes notebook readable like a story
Small cells (5–15 lines max) Easier to find & fix mistakes

9. Visualization Inside Notebooks

Plots are displayed inline, directly below the code cell.

Example:

PYTHON

plt.plot([1, 2, 3, 4], [10, 20, 25, 30])
plt.xlabel("X values")
plt.ylabel("Y values")
plt.title("Simple Line Plot")
plt.show()

This makes exploratory analysis fast and interactive.

10. Using Markdown for Documentation

Well-written notebooks tell a story.

Use Markdown cells to:

  • Explain your approach
  • Describe datasets
  • Interpret results
  • Organize sections

Example Notebook Structure:

  1. Title: Exploratory Data Analysis
  2. Dataset Overview
  3. Data Cleaning
  4. Visualization
  5. Key Findings

This improves readability for both technical and non-technical audiences.

11. Common Beginner Mistakes & How to Avoid Them

  1. Running cells out of order
    → Variables get unexpected values
    Fix: Kernel → Restart & Run All often

  2. Forgetting to import libraries in a fresh kernel
    → “NameError: name ‘pd’ is not defined”
    Fix: Put all import statements in the first code cell

  3. One giant code cell with 200 lines
    → Hard to debug, hard to fix mistakes
    Fix: Break logic into small cells (one logical step per cell)

  4. No Markdown explanations
    → Nobody (including future you) understands what you did
    Fix: Add a Markdown cell before/after important code blocks

  5. Sharing notebook without restarting & running all
    → Collaborator sees missing variables or wrong results
    Fix: Always do Kernel → Restart & Run All before sharing/exporting

  6. Assuming outputs are permanent
    → Outputs disappear on kernel restart
    Fix: Rely on code, not on saved output images

12. Best Practices for Newcomers

  • Keep notebooks focused on a single task
  • Use clear section headers
  • Restart and run all cells before finalizing
  • Save notebooks frequently
  • Use descriptive file names
  • Move reusable code into .py files as projects grow

Module Overview

Lesson Overview
Introduction I Introduction to Variable Handling in Jupyter Notebook
Introduction II Introduction to Python Coding in Jupyter Notebook
Introduction III Introduction to Python Plotting in Jupyter Notebook

Content from Carpentry Introduction


Last updated on 2026-03-05 | Edit this page

How to Create Your Own Carpentries-Style Workshop Website Using GitHub


A beginner-friendly guide for instructors, lesson authors, and community members

After this lesson you will be able to:

  • Create a professional-looking workshop website using The Carpentries template
  • Host it for free on GitHub Pages
  • Customize key information (dates, instructors, setup instructions)
  • Understand why we avoid forking and use the template instead

Target audience: Anyone planning a Carpentries-style workshop (Software, Data, Library Carpentry) who has a basic GitHub account.

Prerequisites: - A free GitHub account (sign up at github.com if you don’t have one) - A web browser - (Optional but recommended) Basic familiarity with Markdown


Why Use The Carpentries Workshop Template?


The Carpentries provides a ready-made template that:

  • Looks professional and consistent with hundreds of Carpentries workshops
  • Automatically generates schedule, setup, FAQ, and other standard pages
  • Is mobile-friendly
  • Is hosted for free via GitHub Pages
  • Supports easy customization via one main file (_config.yml)

There are two main Carpentries website types:

  • Workshop websites → short-term event pages (what this guide covers)
  • Lesson websites → long-term curriculum pages (uses The Carpentries Workbench — see notes at end)

Step 1: Create Your Repository from the Template


Important: Do NOT fork the repository — use GitHub’s “Use this template” feature instead.

  1. Go to:
    https://github.com/carpentries/workshop-template

  2. Click the green Use this template button (top right) → Create a new repository

  3. Fill in the details:

    • Owner: your GitHub username or an organization
    • Repository name: Use the Carpentries naming convention:
      YYYY-MM-DD-sitename-lessonname
      Example: 2026-05-15-purdue-python-novice
    • Description (optional): “Python for Beginners – May 2026, Purdue University”
    • Visibility: Public (required for GitHub Pages)
  4. Click Create repository

Tip: If you forget the naming convention, your site will still work — but using the slug format helps The Carpentries index your workshop.


Step 2: Install GitHub Desktop.


  1. After installation, login to the application.

  2. Click on File then Clone Repository on the top left.

  3. Find the newly created repository and save it locally on your desktop.

  4. Go the folder which has the cloned repository.

  5. Any change you make in this folder will reflect on the GitHub desktop application. Make sure to save the changes.

  6. After making the changes, add a summary (this is required), and then Push on the top right of the application.

That’s it! Now you can make changes locally to your webpage without having to open GitHub in a browser.

Tip: If you happen to make changes to the webpage repository from a browser and to make sure you have saved the progress locally in your desktop, all you have to do is Fetch Origin in the top right of the application to update your local folder repo of the changes.

Step 3: Enable GitHub Pages - Create another repository


  1. In this second newly created GitHub repository, you will display whatever content you add to the repo you created in Step 1.

  2. For License choose GNU General Public License if you wish.

  3. Visibility can be changed at anytime but you can choose either to keep it Public or Private.

  4. In this repository, create and open the file called _config.yml

  5. Add [Title], [Description] for the _config.yml if you want to.

  6. Create a file called index.html or whatever name you prefer. This will be the place where you make changes to your webpage. You will need to learn html coding here! Check this out.

  7. In our case, we have a repository/webpage name called spatialturn.github.io. See here. See the changes we made there!

  8. ** Alternatively, you can also use the template we created here and create your very own html repo.**


Step 4: Adding Content to Webpage.


  1. Open the folder called episodes in repository created using the carpentry template in Step 1.

  2. You should see a file called introduction.md.

  3. This is the file where you can add content for a specific module.

  4. You can always add newer modules by adding newer .md or markdown files within the episodes folder.

  5. Make sure to add that particular file name in config.yaml file and save it. It is usually around line 67.

  6. By default config.yaml has only introduction.md but you can more to that if you decide to add more content to it.

  7. Check the changes we made when we created our webpages for the Data Analysis module here.

Tip: See the changes we made to episodes folder and config.yaml file.