{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Python scripts" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Until now we've been executing commands in the IPython Notebook. But usually, when you get code from other people, it doesn't come in IPython Notebooks, comes in Python files. These are just plain-text files of Python commands.\n", "\n", "There's a file in the same directory as these notebooks called *nobel.py*. The \".py\" extension hints that this is a Python script.\n", "\n", "Open a command prompt, and use the navigation commands (`dir` and `cd` on Windows; `ls`, `pwd`, and `cd` on OS X and Linux) to navigate to your directory of workshop exercises. See \"Practice navigating the computer from a command prompt\" in your Setup notebook ([Windows](setup.windows.ipynb), [Mac](setup.mac.ipynb), [Linux](setup.linux.ipynb)) for a refresher on those commands (or just ask for help!)\n", "\n", "Once you are in the workshop directory, execute the contents of nobel.py by typing\n", "\n", " python nobel.py\n", "\n", "at a command prompt.\n", "\n", "*nobel.py* introduces two new concepts: comments and multiline strings.\n", "\n", "Open nobel.py in your text editor (see preparing your text editor for a refresher on starting the editor).\n", "\n", "Read through the file in your text editor carefully and check your understanding of both the comments and the code.\n", "\n", "Study the script until you can answer these questions:\n", "\n", "* How do you comment code in Python?\n", "* How do you print just a newline?\n", "* How do you print a multi-line string so that whitespace is preserved?\n", "\n", "Let's get back to some interactive examples. Keep typing them out! You'll thank yourself tomorrow. :)" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Booleans" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So far, the code we've written has been unconditional: no choice is getting made, and the code is always run. Python has another data type called a boolean that is helpful for writing code that makes decisions. There are two booleans: True and False.\n", "\n", " True\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " False" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Flow Control" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "`if` statements" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can use these expressions that evaluate to booleans to make decisions and conditionally execute code:\n", "\n", " if 6 > 5:\n", " print \"Six is greater than five!\"\n", "\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "That was our first multi-line piece of code, and those four spaces at the beginning of the second line are important; don't leave them out! \n", "\n", "When you're typing at the regular, command-line Python prompt, instead of this IPython Notebook, the way you enter Python containing this kind of \"block\" is a little different. Go to the command prompt window and try this:\n", "\n", "- First, type the if 6 > 5: part, and hit enter. The next line will have *...* as a prompt, instead of the usual *>>>*. This is Python telling us that we are in the middle of a code block, and so long as we indent our code it should be a part of this code block.\n", "- Type 4 spaces, and then type print \"Six is greater than five!\". \n", "- Hit enter to end the line, and hit enter again to tell Python you are done with this code block. \n", "\n", "All together, it will look like this:\n", "\n", " >>> if 6 > 5:\n", " ... print \"Six is greater than five!\"\n", " ... \n", "\n", "Six is greater than five!\n", "\n", "So what is going on here? When Python encounters the if keyword, it evaluates the expression following the keyword and before the colon. If that expression is True, Python executes the code in the indented code block under the if line. If that expression is False, Python skips over the code block.\n", "\n", "In this case, because 6 really is greater than 5, Python executes the code block under the if statement, and we see \"Six is greater than five!\" printed to the screen. Guess what will happen with these other expressions, then type them out and see if your guess was correct:\n", "\n", " if 0 > 2:\n", " print \"Zero is greater than two!\"\n", " if \"banana\" in \"bananarama\":\n", " print \"I miss the 80s.\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "more choices: `if` and `else`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can use the else keyword to execute code only when the if expression isn't True:\n", "\n", " sister_age = 15\n", " brother_age = 12\n", " if sister_age > brother_age:\n", " print \"sister is older\"\n", " else:\n", " print \"brother is older\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Like with `if`, the code block under the `else` statement must be indented so Python knows that it is a part of the else block." ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "compound conditionals: `and` and `or`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can check multiple expressions together using the and and or keywords. If two expressions are joined by an and, they both have to be True for the overall expression to be True. If two expressions are joined by an or, as long as at least one is True, the overall expression is True.\n", "\n", "Try typing these out and see what you get:\n", "\n", " 1 > 0 and 1 < 2\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 1 < 2 and \"x\" in \"abc\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \"a\" in \"hello\" or \"e\" in \"hello\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1 <= 0 or \"a\" not in \"abc\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Before you execute these next two examples, try to guess what they will print, then execute them and see if you are correct Make sure you understand why some of the lines are indented; feel free to ask a staff member to help explain. It is important to be comfortable with indenting for tomorrow." ] }, { "cell_type": "code", "collapsed": false, "input": [ "temperature = 32\n", "if temperature > 60 and temperature < 75:\n", " print \"It's nice and cozy in here!\"\n", "else:\n", " print \"Too extreme for me.\"\n" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "hour = 11\n", "if hour < 7 or hour > 23:\n", " print \"Go away!\"\n", " print \"I'm sleeping!\"\n", "else:\n", " print \"Welcome to the cheese shop!\"\n", " print \"Can I interest you in some choice gouda?\"" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can have as many lines of code as you want in if and else blocks; just make sure to indent them so Python knows they are a part of the block." ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "even more choices: elif" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you have more than two cases, you can use the elif keyword to check more cases. You can have as many elif cases as you want; Python will go down the code checking each elif until it finds a True condition or reaches the default else block.\n", " \n", " sister_age = 15\n", " brother_age = 12\n", " if sister_age > brother_age:\n", " print \"sister is older\"\n", " elif sister_age == brother_age:\n", " print \"sister and brother are the same age\"\n", " else:\n", " print \"brother is older\"" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You don't have to have an else block, if you don't need it. That just means there isn't default code to execute when none of the if or elif conditions are True:\n", " \n", " color = \"orange\"\n", " if color == \"green\" or color == \"red\":\n", " print \"Christmas color!\"\n", " elif color == \"black\" or color == \"orange\":\n", " print \"Halloween color!\"\n", " elif color == \"pink\":\n", " print \"Valentine's Day color!\"" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now go back to the cell above, change the first line to read\n", "\n", " color = 'purple'\n", " \n", "and execute it - notice how it doesn't print anything. Remember that '=' is for assignment (**make** this equal that!) and '==' is for comparison (**does** this equal that**?**).\n", "\n", "[edit]Writing Functions\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " type(True)\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " False\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "type(False)\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "You can test if Python objects are equal or unequal. The result is a boolean:\n", "\n", " 0 == 0\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 0 == 1\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Use == to test for equality. Recall that = is used for assignment.\n", "This is an important idea and can be a source of bugs until you get used to it: = is assignment, == is comparison.\n", "Use != to test for inequality:\n", " \"a\" != \"a\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \"a\" != \"A\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "<, <=, >, and >= have the same meaning as in math class. The result of these tests is a boolean:\n", " 1 > 0\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 2 >= 3\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " -1 < 0\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " .5 <= 1\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can check for containment with the in keyword, which also results in a boolean:\n", " \n", " \"H\" in \"Hello\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \"X\" in \"Hello\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or check for a lack of containment with not in:\n", "\n", " \"a\" not in \"abcde\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \"Perl\" not in \"Boston Python Workshop\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Flow Control\n", "============\n", "\n", "\n", "if statements\n", "-------------\n", "\n", "We can use these expressions that evaluate to booleans to make decisions and conditionally execute code:\n", "\n", " if 6 > 5:\n", " print \"Six is greater than five!\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "That was our first multi-line piece of code, and we need to pay attention to the indentation on the second line.\n", "Make sure to hit space four times before typing the second line; Python needs them to understand what we want it\n", "to do. \n", "\n", "Try typing this same code at a regular command prompt (outside this notebook), too; you'll see that \n", "it works differently:\n", "\n", "- First, type the if 6 > 5: part, and hit enter. The next line will have **...** as a prompt, \n", "instead of the usual **>>>**. This is Python telling us that we are in the middle of a code block, \n", "and so long as we indent our code it should be a part of this code block.\n", "\n", "- Type 4 spaces, and then type print \"Six is greater than five!\". \n", "\n", "- Hit enter to end the line, and hit enter again to tell Python you are done with this code block. \n", "\n", "All together, in the command-prompt window, it will look like this:\n", "\n", " >>> if 6 > 5:\n", " ... print \"Six is greater than five!\"\n", " ... \n", " \n", "Six is greater than five!\n", "\n", "So what is going on here? When Python encounters the if keyword, it evaluates the expression following the keyword and before the colon. \n", "\n", "If that expression is True, Python executes the code in the indented code block under the if line. \n", "\n", "If that expression is False, Python skips over the code block.\n", "\n", "In this case, because 6 really is greater than 5, Python executes the code block under the if statement, \n", "and we see \"Six is greater than five!\" printed to the screen. Guess what will happen with these other expressions, \n", "then type them out and see if your guess was correct:\n", "\n", " if 0 > 2:\n", " print \"Zero is greater than two!\"\n", " if \"banana\" in \"bananarama\":\n", " print \"I miss the 80s.\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "more choices: if and else\n", "-------------------------\n", "\n", "You can use the else keyword to execute code only when the if expression isn't True:\n", "\n", " sister_age = 15\n", " brother_age = 12\n", " if sister_age > brother_age:\n", " print \"sister is older\"\n", " else:\n", " print \"brother is older\"\n", "\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Like with if, the code block under the else statement must be indented so Python knows that it is a part of the else block.\n", "\n", "compound conditionals: and and or\n", "---------------------------------\n", "\n", "You can check multiple expressions together using the and and or keywords. \n", "\n", "If two expressions are joined by an and, they both have to be True for the overall expression to be True. \n", "\n", "If two expressions are joined by an or, as long as at least one is True, the overall expression is True.\n", "\n", "Try typing these out and see what you get:\n", "\n", " 1 > 0 and 1 < 2\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 1 < 2 and \"x\" in \"abc\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \"a\" in \"hello\" or \"e\" in \"hello\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 1 <= 0 or \"a\" not in \"abc\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Guess what will happen when you enter these next two examples, and then type them out and see if you are correct. If you have trouble with the indenting, call over a staff member and practice together. It is important to be comfortable with indenting for tomorrow.\n", "\n", " temperature = 32\n", " if temperature > 60 and temperature < 75:\n", " print \"It's nice and cozy in here!\"\n", " else:\n", " print \"Too extreme for me.\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " hour = 11\n", " if hour < 7 or hour > 23:\n", " print \"Go away!\"\n", " print \"I'm sleeping!\"\n", " else:\n", " print \"Welcome to the cheese shop!\"\n", " print \"Can I interest you in some choice gouda?\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can have as many lines of code as you want in if and else blocks; just make sure to indent them so Python knows they are a part of the block.\n", "\n", "even more choices: elif\n", "-----------------------\n", "\n", "If you have more than two cases, you can use the elif keyword to check more cases. You can have as many elif cases as you want; Python will go down the code checking each elif until it finds a True condition or reaches the default else block.\n", "\n", " sister_age = 15\n", " brother_age = 12\n", " if sister_age > brother_age:\n", " print \"sister is older\"\n", " elif sister_age == brother_age:\n", " print \"sister and brother are the same age\"\n", " else:\n", " print \"brother is older\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You don't have to have an else block, if you don't need it. That just means there isn't default code to execute when none of the if or elif conditions are True:\n", "\n", " color = \"orange'\n", " if color == \"green\" or color == \"red\":\n", " print \"Christmas color!\"\n", " elif color == \"black\" or color == \"orange\":\n", " print \"Halloween color!\"\n", " elif color == \"pink\":\n", " print \"Valentine's Day color!\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Now go back to the cell above and change the first line to read\n", "\n", " color = 'purple'\n", " \n", "Execute the cell again. Notice that, this time, nothing is printed.\n", "\n", "Remember that '`=`' is for assignment (**make** this equal that) and '`==`' is for comparison (**does** this equal that**?**).\n" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Writing Functions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We talked a bit about functions when we introduced the type() function. Let's review what we know about functions:\n", "\n", "- They do some useful bit of work.\n", "- They let us re-use code without having to type it out each time.\n", "- They take input and possibly produce output (we say they return a value). You can assign a variable to this output.\n", "\n", "You call a function by using its name followed by its arguments in parenthesis.\n", "\n", "For example:\n", "\n", " length = len(\"Mississippi\")\n", "\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Executing this code assigns the length of the string \"Mississippi\" to the variable length. See what it did:\n", "\n", " length\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "We can write our own functions to encapsulate bits of useful work so we can reuse them. Here's how you do it:\n" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Step 1: write a function *signature*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A function *signature* tells you how the function will be called. It starts with the keyword `def`, which tells Python that you are *defining* a function. Then comes a space, the name of your function, an open parenthesis, the comma-separated input parameters for your function, a close parenthesis, and a colon. Here's what a function signature looks like for a function that takes no arguments:\n", "\n", " def myFunction():\n", "\n", "Here's what a function signature looks like for a function that takes one argument called string:\n", "\n", " def myFunction(string):\n", "\n", "And one for a function that takes two arguments:\n", "\n", " def myFunction(myList, myInteger):\n", "\n", "Parameters should have names that usefully describe what they are used for in the function.\n", "\n", "We've used the words \"parameters\" and \"arguments\" seemingly interchangeably to reference the input to functions. The distinction isn't really important right now, but if you're curious: in function signatures the input is called parameters, and when you are calling the function the input is called arguments." ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Step 2: do useful work inside the function" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Underneath the function signature you do your useful work. Everything inside the function is indented, just like with if/else blocks, so Python knows that it is a part of the function.\n", "\n", "You can use the variables passed into the function as parameters, just like you can use variables once you define them outside of functions.\n", "\n", " def add(x, y):\n", " result = x + y" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Step 3: return something" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you want to be able to assign a variable to the output of a function, the function has to return that output using the return keyword.\n", "\n", " def add(x, y):\n", " result = x + y\n", " return result\n", "\n", "or, even shorter:\n", "\n", " def add(x, y):\n", " return x + y\n", "\n", "You can return any Python object: numbers, strings, booleans ... even other functions!\n", "\n", "Once you execute a return, you are done with the function -- you don't get to do any more work. That means if you have a function like this:\n", "\n", " def absoluteValue(number):\n", " if number < 0:\n", " return number * -1\n", " return number\n", "\n", "if number is less than 0, you return number * -1 and never even get to the last line of the function. However, if number is greater than or equal to 0, the if expression evaluates to False, so we skip the code in the if block and return number.\n", "\n", "We could have written the above function like this if we wanted. It's the same logic, just more typing:\n", "\n", " def absoluteValue(number):\n", " if number < 0:\n", " return number * -1\n", " else:\n", " return number" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Step 4: use the function" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once you define a function you can use it as many times as you want. Go ahead and type this function definition in and execute it.\n", "\n", " def add(x, y):\n", " return x + y\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now you can use it as many times as you want, passing in whatever arguments you want." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " result = add(1234, 5678)\n", " print result\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", " result = add(-1.5, .5)\n", " print result\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "Functions don't have to return anything, if you don't want them to. They usually return something because we usually want to be able to assign variables to their output." ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "End of Part 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Congratulations! You've learned about and practiced executing Python scripts, booleans, conditionals, and if/else blocks, and you've written your own Python functions. This is a huge, huge accomplishment!\n", "\n", "Take a break, stretch, meet some neighbors, and ask the staff if you have any questions about this material.\n", "\n", "\n", "\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }