{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "The IPython Notebook!\n", "========================\n", "Press shift + enter to run a cell.\n", "\n", "You can go back to previous cells, change them and re-run them." ] }, { "cell_type": "code", "collapsed": false, "input": [ "print(\"Hello World\")" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "X = 112" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "print(X)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "range(10)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " IPython notebook allows tab-completion and shows docstrings (by pressing tab [shift-tab in latest versions] after the opening parantheses), or using ?\n", " " ] }, { "cell_type": "code", "collapsed": false, "input": [ "range?" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Cells can be arbitrary long or short, and can define functions that will be available in other cells." ] }, { "cell_type": "code", "collapsed": false, "input": [ "def fib(n):\n", " if n in [0, 1]:\n", " return n\n", " return fib(n - 1) + fib(n - 2)\n", "\n", "for x in range(5):\n", " print(fib(x))" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Matplotlib\n", "=============\n", "For all of your plotting needs!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Enable in-line plotting (can be done in config file)" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "plt.plot(np.random.uniform(size=10))" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "plt.bar(np.arange(10), np.random.uniform(size=10))" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "plt.hist(np.random.normal(size=1000))" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "x, y = np.random.uniform(size=(2, 10))\n", "plt.scatter(x, y, marker=\"x\")" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "print(np.eye(5))\n", "plt.matshow(np.eye(5))" ], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }