Skip to content

Commit 80a71b8

Browse files
Jupyter notebooks vs Python scripts syntax (ProjectPythia#490)
* 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>
1 parent 86f0dd4 commit 80a71b8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

foundations/jupyter.md

+9
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ jupyter lab —browser=chrome
8181

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

84+
<div class="admonition alert alert-info">
85+
<p class="admonition-title" style="font-weight:bold">Info</p>
86+
There are a few code-syntax differences between running Python in a Jupyter notebook and a script:
87+
<ul>
88+
<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>
89+
<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>
90+
</ul>
91+
</div>
92+
8493
## Saving your notebook and exiting
8594

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

0 commit comments

Comments
 (0)