{
 "metadata": {
  "name": "",
  "signature": "sha256:8925a816cb9ea05a6a48e6ec88b1e1778772a9e1e429803a5c922fb000f7f30d"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5: Arrays, qualifiers, and reading numbers"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.1, Page number: 84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variable declaration\n",
      "data = [ 34.0, 27.0, 45.0, 82.0, 22.0 ]\n",
      "\n",
      "# Calculation\n",
      "total = data[0] + data[1] + data[2] + data[3] + data[4]\n",
      "average = total/5.0\n",
      "\n",
      "# Result\n",
      "print ('Total %f Average %f' % (total, average))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total 210.000000 Average 42.000000\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.2, Page number: 87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variable declaration\n",
      "name = 'Sam'\n",
      "\n",
      "# Result\n",
      "print ('The name is %s' % name)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The name is Sam\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.3, Page number: 88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variable declaration\n",
      "first = 'Steve'\n",
      "last = 'Oualline'\n",
      "\n",
      "# Calculation\n",
      "full_name = first + ' ' + last\n",
      "\n",
      "# Result\n",
      "print ('The full name is %s' % full_name)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The full name is Steve Oualline\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.4, Page number: 89"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variable declaration\n",
      "line = 'hello world'\n",
      "\n",
      "# Result\n",
      "print ('The length of the line is %d' % len(line))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The length of the line is 11\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.5, Page number: 90"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variable declaration\n",
      "first = 'Steve'\n",
      "last = 'Oualline'\n",
      "\n",
      "# Calculation\n",
      "full = first + ' ' + last\n",
      "\n",
      "# Result\n",
      "print ('The name is %s' % full)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The name is Steve Oualline\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.6, Page number: 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variable declaration\n",
      "first = 'Steve'\n",
      "last = 'Oualline'\n",
      "\n",
      "# Calculation\n",
      "full = first + ' ' + last\n",
      "\n",
      "# Result\n",
      "print ('The name is %s' % full)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The name is Steve Oualline\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.7, Page number: 93"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variable declaration\n",
      "array = [[0 for x in range(5)] for x in range(5)]\n",
      "array[0][0] = 0 * 10 + 0\n",
      "array[0][1] = 0 * 10 + 1\n",
      "array[1][0] = 1 * 10 + 0\n",
      "array[1][1] = 1 * 10 + 1\n",
      "array[2][0] = 2 * 10 + 0\n",
      "array[2][1] = 2 * 10 + 1\n",
      "\n",
      "# Result\n",
      "print ('array[0]')\n",
      "print (array[0][0])\n",
      "print (array[0][1])\n",
      "print ('\\n')\n",
      "\n",
      "print ('array[1]')\n",
      "print (array[1][0])\n",
      "print (array[1][1])\n",
      "print ('\\n')\n",
      "\n",
      "print ('array[2]')\n",
      "print (array[2][0])\n",
      "print (array[2][1])\n",
      "print ('\\n')"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "array[0]\n",
        "0\n",
        "1\n",
        "\n",
        "\n",
        "array[1]\n",
        "10\n",
        "11\n",
        "\n",
        "\n",
        "array[2]\n",
        "20\n",
        "21\n",
        "\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.8, Page number: 94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variable declaration\n",
      "line = 4\n",
      "\n",
      "# Result\n",
      "print ('Twice %d is %d' % (line, line * 2))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Twice 4 is 8\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.9, Page number: 95"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variable declaration\n",
      "width = 12\n",
      "height = 10\n",
      "\n",
      "# Calculation\n",
      "area = (width * height) / 2\n",
      "\n",
      "# Result\n",
      "print ('The area is %d' % area)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The area is 60\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.10, Page number: 107"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variable declaration\n",
      "width = 4\n",
      "height = 6\n",
      "\n",
      "# Calculation\n",
      "area = (width * height) / 2\n",
      "\n",
      "# Result\n",
      "print ('The area is %d' % area)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The area is 12\n"
       ]
      }
     ],
     "prompt_number": 13
    }
   ],
   "metadata": {}
  }
 ]
}