{
 "metadata": {
  "name": "",
  "signature": "sha256:785237ffc865ddc47952e10309b1bb53ee1543217e833069c02c2afb50bff287"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4: Basic declarations and expressions"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.1, Page number: 71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variable declaration\n",
      "x = (1 + 2) * 4\n",
      "\n",
      "# Result\n",
      "print ('1 plus 2 multiplied by 4 gives %d' % x)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1 plus 2 multiplied by 4 gives 12\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.2, Page number: 75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variable declaration\n",
      "term = 3 * 5\n",
      "term_2 = 2 * term\n",
      "term_3 = 3 * term\n",
      "\n",
      "# Result\n",
      "print ('Twice %d is %d' % (term, term_2))\n",
      "print ('Three times %d is %d' % (term, term_3))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Twice 15 is 30\n",
        "Three times 15 is 45\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.3, Page number: 77"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variable declaration\n",
      "term = 3 * 5\n",
      "term_2 = 2 * term\n",
      "term_3 = 3 * term\n",
      "\n",
      "# Result\n",
      "print ('Twice %d is %d' % (term, term_2))\n",
      "print ('Three times %d is %d' % (term, term_3))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Twice 15 is 30\n",
        "Three times 15 is 45\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.4, Page number: 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variable declaration\n",
      "answer = 1/3\n",
      "\n",
      "# Result\n",
      "print ('The value of 1/3 is %f' % answer)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of 1/3 is 0.000000\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.5, Page number: 80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "answer = 2 + 2\n",
      "\n",
      "# Result\n",
      "print ('The answer is %d' % answer)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The answer is 4\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.6, Page number: 80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variable declaration\n",
      "result = 7.0/22.0\n",
      "\n",
      "# Result\n",
      "print ('The result is %d' % result)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The result is 0\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.7, Page number: 82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variable declaration\n",
      "char1 = 'A'\n",
      "char2 = 'B'\n",
      "char3 = 'C'\n",
      "\n",
      "# Result\n",
      "print ('%c%c%c reversed is %c%c%c' % (char1, char2, char3, char3, char2, char1))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ABC reversed is CBA\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}