{
 "metadata": {
  "name": "",
  "signature": "sha256:03f3f522026b7ff6e1acac7746805bcac18faba022541a5d8a73470a897fdf7a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4, Some More Data Types"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Prgoram 4-1 , Page number: 47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# An illustration of the use of floating point numbers\n",
      "\n",
      "# There is no loss of precision in python\n",
      "a = 246.8\n",
      "b = 135.79\n",
      "\n",
      "answer = a + b\n",
      "print \"%f + %f = %f\"%(a,b,answer)\n",
      "\n",
      "answer = a - b\n",
      "print \"%f - %f = %f\"%(a,b,answer)\n",
      "\n",
      "answer = a * b\n",
      "print \"%f * %f = %f\"%(a,b,answer)\n",
      "\n",
      "answer = a / b\n",
      "print \"%f / %f = %f\"%(a,b,answer)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "246.800000 + 135.790000 = 382.590000\n",
        "246.800000 - 135.790000 = 111.010000\n",
        "246.800000 * 135.790000 = 33512.972000\n",
        "246.800000 / 135.790000 = 1.817512\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Program 4-2 , Page number: 49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Illustration of mixed mode expressions\n",
      "\n",
      "a = 2\n",
      "b = 12.34\n",
      "\n",
      "result = a * b\n",
      "print \"%d * %f = %f\"%(a,b,result)\n",
      "\n",
      "print \"%f in scientific notation is %e\"%(result,result)\n",
      "\n",
      "answer = a * b\n",
      "print \"%d * %f = %d\"%(a,b,answer)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "2 * 12.340000 = 24.680000\n",
        "24.680000 in scientific notation is 2.468000e+01\n",
        "2 * 12.340000 = 24\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Program 4-3 , Page number: 52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "ltr_1 = \"C\"\n",
      "ltr_2 = \" \"\n",
      "ltr_3 = \"i\"\n",
      "ltr_4 = \"s\"\n",
      "ltr_5 = \"g\"\n",
      "ltr_6 = \"r\"\n",
      "ltr_7 = \"e\"\n",
      "ltr_8 = \"a\"\n",
      "ltr_9 = \"t\"\n",
      "ltr_10 = \"!\"\n",
      "\n",
      "print \"%c%c%c%c%c%c%c%c%c%c%c\"%(ltr_1,ltr_2,ltr_3,ltr_4,ltr_2,ltr_5,ltr_6,ltr_7,ltr_8,ltr_9,ltr_10)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "C is great!\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}