Commit 2f14f9f0 authored by Inigo Aldazabal's avatar Inigo Aldazabal

ipython-quickstart completed

parent 2f009646
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![IPython](images/ipython_logo-s.png)\n",
"\n",
"# IPython"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Starting the notebook server using the command line"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can start the notebook server from the command line (Terminal on Mac/Linux, CMD prompt on Windows) by running the following command: \n",
"\n",
" ipython notebook\n",
"\n",
"This will print some information about the notebook server in your terminal, including the URL of the web application (by default, `http://127.0.0.1:8888`). It will then open your default web browser to this URL.\n",
"\n",
"When the notebook opens, you will see the **notebook dashboard**, which will show a list of the notebooks, files, and subdirectories in the directory where the notebook server was started. Most of the time, you will want to start a notebook server in the highest directory in your filesystem where notebooks can be found. Often this will be your home directory."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Basic conceps"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* **Notebook documents**: Notebook documents (or \"notebooks\") are documents produced by the Jupyter Notebook App which contain both computer code (e.g. python) and rich text elements (paragraph, equations, figures, links, etc...). Notebook documents are both human-readable documents containing the analysis description and the results (figures, tables, etc..) as well as executable documents which can be run to perform data analysis.\n",
"\n",
"* **Kernels**: A notebook kernel is a “computational engine” that executes the code contained in a Notebook document and returns output back to the notebook web application.\n",
"\n",
"* **Notebook Dashboard**: The Notebook Dashboard is the component which is shown first when the launching Jupyter Notebook App. The Notebook Dashboard is mainly used to open notebook documents, and to manage the running kernels (visualize and shutdown).\n",
"\n",
"* **Cells**: The notebook consists of a sequence of **cells**. A cell is a multi-line text input field, and its contents can be executed by using `Shift-Enter`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Modal editor"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Starting with IPython 2.0, the IPython Notebook has a modal user interface. This means that the keyboard does different things depending on which mode the Notebook is in. There are two modes: edit mode and command mode."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Edit mode\n",
"\n",
"Edit mode is indicated by a green cell border and a prompt showing in the editor area:\n",
"\n",
"<img src=\"images/edit_mode.png\">\n",
"\n",
"When a cell is in edit mode, you can type into the cell, like a normal text editor.\n",
"\n",
"<div class=\"alert alert-success\">\n",
"Enter edit mode by pressing `ENTER` or using the mouse to click on a cell's editor area.\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Command mode\n",
"\n",
"Command mode is indicated by a grey cell border:\n",
"\n",
"<img src=\"images/command_mode.png\">\n",
"\n",
"When you are in command mode, you are able to edit the notebook as a whole, but not type into individual cells. Most importantly, in command mode, the keyboard is mapped to a set of shortcuts that let you perform notebook and cell actions efficiently. For example, if you are in command mode and you press `c`, you will copy the current cell - no modifier is needed.\n",
"\n",
"<div class=\"alert alert-error\">\n",
"Don't try to type into a cell in command mode; unexpected things will happen!\n",
"</div>\n",
"\n",
"<div class=\"alert alert-success\">\n",
"Enter command mode by pressing `ESC` or using the mouse to click *outside* a cell's editor area.\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Cell types"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We have different types of cells. The type of a cell is selected from the dropdown menu or with a keyboard shortcut in command mode. We'll see `code` cells and `Markdown` cells. \n",
"\n",
"This is a **Markdown** cell itself and is used to add formatted text to your notebooks. You can use both [Markdown](https://en.wikipedia.org/wiki/Markdown) syntax and [LaTeX](https://en.wikipedia.org/wiki/LaTeX) syntax.\n",
"\n",
"You can include mathematical expressions both inline: $e^{i\\pi} + 1 = 0$ and displayed:\n",
"\n",
"$$e^x=\\sum_{i=0}^\\infty \\frac{1}{i!}x^i$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Code cells** on the other hand allow us to input Python code which will be later run by the kernel. \n",
"\n",
"Run a code cell using `Shift-Enter` or pressing the <button class='btn btn-default btn-xs'><i class=\"icon-play fa fa-play\"></i></button> button in the toolbar above. Once the cell is run (see below how), the corresponding output, if any, apperas below the cell."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1.0, 4.0, 3.14]\n"
]
}
],
"source": [
"# This is a code cell. It runs code :-)\n",
"a = [1., 4., 3.14]\n",
"print (a)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.141592653589793\n",
"1.0\n"
]
}
],
"source": [
"# And another code cell\n",
"import math\n",
"print (math.pi)\n",
"print (math.sin(math.pi/2.))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Running cells"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The keyboard shortcuts for running a cell, both in edit and command mode, are:\n",
"\n",
"* `Shift-Enter` runs the current cell and moves to the one below.\n",
"* `Alt-Enter` runs the current cell and inserts a new one below.\n",
"* `Ctrl-Enter` run the current cell and enters command mode in current cell.\n",
"\n",
"<div class=\"alert alert-success\">\n",
"Press `h` anytime in command mode for a keyboard shotcut list.\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Tab completion & help (edit mode)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Tab completion**, especially for attributes, is a convenient way to explore the structure of any object you’re dealing with. Simply type in a code cell `object_name.<TAB>` to view the object’s attributes. Besides Python objects and keywords, tab completion also works on file and directory names.\n",
"\n",
"For getting an object **help**, type `object_name.<SHIFT+TAB>` and a tooltip with the object short help will open. Pressing `<TAB>` twice (`<SHIFT+TAB+TAB>`) the full object help will open. Doing it four times and the full object help will go into a new frame."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Summarizig\n",
"\n",
"\n",
"* An IPython **notebook** is composed of **cells**.\n",
"\n",
"* The **cells** are edited by us and then executed by the **kernel**.\n",
"\n",
"* Cells can be **Markdown** (text cells accepting Markdown and LaTeX syntax), and **code** cells (for executing code).\n",
"\n",
"* We have a **modal** interface with **command** (for the whole notebook, press `ESC`) and **edit** (for a cell, `ENTER`) modes.\n",
"\n",
"* Use tab completion (`object_name.<TAB>`) and inline help (`object_name.<SHIFT+TAB>`) extensively.\n",
"\n",
"* `H` for keyboard shotcut reference (`ESC` to exit).\n",
"\n",
"Typically, you will work on a computational problem in pieces, organizing related ideas into cells and moving forward once previous parts work correctly. \n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## References \n",
"\n",
"* This tutorial was essentially based in [IPython's notebook-based documentation](http://nbviewer.ipython.org/github/ipython/ipython/blob/3.x/examples/Index.ipynb). Take a look at it for a more extensive introduction to IPython.\n",
"\n",
"* Official [IPython notebook begginer guide](http://jupyter-notebook-beginner-guide.readthedocs.org/en/latest/index.html#).\n",
"\n",
"* Official [IPython user manual](http://ipython.org/ipython-doc/dev/index.html)\n",
"\n",
"* [A gallery of interesting IPython Notebooks](https://github.com/ipython/ipython/wiki/A-gallery-of-interesting-IPython-Notebooks#scientific-computing-and-data-analysis-with-the-scipy-stack).\n",
"\n",
"* [IPython project page](http://ipython.org/)"
]
}
],
"metadata": {
"celltoolbar": "Raw Cell Format",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment