{ "metadata": { "name": "", "signature": "sha256:f186500b3e40a8da71224a0bf9ffc9db8c12f47fbdc1547c7f763123da87850f" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Bio 723: Class Session 1" ] }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Help and Documentation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A key skill for becoming an efficient programmer is learning to efficiently navigate documentation resources. The Python standard library is very well documented, and can be quickly accessed from the IPython notebook help menu or online at the python.org website. Similar links to some of the more commonly used scientific and numeric libraries are also found in the Ipython help menu.\n", "\n", "In addition, there are several ways to access abbreviated versions of the documentation from the interpetter itself." ] }, { "cell_type": "code", "collapsed": false, "input": [ "help(min)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Help on built-in function min in module __builtin__:\n", "\n", "min(...)\n", " min(iterable[, key=func]) -> value\n", " min(a, b, c, ...[, key=func]) -> value\n", " \n", " With a single iterable argument, return its smallest item.\n", " With two or more arguments, return the smallest argument.\n", "\n" ] } ], "prompt_number": 8 }, { "cell_type": "code", "collapsed": false, "input": [ "?min # this will pop-up a documentation window in the ipython notebook" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 9 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Data Types" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Numeric data types" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One of the simplest ways to use the Python interpretter is as a fancy calculator. We'll illustrate this below and use this as an opportunity to introduce the core numeric data types that Python supports." ] }, { "cell_type": "code", "collapsed": false, "input": [ "# this is a comment, the interpretter ignores it\n", "# you can use comments to add short notes or explanation\n", "\n", "2 + 10 # add two integers (whole numbers)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 2, "text": [ "12" ] } ], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "2 + 3.14159 # add an integer and a real number (floating point number)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 3, "text": [ "5.14159" ] } ], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "2 * 10 # multiplication" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 4, "text": [ "20" ] } ], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "2 / 10.0 # division" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 5, "text": [ "0.2" ] } ], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ "2 / 10 # be careful with integer division! is the output what you expect?" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 6, "text": [ "0" ] } ], "prompt_number": 6 }, { "cell_type": "code", "collapsed": false, "input": [ "10 % 3 # The % (modulo) operator yields the remainder after division" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 11, "text": [ "1" ] } ], "prompt_number": 11 }, { "cell_type": "code", "collapsed": false, "input": [ "2**10 # exponentiation -- 2 raised to the power 10" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 12, "text": [ "1024" ] } ], "prompt_number": 12 }, { "cell_type": "code", "collapsed": false, "input": [ "2**0.5 # exponentiation with fractional powers, **0.5 = square root, **(1/3.) = cube root" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 8, "text": [ "1.4142135623730951" ] } ], "prompt_number": 8 }, { "cell_type": "code", "collapsed": false, "input": [ "(10+2)/(4-5) # numerical operators differ in their precedence\n", " # contrast the output of this line with the line below" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 9, "text": [ "-12" ] } ], "prompt_number": 9 }, { "cell_type": "code", "collapsed": false, "input": [ "(10+2)/4-5 # good habit to use parentheses to disambiguate potentially confusing calculations" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 10, "text": [ "-2" ] } ], "prompt_number": 10 }, { "cell_type": "code", "collapsed": false, "input": [ "(1 + 1j) # complex number" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 11, "text": [ "(1+1j)" ] } ], "prompt_number": 11 }, { "cell_type": "code", "collapsed": false, "input": [ "(1 + 1j) + (3 + 2j) # adding complex numbers" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 12, "text": [ "(4+3j)" ] } ], "prompt_number": 12 }, { "cell_type": "code", "collapsed": false, "input": [ "(0 + 1j) * (1j) # complex multiplication" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 13, "text": [ "(-1+0j)" ] } ], "prompt_number": 13 }, { "cell_type": "markdown", "metadata": {}, "source": [ "There is a built-in Python function called `type` that we can use to query a variable for it's data type" ] }, { "cell_type": "code", "collapsed": false, "input": [ "type(2)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 14, "text": [ "int" ] } ], "prompt_number": 14 }, { "cell_type": "code", "collapsed": false, "input": [ "type(2.0)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 15, "text": [ "float" ] } ], "prompt_number": 15 }, { "cell_type": "code", "collapsed": false, "input": [ "type(2 + 10.0) # when adding variables of two numeric types, the outcome\n", " # is always the more general type" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 16, "text": [ "float" ] } ], "prompt_number": 16 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Variable assignment" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The results of a calculation can be given a name, and then reused in a different context. This is called variable assignment." ] }, { "cell_type": "code", "collapsed": false, "input": [ "pi = 3.141592654\n", "radius = 4.0\n", "area_circ = pi * radius**2" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 17 }, { "cell_type": "code", "collapsed": false, "input": [ "area_circ" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 18, "text": [ "50.265482464" ] } ], "prompt_number": 18 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Functions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Functions encapsulate a series of related operations or calculations. Writing functions is fundamental to programming so we'll introduce them right away. The general form of a function definition in Python is:\n", "\n", "```\n", "def func_name(arg1, arg2, ...):\n", " body of function\n", " return result\n", "\n", "```\n", "\n", "Note that Python is white space sensitive, rather than using delimiters like braces. White space sensitivity often surprises people who are already familiar with other languages like C or Java. This feature of the language arguably lends iself to readability of code.\n", "\n", "As show above the body of a function definition must be indented. A Python aware editor / environment (like IPython) will help you get the indenting correct.\n", "\n", "Below, we present our first \"real\" function." ] }, { "cell_type": "code", "collapsed": false, "input": [ "def area_of_circle(radius):\n", " \"\"\"radius of circle --> area of circle\"\"\" \n", " return 3.141592654 * radius**2" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 20 }, { "cell_type": "markdown", "metadata": {}, "source": [ "We call our function as follows:" ] }, { "cell_type": "code", "collapsed": false, "input": [ "area_of_circle(4)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 2, "text": [ "50.265482464" ] } ], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "help(area_of_circle)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Help on function area_of_circle in module __main__:\n", "\n", "area_of_circle(radius)\n", " radius of circle --> area of circle\n", "\n" ] } ], "prompt_number": 21 }, { "cell_type": "markdown", "metadata": {}, "source": [ "When you define a function in the interpreter, it's immediately available for use. By contrast, functions and variables defined in modules or libraries you install usually need to be \"imported\"" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from math import factorial # import the factorial function from the math module\n", "help(factorial)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Help on built-in function factorial in module math:\n", "\n", "factorial(...)\n", " factorial(x) -> Integral\n", " \n", " Find x!. Raise a ValueError if x is negative or non-integral.\n", "\n" ] } ], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [ "print factorial(10) # factorial(x) = x * (x-1) * (x-2) .... * 2 * 1 " ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "3628800\n" ] } ], "prompt_number": 6 }, { "cell_type": "markdown", "metadata": {}, "source": [ "For this class, I've configured IPython to import a bunch of commonly used functions from Numpy and Matplotlib, which provide convenient functions for numerical computing and generating scientific figures." ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "In class assignment" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Write a function, `area_of_rect`, that calculates the area of a rectangle. Your function shoudl take two arguments, `length` and `width`." ] }, { "cell_type": "code", "collapsed": false, "input": [ "# write your area_of_rect function here\n" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Booleans" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Python has a data type to represent True and False values (Boolean variables) and supports standard Boolean operators like \"and\", \"or\", and \"not\"" ] }, { "cell_type": "code", "collapsed": false, "input": [ "x = True\n", "y = False" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 19 }, { "cell_type": "code", "collapsed": false, "input": [ "not x" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 20, "text": [ "False" ] } ], "prompt_number": 20 }, { "cell_type": "code", "collapsed": false, "input": [ "not y" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 21, "text": [ "True" ] } ], "prompt_number": 21 }, { "cell_type": "code", "collapsed": false, "input": [ "x and y" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 22, "text": [ "False" ] } ], "prompt_number": 22 }, { "cell_type": "code", "collapsed": false, "input": [ "x and (not y)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 23, "text": [ "True" ] } ], "prompt_number": 23 }, { "cell_type": "code", "collapsed": false, "input": [ "x or y" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 24, "text": [ "True" ] } ], "prompt_number": 24 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Comparison operators" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Python supports comparison operators on numeric data types. The results of applying these comparison operators are Booleans." ] }, { "cell_type": "code", "collapsed": false, "input": [ "4 < 5 # less than" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 25, "text": [ "True" ] } ], "prompt_number": 25 }, { "cell_type": "code", "collapsed": false, "input": [ "4 > 5 # greater than" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 26, "text": [ "False" ] } ], "prompt_number": 26 }, { "cell_type": "code", "collapsed": false, "input": [ "5 <= 5.0 # less than or equal to" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 27, "text": [ "True" ] } ], "prompt_number": 27 }, { "cell_type": "code", "collapsed": false, "input": [ "5 == 5 # tests equality" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 28, "text": [ "True" ] } ], "prompt_number": 28 }, { "cell_type": "code", "collapsed": false, "input": [ "5 == (5**0.5)**2 # the results of this might surprise you" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 29, "text": [ "False" ] } ], "prompt_number": 29 }, { "cell_type": "code", "collapsed": false, "input": [ "(5**0.5)**2 # the problem is that sqrt(5) can not be represented exactly with floating point numbers\n", " # this is not a limitation of Python but generally true for all programming languages" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 30, "text": [ "5.000000000000001" ] } ], "prompt_number": 30 }, { "cell_type": "code", "collapsed": false, "input": [ "# here's one way to test approximate equality when you suspect\n", "# a floating point calculation might be imprecise\n", "\n", "epsilon = 0.0000001\n", "(5 - epsilon) <= ((5**0.5)**2) <= (5 + epsilon)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 31, "text": [ "True" ] } ], "prompt_number": 31 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "None type" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The None type is used in Python to represent the absence of a value (or a null value). Many functions will return a None value if a calculation is valid but there's nothing to return. " ] }, { "cell_type": "code", "collapsed": false, "input": [ "x = None" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 32 }, { "cell_type": "code", "collapsed": false, "input": [ "type(x)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 33, "text": [ "NoneType" ] } ], "prompt_number": 33 }, { "cell_type": "code", "collapsed": false, "input": [ "x is None" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 34, "text": [ "True" ] } ], "prompt_number": 34 }, { "cell_type": "code", "collapsed": false, "input": [ "# this function takes no arguments\n", "# and implicitly returns None\n", "\n", "def say_something():\n", " print \"Something!\"\n", " \n" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 17 }, { "cell_type": "code", "collapsed": false, "input": [ "x = say_something()\n", "print x" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Something!\n", "None\n" ] } ], "prompt_number": 18 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Strings" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The next core data type we'll look at is strings." ] }, { "cell_type": "code", "collapsed": false, "input": [ "s1 = \"Now is the winter of our discontent\"" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 22 }, { "cell_type": "code", "collapsed": false, "input": [ "print(s1)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Now is the winter of our discontent\n" ] } ], "prompt_number": 23 }, { "cell_type": "markdown", "metadata": {}, "source": [ "String's can be specified using either single or double quotes." ] }, { "cell_type": "code", "collapsed": false, "input": [ "s2 = 'made glorious summer by this sun of York.'\n", "\n", "s3 = s1 + ', ' + s2 # strings can be concatenated" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 24 }, { "cell_type": "code", "collapsed": false, "input": [ "print(s3)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Now is the winter of our discontent, made glorious summer by this sun of York.\n" ] } ], "prompt_number": 25 }, { "cell_type": "code", "collapsed": false, "input": [ "len(s1) # get the length of the string" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 26, "text": [ "35" ] } ], "prompt_number": 26 }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are a variety of string related functions. Here are a few for illustration; check out the Python Standard Library for more." ] }, { "cell_type": "code", "collapsed": false, "input": [ "s3.title()" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 28, "text": [ "'Now Is The Winter Of Our Discontent, Made Glorious Summer By This Sun Of York.'" ] } ], "prompt_number": 28 }, { "cell_type": "code", "collapsed": false, "input": [ "s3.count('th') # count the number of times the substring appear in s3" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 30, "text": [ "2" ] } ], "prompt_number": 30 }, { "cell_type": "code", "collapsed": false, "input": [ "s3.split()" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 31, "text": [ "['Now',\n", " 'is',\n", " 'the',\n", " 'winter',\n", " 'of',\n", " 'our',\n", " 'discontent,',\n", " 'made',\n", " 'glorious',\n", " 'summer',\n", " 'by',\n", " 'this',\n", " 'sun',\n", " 'of',\n", " 'York.']" ] } ], "prompt_number": 31 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Indexing and Slicing Strings" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can access individual characters in a string by indexing. Python strings (and other sequences) are zero-indexed, meaning the first character is zero, and the last element of a string of length $n$ is $n-1$." ] }, { "cell_type": "code", "collapsed": false, "input": [ "print(s1)\n", "print \"Length of s1 is:\", len(s1) # print in version 2.7+ is a fxn\n", " # in version <= 2.7 print is a keyword" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Now is the winter of our discontent\n", "Length of s1 is: 35\n" ] } ], "prompt_number": 40 }, { "cell_type": "code", "collapsed": false, "input": [ "s1[0]" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 41, "text": [ "'N'" ] } ], "prompt_number": 41 }, { "cell_type": "code", "collapsed": false, "input": [ "s1[35] # whoops, generates an error!" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "IndexError", "evalue": "string index out of range", "output_type": "pyerr", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0ms1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m35\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;31m# whoops, generates an error!\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mIndexError\u001b[0m: string index out of range" ] } ], "prompt_number": 42 }, { "cell_type": "code", "collapsed": false, "input": [ "s1[34] # for a string of length, the index of the last element is 34" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 43, "text": [ "'t'" ] } ], "prompt_number": 43 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Indexing with negative numbers indexes from the end, starting with -1" ] }, { "cell_type": "code", "collapsed": false, "input": [ "s1[-1], s1[-2], s1[-3], s1[-4]" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 44, "text": [ "('t', 'n', 'e', 't')" ] } ], "prompt_number": 44 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Slicing is like indexing but allows you to retrieve more than one item at a time. Indexing goes from the first element (inclusive) to the last element (non-inclusive)" ] }, { "cell_type": "code", "collapsed": false, "input": [ "s1[0:6] # first six elements" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 45, "text": [ "'Now is'" ] } ], "prompt_number": 45 }, { "cell_type": "code", "collapsed": false, "input": [ "s1[6:10] # next four elements" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 46, "text": [ "' the'" ] } ], "prompt_number": 46 }, { "cell_type": "code", "collapsed": false, "input": [ "s1[-5:] # last five element" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 47, "text": [ "'ntent'" ] } ], "prompt_number": 47 }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can use extended slicing, `s[start:end:step]` as follows" ] }, { "cell_type": "code", "collapsed": false, "input": [ "s1[::2] # get every 2nd element" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 48, "text": [ "'Nwi h itro u icnet'" ] } ], "prompt_number": 48 }, { "cell_type": "code", "collapsed": false, "input": [ "s1[::-1] # get every element walking backwards in the string" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 49, "text": [ "'tnetnocsid ruo fo retniw eht si woN'" ] } ], "prompt_number": 49 }, { "cell_type": "code", "collapsed": false, "input": [ "s4 = \"GGGCGUGGCGCGUA\" # first few bases of the first nucleotide to be sequenced\n", " # alanine tRNA (Holley 1965)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 50 }, { "cell_type": "code", "collapsed": false, "input": [ "\"T\" in s4 # test for inclusion" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 51, "text": [ "False" ] } ], "prompt_number": 51 }, { "cell_type": "code", "collapsed": false, "input": [ "\"GUG\" in s4 # to for a substring" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 52, "text": [ "True" ] } ], "prompt_number": 52 }, { "cell_type": "code", "collapsed": false, "input": [ "s4.lower() # make lower case" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 53, "text": [ "'gggcguggcgcgua'" ] } ], "prompt_number": 53 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Data Structures" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Tuples" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Tuples are ordered collections of arbitrary Python objects." ] }, { "cell_type": "code", "collapsed": false, "input": [ "y = (1, 2, 3, 'a', 'b', 'c')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 89 }, { "cell_type": "code", "collapsed": false, "input": [ "print y[0], y[-1]" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "1 c\n" ] } ], "prompt_number": 90 }, { "cell_type": "code", "collapsed": false, "input": [ "w = y[:3], y[3:]" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 91 }, { "cell_type": "code", "collapsed": false, "input": [ "w[0]" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 92, "text": [ "(1, 2, 3)" ] } ], "prompt_number": 92 }, { "cell_type": "code", "collapsed": false, "input": [ "w[1]" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 93, "text": [ "('a', 'b', 'c')" ] } ], "prompt_number": 93 }, { "cell_type": "code", "collapsed": false, "input": [ "y[::-1]" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 94, "text": [ "('c', 'b', 'a', 3, 2, 1)" ] } ], "prompt_number": 94 }, { "cell_type": "code", "collapsed": false, "input": [ "len(y)" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 95, "text": [ "6" ] } ], "prompt_number": 95 }, { "cell_type": "code", "collapsed": false, "input": [ "del y[-1] # doesn't work, because tuples are immutable" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "TypeError", "evalue": "'tuple' object doesn't support item deletion", "output_type": "pyerr", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mdel\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;31m# doesn't work, because tuples are immutable\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mTypeError\u001b[0m: 'tuple' object doesn't support item deletion" ] } ], "prompt_number": 96 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Lists" ] }, { "cell_type": "code", "collapsed": false, "input": [ "x = [1,2,3,'a','b']" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 60 }, { "cell_type": "code", "collapsed": false, "input": [ "x[0]" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 61, "text": [ "1" ] } ], "prompt_number": 61 }, { "cell_type": "code", "collapsed": false, "input": [ "x[-1]" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 62, "text": [ "'b'" ] } ], "prompt_number": 62 }, { "cell_type": "code", "collapsed": false, "input": [ "x[:3]" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 63, "text": [ "[1, 2, 3]" ] } ], "prompt_number": 63 }, { "cell_type": "code", "collapsed": false, "input": [ "x[::-1] # returns the reversed list but doesn't change x" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 64, "text": [ "['b', 'a', 3, 2, 1]" ] } ], "prompt_number": 64 }, { "cell_type": "code", "collapsed": false, "input": [ "x" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 65, "text": [ "[1, 2, 3, 'a', 'b']" ] } ], "prompt_number": 65 }, { "cell_type": "code", "collapsed": false, "input": [ "x.reverse() # reverses the list in place, i.e. actually effects data" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 66 }, { "cell_type": "code", "collapsed": false, "input": [ "x" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 67, "text": [ "['b', 'a', 3, 2, 1]" ] } ], "prompt_number": 67 }, { "cell_type": "markdown", "metadata": {}, "source": [ "Lists, unlike strings and tuples, are mutable (i.e. can be changed)." ] }, { "cell_type": "code", "collapsed": false, "input": [ "y = [1,2,3,99,5,6] \n", "print y" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "[1, 2, 3, 99, 5, 6]\n" ] } ], "prompt_number": 68 }, { "cell_type": "code", "collapsed": false, "input": [ "y[3] = 4\n", "print y" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "[1, 2, 3, 4, 5, 6]\n" ] } ], "prompt_number": 69 }, { "cell_type": "code", "collapsed": false, "input": [ "w = [1,2,3, ['a', 'b', 'c'], 9, 10]" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 111 }, { "cell_type": "code", "collapsed": false, "input": [ "w" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 112, "text": [ "[1, 2, 3, ['a', 'b', 'c'], 9, 10]" ] } ], "prompt_number": 112 }, { "cell_type": "code", "collapsed": false, "input": [ "del w[3]\n", "print w" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "[1, 2, 3, 9, 10]\n" ] } ], "prompt_number": 113 }, { "cell_type": "code", "collapsed": false, "input": [ "w.append(99)\n", "print w" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "[1, 2, 3, 9, 10, 99]\n" ] } ], "prompt_number": 114 }, { "cell_type": "code", "collapsed": false, "input": [ "w.insert(4, 88)\n", "print w" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "[1, 2, 3, 9, 88, 10, 99]\n" ] } ], "prompt_number": 115 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Sets" ] }, { "cell_type": "code", "collapsed": false, "input": [ "x = {1,2,3,4,4,5}\n", "y = {3,6,8,9,1}" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 72 }, { "cell_type": "code", "collapsed": false, "input": [ "x" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 73, "text": [ "{1, 2, 3, 4, 5}" ] } ], "prompt_number": 73 }, { "cell_type": "code", "collapsed": false, "input": [ "y" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 74, "text": [ "{1, 3, 6, 8, 9}" ] } ], "prompt_number": 74 }, { "cell_type": "code", "collapsed": false, "input": [ "x & y # intersection of x and y" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 75, "text": [ "{1, 3}" ] } ], "prompt_number": 75 }, { "cell_type": "code", "collapsed": false, "input": [ "x | y # union of x and y" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 76, "text": [ "{1, 2, 3, 4, 5, 6, 8, 9}" ] } ], "prompt_number": 76 }, { "cell_type": "code", "collapsed": false, "input": [ "x - y # get elements of x that are not in y" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 77, "text": [ "{2, 4, 5}" ] } ], "prompt_number": 77 }, { "cell_type": "code", "collapsed": false, "input": [ "w = {1,2,3, [4,5] } # elements of sets must be non-mutable so a list can't be inserted" ], "language": "python", "metadata": {}, "outputs": [ { "ename": "TypeError", "evalue": "unhashable type: 'list'", "output_type": "pyerr", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mw\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m}\u001b[0m \u001b[0;31m# elements of sets must be non-mutable so a list can't be inserted\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mTypeError\u001b[0m: unhashable type: 'list'" ] } ], "prompt_number": 78 }, { "cell_type": "code", "collapsed": false, "input": [ "w = {1,2,3, (4,5) } # but a tuple works because it's non-mutable\n", "w" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 79, "text": [ "{1, 2, 3, (4, 5)}" ] } ], "prompt_number": 79 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Dictionaries" ] }, { "cell_type": "code", "collapsed": false, "input": [ "d = {'Fred': '919-555-1234', 'John': '919-666-1234', 'Mary':'919-222-1234'}" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 80 }, { "cell_type": "code", "collapsed": false, "input": [ "d['Mary']" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 81, "text": [ "'919-222-1234'" ] } ], "prompt_number": 81 }, { "cell_type": "code", "collapsed": false, "input": [ "d2 = {'Fred': {'Age':22, 'Phone':'919-555-1234'}, \n", " 'Mary':{'Age':33, 'Phone':'919-333-1234'}}" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 82 }, { "cell_type": "code", "collapsed": false, "input": [ "print \"Fred's age is: \", d2['Fred']['Age']" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Fred's age is: 22\n" ] } ], "prompt_number": 83 }, { "cell_type": "code", "collapsed": false, "input": [ "print \"Mary's phone number is: \", d2['Mary']['Phone']" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Mary's phone number is: 919-333-1234\n" ] } ], "prompt_number": 84 }, { "cell_type": "code", "collapsed": false, "input": [ "d2['Fred']['Address'] = \"123 Main St., Durham, NC, 27708\" # add elements to dictionary\n", "d2['Fred']" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 85, "text": [ "{'Address': '123 Main St., Durham, NC, 27708',\n", " 'Age': 22,\n", " 'Phone': '919-555-1234'}" ] } ], "prompt_number": 85 }, { "cell_type": "code", "collapsed": false, "input": [ "del d2['Mary'] # delete mary from the address book" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 86 }, { "cell_type": "code", "collapsed": false, "input": [ "d2" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 87, "text": [ "{'Fred': {'Address': '123 Main St., Durham, NC, 27708',\n", " 'Age': 22,\n", " 'Phone': '919-555-1234'}}" ] } ], "prompt_number": 87 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Control Flow Statements" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "for, range" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A \"for\" statement iterates over the elements in a seqeunce" ] }, { "cell_type": "code", "collapsed": false, "input": [ "for i in ['a','b','c','d']:\n", " print 'letter:',i\n", " " ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "letter: a\n", "letter: b\n", "letter: c\n", "letter: d\n" ] } ], "prompt_number": 102 }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `range` function creates a list of integers. Use `help` to read the range documentation" ] }, { "cell_type": "code", "collapsed": false, "input": [ "help(range)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Help on built-in function range in module __builtin__:\n", "\n", "range(...)\n", " range(stop) -> list of integers\n", " range(start, stop[, step]) -> list of integers\n", " \n", " Return a list containing an arithmetic progression of integers.\n", " range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.\n", " When step is given, it specifies the increment (or decrement).\n", " For example, range(4) returns [0, 1, 2, 3]. The end point is omitted!\n", " These are exactly the valid indices for a list of 4 elements.\n", "\n" ] } ], "prompt_number": 104 }, { "cell_type": "code", "collapsed": false, "input": [ "for i in range(10):\n", " print i, i**2" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "0 0\n", "1 1\n", "2 4\n", "3 9\n", "4 16\n", "5 25\n", "6 36\n", "7 49\n", "8 64\n", "9 81\n" ] } ], "prompt_number": 105 }, { "cell_type": "code", "collapsed": false, "input": [ "s = \"These are the times that try men's souls...\"\n", "pairs = []\n", "for i in range(len(s)):\n", " pairs.append((i, s[i]))\n", " " ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 106 }, { "cell_type": "code", "collapsed": false, "input": [ "pairs[:10]" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 108, "text": [ "[(0, 'T'),\n", " (1, 'h'),\n", " (2, 'e'),\n", " (3, 's'),\n", " (4, 'e'),\n", " (5, ' '),\n", " (6, 'a'),\n", " (7, 'r'),\n", " (8, 'e'),\n", " (9, ' ')]" ] } ], "prompt_number": 108 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "list comprehensions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "List comprehensions are a more compact and efficient way to iterate over the elements of a list, usually applying some function to the list elements. A list comprehension returns another list." ] }, { "cell_type": "code", "collapsed": false, "input": [ "x = range(-10,10)\n", "y = [i**2 - 2*i for i in x]\n", "plot(x,y) # the plot function comes from the Matplotlib drawing library" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 9, "text": [ "[]" ] }, { "metadata": {}, "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAEACAYAAABWLgY0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtclHXe//HXmFhbVlraoKDLHYKAB8LKflbaGA6mpamV\npeVNHtrKarM109y1qG4d7GyZd3untOTeD9PdSq1V0g5oB9Etyy1QMcVbRSBXw3OheP3++AZ5DpiB\na+aa9/PxmEcwzFzXxwk+85nP9T24LMuyEBERR2pkdwAiIlJ/lORFRBxMSV5ExMGU5EVEHExJXkTE\nwZTkRUQcrEZJfsSIEbjdbjp16lR937hx40hMTCQ5OZlBgwaxe/fu6p/5fD7i4uJISEhgyZIlgY9a\nRERqpEZJfvjw4eTk5BxzX1paGvn5+axZs4b4+Hh8Ph8ABQUFzJ07l4KCAnJychg9ejRHjhwJfOQi\nIvKrapTku3fvTvPmzY+5z+v10qiRefoVV1zBtm3bAFiwYAFDhgwhIi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Ots466yzL7XZb1113XfXPJk+ebMXGxlrt27e3cnJyGjq0kDds2DCrU6dOVufOna0bb7zRKi0t\ntTukkLNo0SIrPj7eio2NtaZMmWJ3OCFt06ZNVnJyspWcnGx16NBBr2cd3HbbbVarVq2siIgIKzo6\n2srKyrJ27txppaamWnFxcZbX67V++OGH0x5Dk6FERBwsaEbXiIhI4CnJi4g4mJK8iIiDKcmLiDiY\nkryIiIMpyYuIOJiSvIiIgynJi4g42P8H4IDYWUIbCDsAAAAASUVORK5CYII=\n", "text": [ "" ] } ], "prompt_number": 9 }, { "cell_type": "code", "collapsed": false, "input": [ "def sin_squared(x):\n", " return sin(x)**2\n", "\n", "x = [i*0.01 for i in range(500)]\n", "y = [sin_squared(i) for i in x]\n", "z = [sin(i) for i in x]\n", "\n", "plot(x,z)\n", "plot(x,y, color='red', linestyle='dashed')" ], "language": "python", "metadata": {}, "outputs": [ { "metadata": {}, "output_type": "pyout", "prompt_number": 34, "text": [ "[]" ] }, { "metadata": {}, "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEACAYAAAC9Gb03AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xt8jvX/B/DXzfANOZalbTWZzHkT1teh5jBCFpWi5CxJ\nX4dEByVUIuKHUVJOyQhhOWyUjcKMNac250Pb2ErM2Wbb9fvjjcI29+7rvu/PdV/36/l47FHLdXg3\n23uf6319Pu+PRdM0DUREZFpFVAdARESOxURPRGRyTPRERCbHRE9EZHJM9EREJsdET0RkcroTfe/e\nveHp6Yk6derke8ygQYNQrVo11KtXDwkJCXpvSUREhaA70ffq1QuRkZH5/vnatWtx+PBhHDp0CF99\n9RUGDBig95ZERFQIuhN9s2bNUL58+Xz/PCIiAj169AAABAUFISMjA+np6XpvS0REVnJ4jT41NRU+\nPj43P/f29kZKSoqjb0tERNc55WXs7V0WLBaLM25LREQAPBx9Ay8vLyQnJ9/8PCUlBV5eXncc5+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IHTp0QMuWLVWHZQjuXPpNT09Hs2bNbn5fPP3002jdunW+x3PBFBGRyfHVNRGRyTHRExGZHBM9\nEZHJMdETEZkcEz0Rkckx0RMRmRwTPRGRyTHRExGZ3P8DVjIGHHcKo00AAAAASUVORK5CYII=\n", "text": [ "" ] } ], "prompt_number": 34 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "if, if-else" ] }, { "cell_type": "code", "collapsed": false, "input": [ "for i in range(10):\n", " if (i % 2) == 0: # equivalent to asking if the number is even:\n", " print i, \"is even!\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "0 is even!\n", "2 is even!\n", "4 is even!\n", "6 is even!\n", "8 is even!\n" ] } ], "prompt_number": 15 }, { "cell_type": "code", "collapsed": false, "input": [ "for i in range(10):\n", " if (i % 2) == 0:\n", " print i, \"is even!\"\n", " else:\n", " print i, \"is odd.\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "0 is even!\n", "1 is odd.\n", "2 is even!\n", "3 is odd.\n", "4 is even!\n", "5 is odd.\n", "6 is even!\n", "7 is odd.\n", "8 is even!\n", "9 is odd.\n" ] } ], "prompt_number": 16 }, { "cell_type": "code", "collapsed": false, "input": [ "x = [1, 2, 3, 4.0, 5.0, 6 + 0j, 'one']\n", "for i in x:\n", " if type(i) == type(0):\n", " print i, 'is an integer number.'\n", " elif type(i) == type(0.0):\n", " print i, 'is a floating point number.'\n", " elif type(i) == type(0j):\n", " print i, 'is a complex number.'\n", " else:\n", " print \"I don't recongize\", i, \"as a number.\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "1 is an integer number.\n", "2 is an integer number.\n", "3 is an integer number.\n", "4.0 is a floating point number.\n", "5.0 is a floating point number.\n", "(6+0j) is a complex number.\n", "I don't recongize one as a number.\n" ] } ], "prompt_number": 24 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "break, continue" ] }, { "cell_type": "code", "collapsed": false, "input": [ "s = 'The quick brown fox jumped over the lazy dog.'\n", "articles = ['a', 'an', 'the']\n", "\n", "for word in s.split():\n", " if word in articles:\n", " print '-->', word, \"<-- I can't stand articles! I'm leaving.\"\n", " break\n", " else:\n", " print word\n", "\n", " \n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The\n", "quick\n", "brown\n", "fox\n", "jumped\n", "over\n", "--> the <-- I can't stand articles! I'm leaving.\n" ] } ], "prompt_number": 36 }, { "cell_type": "code", "collapsed": false, "input": [ "s = 'The quick brown fox jumped over the lazy dog.'\n", "articles = ['a', 'an', 'the']\n", "\n", "for word in s.split():\n", " if word in articles:\n", " print '-->', word, \"<-- I can't stand articles!\"\n", " continue\n", " print word" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The\n", "quick\n", "brown\n", "fox\n", "jumped\n", "over\n", "--> the <-- I can't stand articles!\n", "lazy\n", "dog.\n" ] } ], "prompt_number": 37 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }