diff --git a/Examples/PythonPackageExample/python/tutorials/ThinkerExample.ipynb b/Examples/PythonPackageExample/python/tutorials/ThinkerExample.ipynb new file mode 100644 index 0000000000..63304ba78c --- /dev/null +++ b/Examples/PythonPackageExample/python/tutorials/ThinkerExample.ipynb @@ -0,0 +1,148 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This is a very short example showing how a ipython notebook tutorial could look like" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# The next three line tell python where to look for the code\n", + "# in case the package was installed (e.g. make install) they are not necessary.\n", + "import os\n", + "import sys\n", + "sys.path.insert(0, os.path.abspath('..'))\n", + "\n", + "# import our great new class\n", + "from sample.thinker import Thinker" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "currently I'm thinking of...\n", + "delicious\n", + "open\n", + "camel\n", + "camel\n", + "camel\n" + ] + } + ], + "source": [ + "# create a thinker and let it think\n", + "initial_nr_thoughts = 5\n", + "thinker = Thinker(initial_nr_thoughts)\n", + "thinker.think_out_loud()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "currently I'm thinking of...\n", + "toe\n", + "toe\n", + "delicious\n", + "open\n", + "toe\n" + ] + } + ], + "source": [ + "# our thinker will produce new thoughts every time we call it\n", + "thinker.think_out_loud()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "currently I'm thinking of...\n", + "camel\n", + "open\n" + ] + } + ], + "source": [ + "# we can also manipulate the number of thoughts it thinks\n", + "thinker.number_of_thoughts = 2\n", + "thinker.think_out_loud()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "That's it, what a great tutorial!" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +}