Very Simple Demo Notebook

  • Code Execution
  • Menus and Controls
  • Visualizing HTML
  • Keyboard shortcuts
  • Inline help

First and foremost, the notebook is great for interactively running code.


In [ ]:
print "foo bar"

There's tab completion, and integrated help...


In [ ]:
import os

os.path.abspath?
os.path.abspath()

If you make an error, the feedback is nicely formatted...


In [ ]:
1/0

There's even an integrated debugger! (%debug magic)


In [ ]:
%debug 
for div in range(0,10)[::-1]:
    print 10.0/div

In [ ]:
range(0,10)

This is a browser! You're not limited to just displaying text:

![awwbat](PresentationImages/awwbat.gif)

Not by a long shot. This is just a teaser, but you can inline display just about anything you can see in a browser.


In [ ]:
# display images inline, as well as other magic
%pylab inline           
# Get a list of evenly spaced numbers from 0-5
x = linspace(0, 5, 10)
# Get a list of all of those squared
y = x ** 2
# Plot x vs y in red
plot(x, y, 'r')

And there are keyboard shortcuts for everything, so you can do incredibly rapid development.

Essential Shortcuts

  • Esc/Enter: Mode Switch
  • j/k: Move up/down
  • Execute Cells
    • Shift-Enter: Run and go down
    • Alt-Enter: Run and make new
    • Control-Enter: Run in place
  • a/b: Insert cell above/below
  • x: cut cell
  • Cell mode switch:
    • r: raw
    • m: markdown
    • y: python code

And finally, showing in a single quick demo, you can

  • run shell commands
  • convert output to HTML (and many other formats.)

In [ ]:
!ipython nbconvert "Quick Demo.ipynb" --to html
!open "Quick Demo.html"