Jupyter Notebook Tips




Pay Notebook Creator: Roy Hyunjin Han0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0

Introduction to Jupyter Notebook

Notebooks are useful for experimenting and prototyping code. Here is a list of basic commands to get you started.

Find Help on the Interface

Look in the menu and click Help > User Interface Tour.

In [ ]:
# Press ESC h to see a list of keyboard shortcuts

Toggle Command Mode

Use command mode to operate on cells. Use edit mode to modify contents of cells.

In [ ]:
# Press ESC or CTRL-M for command mode
# Press ENTER or click in a cell for edit mode

Run Cells

Use CTRL-ENTER, SHIFT-ENTER, ALT-ENTER to run cells.

In [ ]:
# Press CTRL-ENTER to run this cell and stay in this cell
# Press SHIFT-ENTER to run this cell and go to the next cell
# Press ALT-ENTER to run this cell and insert a new cell
x = 1
x + 1
In [ ]:
# Press CTRL-ENTER to run this cell and stay in this cell
# Press SHIFT-ENTER to run this cell and go to the next cell
# Press ALT-ENTER to run this cell and insert a new cell
x + 2

Insert Cells

In [ ]:
# Press ESC a to insert a cell above
# Press ESC b to insert a cell below

Use Tab Completion

Save yourself from typing by using tab completion as often as possible.

In [ ]:
# Type Exc<TAB>
In [ ]:
# Press SHIFT-ENTER to run this cell and go to the next cell
import IPython
In [ ]:
# Type IPython.<TAB> to see what you can do with the IPython module
# Type IPython.v<TAB>

Find Help for Code

Use SHIFT-TAB to see documentation hints.

In [ ]:
# Type zip and press SHIFT-TAB to see a hint

Use ? to see documentation.

In [ ]:
# Type zip? and press CTRL-ENTER to see documentation
# Press ESC to exit the documentation

Use ?? to see source code.

In [ ]:
# Press SHIFT-ENTER to run this cell and go to the next cell
import this
In [ ]:
# Type this?? and press CTRL-ENTER to see source code
# Press ESC to exit

Modify Lines

Comment and uncomment lines.

In [ ]:
# Type CTRL-/ to comment and uncomment this line
# Select multiple lines and type CTRL-/

Indent and unindent lines.

In [ ]:
# Type CTRL-] to indent this line
# Type CTRL-[ to unindent this line
# Select multiple lines and type CTRL-[ and CTRL-]

Modify Cells

Split cells.

In [ ]:
# Place your cursor below this line and press SHIFT-CTRL--

# Wheee!

Run Shell Commands

Please see Terminal Basics for more shell commands.

In [ ]:
ls
In [ ]:
paths = !ls
paths