{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Day 1 Tutorial" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Welcome to the Friday tutorial!\n", "\n", "This tutorial covers several core programming concepts that we'll build upon during an interactive lecture tomorrow morning. \n", "It will take 1-2 hours to complete. There's a break in the middle, and exercises at the middle and end to help review the material.\n", "\n", "This is an interactive tutorial! As you go through this tutorial, any time you see something that looks like this:\n", "\n", " a = \"Hello\"\n", " \n", "that's followed by an empty *code cell* (a light grey rectagle with a label like *\"In[ ]\"*), you should \n", "type the expression in the code cell, hit Shift+Return to *execute* it, and note the output.\n", "\n", "No copying and pasting! You'll learn the concepts better if you type them out yourself." ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Math" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![Calculator](files/images/100px-Calculator.png)\n", "\n", "Math in Python looks a lot like math you type into a calculator. A Python prompt makes a great calculator if you need to crunch some numbers and don't have a good calculator handy." ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Addition" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 2 + 2" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 1.5 + 2.25" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Subtraction" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 4 - 2" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 100 - .5" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 0 - 2" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Multiplication" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 2 * 3 " ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Division" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 4 / 2" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 1 / 2" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Hey now! That last result is probably not what you expected. What's going on here is that integer divison produces an integer. You need a number that knows about the decimal point to get a decimal out of division:\n", "\n", " 1.0 / 2" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This means you have to be careful when manipulating fractions. If you were doing some baking and needed to add 3/4 of a cup of flour and 1/4 of a cup of flour, we know in our heads that 3/4 + 1/4 = 1 cup. But try that at the Python prompt:\n", "\n", " 3/4 + 1/4" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What do you need to do to get the right answer? Use data types that understand decimals for each of the divisions:\n", "\n", " 3.0/4 + 1.0/4" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 3.0/4.0 + 1.0/4.0" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The two previous expressions produce the same result. You only need to make one of the numbers in each fraction have a decimal. When the Python interpreter goes to do the division, it notices that one of the numbers in the fraction cares about decimals and says \"that means I have to make the other number care about decimals too\"." ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Types" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![Image of shapes](files/images/150px-Geometry.png)\n", "\n", "There's a helpful function (more on what a function is in a second) called type that tells you what kind of thing -- what data type -- Python thinks something is. We can check for ourselves that Python considers '1' and '1.0' to be different data types:\n", "\n", " type(1)" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " type(1.0)" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So now we've seen two data types: integers and floats.\n", "\n", "I used the term 'function' without explaining what it is -- we'll talk about functions more in a bit, and write our own, but for now know these things:\n", "\n", "- Functions encapsulate some useful bit of work. We save that useful bit of work inside the function so we don't have to type it over and over again every time we want to use it. So, for example, some nice person decided that being able to determine the type of an object was useful, so he or she put the Python code that figures out an object's type into the function type, and now we all get to use it, instead of having to write it ourselves.\n", "- Functions are sort of like functions in math class. You provide input to a function and it produces output. The type function takes data as an input, and produces what type of data the data is (e.g. an integer or a float) as output.\n", "\n", "To use a function, write the name of the function followed by an open parenthesis, what the function takes as input (we call that input the arguments to the function), and then a close parenthesis.\n", "\n", "So in this case 'type' is the name of the function, and it takes one argument; in the example we first give type an argument of 1 and then give it an argument of 1.0." ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Variables" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A lot of work gets done in Python using variables. Variables are a lot like the variables in math class, except that in Python variables can be of any data type, not just numbers.\n", "\n", " type(4)" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " x = 4" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " x" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " type(x)" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 2 * x" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Giving a name to something, so that you can refer to it by that name, is called *assignment*. Above, we assigned the name \"`x`\" to 4, and after that we can use `x` wherever we want to use the number 4.\n", "\n", "Variables can't have spaces or other special characters, and they need to start with a letter. Here are some valid variable names:\n", "\n", " magic_number = 1500\n", " amountOfFlour = .75\n", " my_name = \"Jessica\"\n", "\n", "Projects develop naming conventions: maybe multi-word variable names use underscores (like magic_number), or \"camel case\" (like amountOfFlour). The most important thing is to be consistent within a project, because it makes the code more readable." ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Output" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Notice how if you type a 4 and hit enter, the Python interpreter spits a 4 back out:\n", "\n", " 4" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "But if you assign 4 to a variable, nothing is printed:\n", "\n", " x = 4" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can think of it as that something needs to get the output. Without an assignment, the winner is the screen. With assignment, the output goes to the variable.\n", "\n", "You can reassign variables if you want:\n", "\n", " x = 4" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " x" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " x = 5" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " x" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sometimes reassigning a variable is an accident and causes bugs in programs.\n", "\n", " x = 3" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " y = 4" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " x * y" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " x * x" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " 2 * x - 1 * y" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Order of operations works pretty much like how you learned in school. If you're unsure of an ordering, you can add parentheses like on a calculator:\n", "\n", " (2 * x) - (1 * y)" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that the spacing doesn't matter:\n", "\n", " x = 4" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and\n", "\n", " x=4" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "are both valid Python and mean the same thing.\n", "\n", " (2 * x) - (1 * y)" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " (2*x)-(1*y)" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "are also both valid and mean the same thing. You should strive to be consistent with whatever spacing you like or a job requires, since it makes reading the code easier.\n", "\n", "You aren't cheating and skipping typing these exercises out, are you? Good! :)" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Strings" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So far we've seen two data types: integers and floats. Another useful data type is a string, which is just what Python calls a bunch of characters (like numbers, letters, whitespace, and punctuation) put together. Strings are indicated by being surrounded by quotes:\n", "\n", " \"Hello\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " \"Python, I'm your #1 fan!\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Like with the math data types above, we can use the type function to check the type of strings:\n", "\n", " type(\"Hello\")\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " type(1)" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " type(\"1\")" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "String Concatenation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can smoosh strings together (called \"concatenation\") using the '+' sign:\n", "\n", " \"Hello\" + \"World\"\n", " name = \"Jessica\"\n", " print \"Hello \" + name" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Printing" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can print strings using print:\n", "\n", " h = \"Hello\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " w = \"World\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " print h + w\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " my_string = h + \" Weird \" + w\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " print my_string\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "How about printing different data types together?\n", "\n", " print \"Hello\" + 1" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Hey now! The output from the previous example was really different and interesting; let's break down exactly what happened:\n", "\n", " >>> print \"Hello\" + 1 \n", " Traceback (most recent call last):\n", " File \"\", line 1, in \n", " TypeError: cannot concatenate 'str' and 'int' objects\n", "\n", "Python is giving us a *traceback*. A traceback is details on what was happening when Python encountered an Exception or Error -- something it doesn't know how to handle.\n", "\n", "There are many kinds of Python errors, with descriptive names to help us humans understand what went wrong. In this case we are getting a TypeError: we tried to do some operation on a data type that isn't supported for that data type.\n", "\n", "Python gives us a helpful error message as part of the TypeError:\n", "\n", " \"cannot concatenate 'str' and 'int' objects\"\n", "\n", "We saw above the we can concatenate strings:\n", "\n", " print \"Hello\" + \"World\"\n", "\n", "works just fine.\n", "\n", "However,\n", "\n", " print \"Hello\" + 1\n", "\n", "produces a TypeError. We are telling Python to concatenate a string and an integer, and that's not something Python understands how to do.\n", "\n", "We can convert an integer into a string ourselves, using the `str` function:\n", "\n", " print \"Hello\" + str(1)" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Like the type function from before, the str function takes 1 argument. In the above example it took the integer 1. str takes a Python object as input and produces a string version of that input as output." ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "String Length" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There's another useful function that works on strings called len. len returns the length of a string as an integer:\n", "\n", " print len(\"Hello\")" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " print len(\"\")\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " fish = \"humuhumunukunukuapua\u02bba\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " length = str(len(fish))\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " print fish + \" is a Hawaiian fish whose name is \" + length + \" characters long.\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Quotes" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We've been using double quotes around our strings, but you can use either double or single quotes:\n", "\n", " print 'Hello'\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " print \"Hello\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Like with spacing above, use whichever quotes make the most sense for you, but be consistent.\n", "You do have to be careful about using quotes inside of strings:\n", "\n", " print 'I'm a happy camper'\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This gives us another traceback, for a new kind of error, a **SyntaxError**. When Python looks at that expression, it sees the string *'I'* and then\n", "*m a happy camper'*\n", "which it doesn't understand -- it's not 'valid' Python. Those letters aren't variables (we haven't assigned them to anything), and that trailing quote isn't balanced. So it raises a SyntaxError.\n", "\n", "We can use double quotes to avoid this problem:\n", "\n", " print \"I'm a happy camper\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "or we can *escape* the quote with a backslash:\n", "\n", " print 'I\\'m a happy camper'\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " print 'Ada Lovelace is often called the world\\'s first programmer.'\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " print \"Computer scientist Grace Hopper popularized the term \\\"debugging\\\".\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One fun thing about strings in Python is that you can multiply them:\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " print \"A\" * 40\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " print \"ABC\" * 12\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " h = \"Happy\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " b = \"Birthday\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ " print (h + b) * 10\n" ] }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Part 1 Practice" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We won't make you type these next cells - but before you execute them, see if you can predict what the output will be. Then execute the cells and check your guess." ] }, { "cell_type": "code", "collapsed": false, "input": [ "total = 1.5 - 1/2 + ((-2.0/2) - (1.0/2))\n", "print total" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "type(total)" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "a = \"quick\"\n", "b = \"brown\"\n", "c = \"fox jumps over the lazy dog\"\n", "print \"The \" + a * 3 + \" \" + b * 3 + \" \" + c" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "print 2.0 * 123 + str(2.0) * 123" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "a = \"| (_| -()- -()- -()- -()- | -()- -()- -()- -()- ||\\n\"\n", "b = \"|_\\_|_/___|__|__|__|___|__|___|__|___________________________||\\n\"\n", "c = \"|________________________________|__|__()_|__()_|__()__|_____||\\n\"\n", "d = \" ___|)_______________________________________________________\\n\"\n", "e = \"|_/(|,\\____/_|___/_|____/_|______|___________________________||\\n\"\n", "f = \"|___/____________________________|___________________________||\\n\"\n", "g = \"| | | () | () | () | | ||\\n\"\n", "h = \"|__\\___|.________________________|___\\_|___\\_|___\\_|___|_____||\\n\"\n", "i = \"|__/|_______/|____/|_____/|______|___________________________||\\n\"\n", "j = \"|_____/__________________________|____\\|____\\|____\\|_________||\\n\"\n", "k = \"|____/___________________________|___________________________||\\n\"\n", "l = \"|__/___\\_._______________________|__|__|__|__|__|__|___|_____||\\n\"" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "print d + f + i + e + b + g + a + c + l + h + j + k" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "End of Part 1\n", "=============\n", "\n", "\n", "Congratulations! You've learned about and practiced math, strings, variables, data types, exceptions, tracebacks, and executing Python from the Python prompt.\n", "Take a break, stretch, meet some neighbors, and ask the staff if you have any questions about this material.\n", "\n", "\n" ] } ], "metadata": {} } ] }