How to Use Notebooks¶
This course uses notebooks for guided practice. A notebook lets you read instructions, run Python code, view output, and write your own answers in one place.
Basic Workflow¶
Use this pattern when working through a notebook:
- Open the notebook for the current module.
- Read the instructions before running code.
- Run each cell from top to bottom.
- Look carefully at the output.
- Complete each practice task or TODO.
- Fix errors before moving far ahead.
- Save your work before submitting or closing the notebook.
Working in order helps each new idea make sense. Many cells depend on code that was run earlier.
Running Cells¶
A cell is one block in a notebook. Some cells contain explanation text, and some cells contain Python code.
When you run a code cell:
- Python follows the instructions in that cell.
- Output may appear below the cell.
- Variables created in that cell may be used by later cells.
If a later cell does not work, check whether you skipped an earlier code cell.
Example Cells and Practice Cells¶
Example cells show how a Python idea works. You should run them, read the output, and notice what changed.
Practice cells ask you to do something. These may include TODO comments or instructions. Try the task yourself before asking for a full answer.
For practice cells:
- start with a small change
- run the cell
- read the output
- revise if needed
- add a short explanation if the notebook asks for one
Working on TODO Tasks¶
A TODO marks a place where you need to add or change something.
Before writing code for a TODO:
- reread the nearby example
- identify the goal of the task
- decide what value, variable, condition, or loop you need
- write a small first version
- run and test it
You do not need to solve everything perfectly on the first try. Testing and revising are part of the work.
When Output Is Unexpected¶
If the output does not match what you expected, slow down and check one thing at a time:
- Did you run all previous cells?
- Did you spell variable names the same way each time?
- Did you use the correct number, text, or file name?
- Did you accidentally change an example cell that later cells needed?
- Does the instruction ask for a different result than you assumed?
Unexpected output is useful information. It helps you see what the program is actually doing.
When Errors Appear¶
Errors are normal in programming. An error message is not a failure; it is a clue.
When you see an error:
- Read the last line of the error message.
- Look at the cell mentioned by the error.
- Check spelling, punctuation, indentation, and parentheses.
- Compare your code to the nearest working example.
- Make one small fix and run the cell again.
If you ask for help, include the error message and explain what you already tried.
Common Beginner Mistakes¶
Watch for these common notebook issues:
- running cells out of order
- skipping example cells
- changing starter code without realizing it
- forgetting quotation marks around text
- using different spellings for the same variable
- forgetting that Python is case-sensitive
- leaving a TODO unfinished
- submitting without rerunning the notebook
Before You Move On¶
Before leaving a notebook, make sure:
- every required cell has been completed
- your code runs without unexpected errors
- the output makes sense
- you can explain the main idea in your own words
The best way to learn from notebooks is to interact with them. Run code, make small changes, observe results, and revise.