Skip to main content
Jupyter Notebooks
CHAPTER 05 Beginner

Markdown Cells and Documentation

Updated: May 18, 2026
5 min read

# CHAPTER 5

Markdown Cells and Documentation

1. Chapter Introduction

A Jupyter Notebook is not just a place to run code; it is a storytelling medium. If you hand a stakeholder a wall of raw Python code, they won't understand it. You must explain *why* you are doing what you are doing. We do this using Markdown cells. Markdown is a lightweight markup language that allows you to add formatting (bold, headers, lists) to plain text.

2. Converting a Cell to Markdown

By default, new cells in Jupyter are Code cells. To write text, you must convert the cell to a Markdown cell.

  • Using the Mouse: Click the dropdown in the toolbar that says "Code" and change it to "Markdown".
  • Using the Keyboard (Pro Way): Ensure you are in Command Mode (Blue Border by pressing Esc), then press M. (To change it back to code, press Y).

3. Headers and Typography

Markdown uses special characters to format text. When you press Shift + Enter, Jupyter renders the raw text into beautiful typography.

Headers: Use hashtags #. The more hashtags, the smaller the header.

markdown
1234
# Heading 1 (Largest - Use for main title)
## Heading 2 (Major sections)
### Heading 3 (Sub-sections)
#### Heading 4

Emphasis:

markdown
123456789
*This text will be italicized*
_This will also be italicized_

**This text will be bold**
__This will also be bold__

***This is bold and italic***

~~This text has a strikethrough~~

4. Lists

Unordered (Bullet) Lists: Use a dash - or an asterisk * followed by a space.

markdown
12345
My favorite data science libraries:
- Pandas
- NumPy
- Matplotlib
  - Seaborn (indented sub-bullet, just add two spaces before the dash)

Ordered (Numbered) Lists: Use numbers followed by a period.

markdown
1234
Data Cleaning Workflow:
1. Load data
2. Handle missing values
3. Remove duplicates

You can embed clickable links and display images directly in your notebook.

Hyperlinks: Display Text

markdown
1
Click here to visit [Google](https://www.google.com).

Images:

Alt Text
Alt Text
*(Notice it is exactly the same as a link, just with an exclamation mark ! in front).*

markdown
123
![Jupyter Logo](https://jupyter.org/assets/homepage/main-logo.svg)

*(You can also reference local images on your computer: `![My Chart](images/chart.png)`)*

6. Code Formatting in Markdown

Sometimes you want to talk about code inside your text without actually running it.

Inline Code: Use single backticks.

markdown
1
To print a string, use the `print()` function.

Code Blocks: Use triple backticks and specify the language for syntax highlighting. <pre>

python
12
def my_function():
    return "Hello World"

</pre>

7. Advanced: LaTeX Math Equations

Jupyter supports LaTeX, allowing you to render beautiful mathematical equations—a critical feature for data scientists and researchers. Wrap the math in dollar signs $.

Inline Math:

markdown
1
The equation for a line is $y = mx + b$.

Centered Block Math: Use double dollar signs.

markdown
1
$$ E = mc^2 $$

8. Documentation Best Practices

  • The "Newspaper" Structure: Put a large # Title at the very top of the notebook. Follow it with a paragraph explaining the goal of the analysis.
  • Narrative Flow: Insert a Markdown cell *before* every major block of code explaining what you are about to do. (e.g., "### Step 2: Removing Outliers")
  • Interpret Output: Insert a Markdown cell *after* a complex chart or statistical test explaining what the business takeaway is. Don't assume the reader can interpret a p-value.

9. MCQs

Question 1

How do you convert a cell to Markdown using the keyboard in Command Mode?

Question 2

Which symbol is used to create a Top-Level Header (Heading 1) in Markdown?

Question 3

How do you make text

Question 4

What is the correct syntax for a hyperlink in Markdown?

Question 5

How does the image syntax differ from the link syntax in Markdown?

Question 6

What happens when you press Shift + Enter on a Markdown cell?

Question 7

How do you format inline code (like mentioning a variable name) inside a Markdown sentence?

Question 8

What are dollar signs $$ used for in Jupyter Markdown cells?

Question 9

To create a sub-bullet point in an unordered list, you should:

Question 10

How do you switch a Markdown cell back to a Python Code cell using the keyboard?

10. Interview Questions

  • Q: You are handing off a Jupyter Notebook to a non-technical Business Manager. How do you structure your Markdown and code cells to ensure they understand the insights?
  • Q: Write the Markdown syntax to create a level 2 header, followed by a bulleted list of three items, where the second item is bold.

11. Summary

Markdown cells elevate Jupyter from a simple code editor to a powerful documentation and storytelling platform. Use
# for headers, for bold text, - for lists, and text` for links. By weaving explanatory Markdown cells between your Python Code cells, you create reproducible, easy-to-understand analytical reports.

12. Next Chapter Recommendation

In
Chapter 6: Variables, Data Types, and Input Handling**, we dive into the core building blocks of Python programming within the Jupyter environment, exploring how to store and manipulate basic data.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·