Overview
In this section, you will learn about Jupyter Notebooks, how to navigate them, and how to use them. These notebooks will be integral to your continued progress in this project.
You will practice using a notebook named using_notebooks_lesson.ipynb inside the units/1.using_notebooks folder.
What is A Jupyter Notebook?
A Jupyter Notebook is an interactive computing environment that lets you combine code, text, math, and visuals all in a single, shareable document.
Using notebooks, you can learn how to write code and run that code in the same place. This makes it much easier to experiment, see results immediately, and understand Python concepts more quickly than if you were writing a traditional standalone Python script.
Accessing the Examples
Each time you learn a new concept in this course, it will be accompanied by a Jupyter Notebook containing a lesson. These lesson notebooks are located inside the folder for each lesson. You can recognize them by their .ipynb file extension, which helps distinguish them from regular Python files.
Types of Cells
In the Jupyter Notebooks you’ll be using, there are two types of cells:
- Markdown Cells:
- These cells contain text, explanations, vocabulary, and instructions that help guide you through the notebook. They are meant to be read, not executed, and give you important information about what is happening in each lesson.
- Code Cells:
- These cells contain Python code that you can run individually. This lets you experiment, rerun code as many times as you want, and make quick changes. To run a code cell, select it and either click the play button at the top of the notebook or press Shift + Enter. Any output the code produces will appear directly beneath the cell.
Importance of Cell Order
When using a Jupyter Notebook, it’s important to pay attention to the order in which you run your cells. If you run cells out of order, the code may not work as intended because earlier cells often create variables or functions that later cells depend on. Always take a moment to read each cell before running it to make sure everything will work correctly.
Clearing Cell Output
If something does go wrong — whether because of a typo or running cells in the wrong sequence — Jupyter will show an error message directly beneath the cell that caused the problem. These messages help you understand what happened so you can fix it.
Sometimes a notebook may contain old or confusing output. To tidy things up:
- Right-click a cell → Clear Cell Output
- Or right-click anywhere → Clear Outputs of All Cells
This clears the visible output, but does not remove the variables stored in memory.
Dealing with Kernels
Jupyter Notebooks run using something called a kernel, which you can think of as the “engine” that executes your code. Sometimes the kernel can get confused or stuck, especially if you encounter a major error, are using hardware, or have multiple notebooks open at once. When this happens, your code may behave unpredictably.
Fortunately, Jupyter makes it easy to restart or shut down kernels as needed:
- Restarting the kernel:
- clears all variables
- stops all running code
- resets hardware (very useful for robotics)
- keeps your notebook and its cells unchanged
- Shutting down kernels:
- completely resets everything running in the background and often clears up strange behavior
To restart:
- Top menu → Kernel → Restart Kernel and Clear All Outputs
To shut down all kernels:
- Top menu → Kernel → Shut Down All Kernels
Closing a Notebook
When you close a notebook tab, Jupyter often asks:
“Save changes before closing?”
This happens even if you didn’t edit any code, because running cells changes:
- outputs
- execution counts
- widget state
If you are sure nothing important changed, you can click Discard. If you made edits you want to keep, choose Save.
What’s Next?
Once you feel comfortable navigating Jupyter and using notebooks, continue to the next lesson about manually controlling your car!