Skip to content

Commit

Permalink
Added a notebook to teach the Notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
Catherine Devlin committed Mar 30, 2013
1 parent 0163fda commit 4a448b0
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 2 deletions.
139 changes: 139 additions & 0 deletions notebook_practice.ipynb
@@ -0,0 +1,139 @@
{
"metadata": {
"name": "notebook_practice"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"IPython Notebook practice\n",
"=========================\n",
"\n",
"Your next step is to learn how to use the IPython Notebook to run Python right here inside your browser. A Notebook is made of *cells*; some are text cells, like this one (Notebook calls them \"Markdown\" cells). The cell below this is a *code* cell that can run Python commands. In fact, it's waiting for you to run it right now!\n",
"\n",
"Click your mouse in the cell below this one. To tell the Notebook to execute that code, hold down `SHIFT` and hit `Enter`."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print \"Hello, Student!\""
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the next cell, try typing some code of your own. Type\n",
"\n",
" for food in [\"milk\", \"bread\", \"ugli fruit\"]:\n",
" print food\n",
"\n",
"and hit `SHIFT`+`Enter`.\n",
"\n",
"Notice that the code didn't execute when you hit `Enter` at the end of typing the first line. The notebook waits for `SHIFT`+`Enter` to execute the code."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can always go back and modify old cells. Click back in the cell *above* this one, change `\"bread\"` to `\"rice\"`, and use `SHIFT`+`Enter` to execute it again.\n",
"\n",
"----\n",
"\n",
"At the top of this page, there's a menu bar and a series of icons. Hover your mouse over the icons to see what they do. The only one you really need to learn now, though, is the one on the far left - the *save* icon (or File / Save from the menu). The IPython Notebook *does not autosave!* - so if you close this webpage down without saving, you'll lose all the work you've done on it! We think you'll want to keep it instead to refer to in the future. (If you actually want a fresh start, you can choose Cell / All Output / Clear from the menus.)\n",
"\n",
"----\n",
"\n",
"One wonderful thing about the IPython Notebook is that *it helps you cheat*. If you're in the middle of typing *anything* in a Notebook cell and you hit the `Tab` key, a dropdown list will appear with what IPython thinks you might want to type next. This can help you remember Python commands, variable names, etc., especially if you can remember the first letter.\n",
"\n",
"In the cell below, type `pr` and then hit `Tab`. Choose `print` from the dropdown list that appears. Then type ` 'yay for TAB!'` and hit `SHIFT`+`Enter`."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Tab completion can also show you what methods an object has. We haven't taught you those words yet, so I'm talking nonsense. But try this out now anyway, and later in the weekend it will be handy to you.\n",
"\n",
"Go to the next cell down and hit `SHIFT`+`Enter`. Now IPython knows about your variable `x`. Now go to the cell below that, put your cursor right after the period in `x.`, and hit `Tab`. A list of possible things you can do to `x` appears (really, they're things `x` can do to *itself* when you tell it to). Choose the first one, `capitalize`. Type `()` (open and close parentheses) immediately after it, so the whole thing looks like\n",
"\n",
" x.capitalize()\n",
"\n",
"and hit `SHIFT`+`Enter`."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"x = \"big\""
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"x."
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Nice, huh? You didn't even know the `capitalize` method existed, but IPython showed it to you.\n",
"\n",
"Success!\n",
"========\n",
"\n",
"You've seen the mechanics of working with the IPython Notebook. \n",
"Now it's time to work through the tutorial. \n",
"Save this page (remember the icon at the top left), then close it, \n",
"and choose \"day1.1\" from the list of notebooks on your IPython Dashboard."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
41 changes: 39 additions & 2 deletions setup.windows.ipynb
@@ -1,6 +1,6 @@
{
"metadata": {
"name": "friday.setup"
"name": "setup.windows"
},
"nbformat": 3,
"nbformat_minor": 0,
Expand All @@ -19,7 +19,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"In the directory of workshop materials, navigate into the \"windows\" directory and double-click \"install.bat\". Keep clicking the \"OK\" and \"Install\" buttons (accepting all the defaults) as it installs several programs on your computer:\n",
"Insert the CD or USB drive provided by the instructor. Using Windows Explorer (start it by pressing Windows key + \"E\"), drag the \"workshop\" folder onto your own computer to make your own copy of the class materials. Then you can remove the CD or USB drive and pass it along. If you can't use a CD or USB drive, download [this file](https://github.com/catherinedevlin/mpwfw_exercises/archive/master.zip) and have an instructor help you prepare it.\n",
"\n",
"Double-click the \"workshop\" folder you just copied to enter it, then double-click \"install.bat\". Keep clicking the \"OK\" and \"Install\" buttons (accepting all the defaults) as it installs several programs on your computer:\n",
"\n",
"* The Python language\n",
"* IPython, a special Python environment we'll use for the workshop\n",
Expand Down Expand Up @@ -238,6 +240,41 @@
"* When you run the python command with a file name as an argument, Python executes the Python code in that file."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Goal #6: Practice using IPython Notebook\n",
"========================================\n",
"\n",
"You'll spend most of this workshop using a Python tool called the *IPython Notebook*.\n",
"This lets you run IPython cells, which are like the interactive Python prompt you tried out\n",
"in Goal #3, right within your browser.\n",
"\n",
"1. Open a command window (see Goal #4) and use `cd` to navigate into the `workshop` directory. \n",
"\n",
"2. Type\n",
"\n",
" ipython notebook\n",
"\n",
" and hit `Enter`.\n",
"\n",
"3. Your browser should come up with a page called \"IP[y]: Notebook\". That's your IPython Dashboard; it has a list of notebooks. Click \"notebook_practice\" and follow the instructions on the notebook that it brings up.\n",
"\n",
"Goal #7: Tutorial\n",
"=================\n",
"\n",
"Go back to the IPython Dashboard page in your browser, and click the \"day1.1\" notebook. Follow along through that tutorial. Remember to ask lots of questions, to the instructors and to the other students - we're all here to help each other!"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
Expand Down

0 comments on commit 4a448b0

Please sign in to comment.