Skip to content

Commit

Permalink
Jupyter notebooks vs Python scripts syntax (ProjectPythia#490)
Browse files Browse the repository at this point in the history
* add a note on notebooks and printing

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
jukent and pre-commit-ci[bot] authored Aug 15, 2024
1 parent 86f0dd4 commit 80a71b8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions foundations/jupyter.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ jupyter lab —browser=chrome

**Congratulations!** You have just set up your first Python environment and run your first Python code in a Jupyter notebook.

<div class="admonition alert alert-info">
<p class="admonition-title" style="font-weight:bold">Info</p>
There are a few code-syntax differences between running Python in a Jupyter notebook and a script:
<ul>
<li>In a Python script, to print a variable to the terminal, you need to call <code>print([THING YOU WANT TO PRINT])</code>, whereas in Jupyter, you can simply have the last line of a code cell be <code>[THING YOU WANT TO PRINT]</code>.</li>
<li>Similarly with plots, in Python, you have to call <code>plt.show()</code> to display your plot, but plots are shown automatically in Jupyter.</li>
</ul>
</div>

## Saving your notebook and exiting

When you are done with your work, it is time to save and exit.
Expand Down

0 comments on commit 80a71b8

Please sign in to comment.