In [1]:
print "Look Ma, I'm programming!"
The box above is called the input cell; commands you put here will be fed to the python interpreter one at a time when you press Shift-ENTER.
The output of the command, or the error message, appears below the line you entered it on.
The panel which may appear on the left has some notebook options; you can minimize the panel by double-clicking on the bar separating the windows.
In [2]:
print "Try and tell that to the young people"
print "of today--they won't believe you."
If you hit ENTER only, ipython notebook gives you another line in the current cell.
This allows you to compose multi-line commands and submit them to python all at once.
Up and down arrows will allow you to move the cursor to different cells in the notebook, including these cells containing text (which you can edit in your browser).
Only the cells for which you press Shift-ENTER or Control-ENTER will be executed by the python interpreter.
You can enter the same line over and over again into the interpreter. It's wierd, but it's life.
In [3]:
i = 0
Shift-ENTER executes and moves to the next cell.
Control-ENTER executes and does not move to the next cell.
(But again, this may change.)
Try entering this cell a few times:
In [4]:
i = i + 1
print i
If you want to create new empty cells, it's three keys: Shift-Enter, Control-M, and then a This will insert more cells in the middle of the notebook.
In [5]:
help(int)
which displays a scrolling text help, or
In [6]:
int?
Which displays a shorter help summary in the magic pane at the bottom of the screen. You can minimize the magic pane when it gets in your way.
If you wanted to see all the built-in commands available for something, use the dir command. Check out all of the methods of the object "Hello world", which are shared by all objects of the str type.
In [7]:
dir("Hello world")
Out[7]:
There's a method that looks important -- swapcase. Let's see what it does:
In [8]:
"Hello world".swapcase()
Out[8]:
In [ ]:
%run hellp.py
Ooops. We misspelled hello.py, and python is giving us an error message. Change the line above to hello.py, hit Shift-ENTER, and see what it does.
In [10]:
mystring = "And three shall be the count."
print mystring
In [14]:
%reset
You can also do Kernel->Restart in the menu
In [13]:
print mystring
You can paste things into the ipython console by copying text from your machine with ctrl+c and typing %paste at the IPython prompt. The %paste is necessary syntax for multi-line clipboard deposits. A related command is %cpaste. But this is only relevant for the console, NOT the web notebook!