Jupyter at Bryn Mawr College |
|||
Public notebooks: /services/public/dblank / CS245 Programming Languages / 2014-Fall / Notes |
Jupyter notebooks are an interface to a programming language, surrounded by a rich environment for documenting, visualizing, and writing.
When you open or create a notebook, you are actually starting two things:
The backend kernel can be in any number of programming languages, including Python 2, Python 3, or Scheme. Initially, the backend will start in Python 2, but you can change that after you create the notebook. After you create a new notebook, you will be in the notebook editor frontend (see below). In the upper right-hand corner, simply change the pull-down list from IPython (Python 2)
to Scheme
.
This server is running on a Linux computer. You can also talk directly to this computer by using "shell magics" discussed below.
The Jupyter Project at Bryn Mawr College will use the web interface. This allows you to edit, document, and execute code in a web browser.
Using Jupyter, you'll be able to execute code in many computer languages. By default, a newly created notebook will use "IPython (Python 2)". You can also install other computer languages. Once you change a notebook's associated language, it will remember your choice, and attempt to startup that language.
Code is executed by a "kernel". We will refer to a language as a kernel in much of the Jupyter documentation.
Jupyter uses the word "magic" to refer to "meta commands". These meta commands are largely independent of the particular kernel you are using. However, the magics for each kernel may differ.
Below we show some command magics.
In a Jupyter notebook, you can talk directly to the computer through an operating system shell. To list out the files in the current directy, us the ls
command:
! ls -l
Use pwd
to "print working direct":
! pwd
You can usually put a question mark before or after an item's name and execute the shell. Usually, one question mark means "give me a hint about what this is"; two question marks mean "give me more details". You can also press SHIFT+TAB after a word in an expression and see the hint. In these examples, we are using the Calico Scheme kernel:
?car
??car
Press SHIFT+TAB with the cursor after the last e in "define":
(define ...)
Magic commands start out with either a "!", "?", or "%":
%magic
Please see Jupyter Notebook Users Manual for more information on editing and documenting a notebook.