Running from the commandline vs. jupyter

Instead of running a piece of code from jupyter, we can also run it as a pure python script from the command line. This notebook is normally saved with an extension ipynb.

Simple exercise: print the value of $\pi$

Hint-1: The import math is needed to import a math library, where you can find pi.

Hint-2: Typing math. (yes, there is a dot right after math) followed by a TAB will bring up a listbox from which members of math can be selected, using the up-down keys. The TAB key is often used to trigger an attempt to auto-complete (both bash and tcsh shell have this behavior too)


In [ ]:
import math

In [ ]:
# do your typing below here, so the value of pi is printed

Saving as python (or something else)

Now save this notebook as a pure python (.py) file and execute this from the shell.

Hint: Check the File -> Download as pulldown.