From 8048392490bd2efe0fdfa001945f663cba969841 Mon Sep 17 00:00:00 2001 From: nice Date: Thu, 9 Oct 2014 18:07:00 +0530 Subject: updated books --- .../KamthaneChapter10.ipynb | 2940 ++ .../KamthaneChapter11.ipynb | 446 + .../KamthaneChapter12.ipynb | 849 + .../KamthaneChapter13.ipynb | 2367 ++ .../KamthaneChapter14.ipynb | 2311 + .../KamthaneChapter15.ipynb | 754 + .../KamthaneChapter16.ipynb | 2160 + .../KamthaneChapter3.ipynb | 1060 + .../KamthaneChapter4.ipynb | 972 + .../KamthaneChapter5.ipynb | 2624 ++ .../KamthaneChapter6.ipynb | 42312 +++++++++++++++++++ .../KamthaneChapter7.ipynb | 3644 ++ .../KamthaneChapter8.ipynb | 2750 ++ .../KamthaneChapter9.ipynb | 1999 + Programming_in_C_using_ANSI_C/README.txt | 10 + .../screenshots/screenshot1.png | Bin 0 -> 124312 bytes .../screenshots/screenshot1_1.png | Bin 0 -> 124312 bytes .../screenshots/screenshot2.png | Bin 0 -> 133043 bytes .../screenshots/screenshot2_1.png | Bin 0 -> 133043 bytes .../screenshots/screenshot3.png | Bin 0 -> 125297 bytes .../screenshots/screenshot3_1.png | Bin 0 -> 125297 bytes 21 files changed, 67198 insertions(+) create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter10.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter11.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter12.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter13.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter14.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter15.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter16.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter3.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter4.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter5.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter6.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter7.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter8.ipynb create mode 100755 Programming_in_C_using_ANSI_C/KamthaneChapter9.ipynb create mode 100755 Programming_in_C_using_ANSI_C/README.txt create mode 100755 Programming_in_C_using_ANSI_C/screenshots/screenshot1.png create mode 100755 Programming_in_C_using_ANSI_C/screenshots/screenshot1_1.png create mode 100755 Programming_in_C_using_ANSI_C/screenshots/screenshot2.png create mode 100755 Programming_in_C_using_ANSI_C/screenshots/screenshot2_1.png create mode 100755 Programming_in_C_using_ANSI_C/screenshots/screenshot3.png create mode 100755 Programming_in_C_using_ANSI_C/screenshots/screenshot3_1.png (limited to 'Programming_in_C_using_ANSI_C') diff --git a/Programming_in_C_using_ANSI_C/KamthaneChapter10.ipynb b/Programming_in_C_using_ANSI_C/KamthaneChapter10.ipynb new file mode 100755 index 00000000..68503d70 --- /dev/null +++ b/Programming_in_C_using_ANSI_C/KamthaneChapter10.ipynb @@ -0,0 +1,2940 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Chapter 10: Functions

" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.1, Page number: 320

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#user defined function\n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "x = 1\n", + "y = 2\n", + "\n", + "#Function definition\n", + "def add(a,b):\n", + " return a+b\n", + "\n", + "#Function call\n", + "z = add(x,y)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"z = %d\"%(z))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "z = 3" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.2, Page number: 321

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Call user-defined function at different places.\n", + "\n", + "import sys\n", + "\n", + "#Function definitions\n", + "def y():\n", + " sys.stdout.write(\" Y\")\n", + " return\n", + "\n", + "def a():\n", + " sys.stdout.write(\" A\")\n", + " y()\n", + " return\n", + "\n", + "def b():\n", + " sys.stdout.write(\" B\")\n", + " a()\n", + " return\n", + "\n", + "def c():\n", + " a()\n", + " b()\n", + " sys.stdout.write(\" C\")\n", + " return\n", + "\n", + "def d():\n", + " sys.stdout.write(\" D\")\n", + " c()\n", + " b()\n", + " a()\n", + " return\n", + "\n", + "#Function calls\n", + "y()\n", + "a()\n", + "b()\n", + "c()\n", + "d()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Y A Y B A Y A Y B A Y C D A Y B A Y C B A Y A Y" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.3, Page number: 323

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Using similar variable names in different functions.\n", + "\n", + "import sys\n", + "\n", + "#Function definition\n", + "def fun():\n", + " b = 20\n", + " c = 10\n", + " sys.stdout.write(\"\\nIn fun() B = %d C = %d\"%(b,c))\n", + " return\n", + "\n", + "#Variable Initialization\n", + "b = 10\n", + "c = 5\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nIn main() B = %d C = %d\"%(b,c))\n", + "fun()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "In main() B = 10 C = 5\n", + "In fun() B = 20 C = 10" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.4, Page number: 323

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Global variables on different functions.\n", + "\n", + "import sys\n", + "\n", + "#Global Variable Initialization\n", + "b = 10\n", + "c = 5\n", + "\n", + "def fun():\n", + " global b \n", + " b += 1\n", + " global c \n", + " c -= 1\n", + " sys.stdout.write(\"\\nIn fun() B = %d C = %d\"%(b,c))\n", + " return\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nIn main() B = %d C = %d\"%(b,c))\n", + "fun()\n", + "b += 1\n", + "c -= 1\n", + "sys.stdout.write(\"\\nAgain In main() B = %d C = %d\"%(b,c))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "In main() B = 10 C = 5\n", + "In fun() B = 11 C = 4\n", + "Again In main() B = 12 C = 3" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.5, Page number: 325

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Using return statement in different ways\n", + "\n", + "import sys\n", + "\n", + "#Function definition\n", + "def pass1(a):\n", + " if a == 0:\n", + " return;\n", + " else:\n", + " return a*a*a\n", + "\n", + "#Variable Initialization\n", + "x = int(raw_input(\"Enter value of x : \"))\n", + "\n", + "#Function call & Result\n", + "if x != 1 or x > 0:\n", + " y = pass1(x)\n", + "\n", + "#There is no switch statement in python, so if..else statement\n", + "if y == 1:\n", + " sys.stdout.write(\"The value returned is %d\"%(y))\n", + "else:\n", + " sys.stdout.write(\"The Cube of %d is : %d\"%(x,y))\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter value of x : 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Cube of 5 is : 125" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.6, Page number: 327

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display message using user defined function\n", + "\n", + "import sys\n", + "\n", + "#Function definition\n", + "def message():\n", + " sys.stdout.write(\"Have a nice day\")\n", + "\n", + "#function call\n", + "message()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Have a nice day" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.7, Page number: 328

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display Alphabets 'A','B' and 'C' using functions\n", + "\n", + "import sys\n", + "\n", + "#Functions definitions\n", + "def a():\n", + " sys.stdout.write(\"\\nA\")\n", + " \n", + "def b():\n", + " sys.stdout.write(\" B\")\n", + " \n", + "def c():\n", + " sys.stdout.write(\" C\")\n", + " \n", + "#Function call\n", + "a()\n", + "b()\n", + "c()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "A B C" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.8, Page number: 329

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Send value to user defined function and display results\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def dat(x,y,z):\n", + " sys.stdout.write(\"Date = %d/%d/%d\"%(x,y,z))\n", + " \n", + "#Variable Initialization\n", + "d = int(raw_input(\"Enter date dd/mm/yy\"))\n", + "m = int(raw_input(\"Enter date dd/mm/yy\"))\n", + "y = int(raw_input(\"Enter date dd/mm/yy\"))\n", + "\n", + "#function call & Result\n", + "dat(d,m,y)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter date dd/mm/yy12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter date dd/mm/yy12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter date dd/mm/yy2001\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Date = 12/12/2001" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.9, Page number: 330

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Square of number using user defined function\n", + "\n", + "import sys\n", + "\n", + "#function definition\n", + "def sqr(k):\n", + " sys.stdout.write(\"\\n%d\"%(k*k))\n", + " \n", + "#Variable Initialization\n", + "j = 0\n", + "\n", + "#Function call & Result\n", + "for j in range(1,5):\n", + " sqr(j)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "1\n", + "4\n", + "9\n", + "16" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.10, Page number: 330

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Pass the value to main() function\n", + "\n", + "import sys\n", + "\n", + "#There is no main function in python\n", + "sys.stdout.write(\"\\nNumber of command line arguments J = %d\"%(len(sys.argv)))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Number of command line arguments J = 6" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.11, Page number: 331

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Pass and return values to user defined function. \n", + "\n", + "import sys\n", + "\n", + "#Function Definitions\n", + "def dat(x,y,z):\n", + " sys.stdout.write(\"\\nToday = %d/%d/%d\"%(x,y,z))\n", + " x += 1\n", + " return x\n", + "\n", + "#Variable Initialization\n", + "d = int(raw_input(\"Enter Date dd/mm/yy : \"))\n", + "m = int(raw_input(\"Enter Date dd/mm/yy : \"))\n", + "y = int(raw_input(\"Enter Date dd/mm/yy : \"))\n", + "\n", + "#Function call\n", + "t = dat(d,m,y)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nTomorrow = %d/%d/%d\"%(t,m,y))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Date dd/mm/yy : 12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Date dd/mm/yy : 12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Date dd/mm/yy : 2001\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Today = 12/12/2001\n", + "Tomorrow = 13/12/2001" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.12, Page number: 332

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Send and recieve values to user defined function \n", + "\n", + "import sys\n", + "\n", + "#Function definition\n", + "def sum1(x,y,z):\n", + " return x+y+z\n", + "\n", + "#Variable Initialization\n", + "a = int(raw_input(\"Enter Three Numbers : \"))\n", + "b = int(raw_input(\"Enter Three Numbers : \"))\n", + "c = int(raw_input(\"Enter Three Numbers : \"))\n", + "\n", + "#Function call\n", + "s = sum1(a,b,c)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"Sum = %d\"%(s))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Numbers : 7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Numbers : 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Numbers : 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum = 16" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.13, Page number: 333

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Recieve values from user defined function without passing any \n", + "#value through main().\n", + "\n", + "import sys\n", + "\n", + "#Function definition\n", + "def sum1():\n", + " x = int(raw_input(\"Enter Three Numbers : \"))\n", + " y = int(raw_input(\"Enter Three Numbers : \"))\n", + " z = int(raw_input(\"Enter Three Numbers : \"))\n", + " return x+y+z\n", + "\n", + "#Function call\n", + "s = sum1()\n", + "\n", + "#Result\n", + "sys.stdout.write(\"Sum = %d\"%(s))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Numbers : 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Numbers : 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Numbers : 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum = 12" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.14, Page number: 333

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Return value in the form of address.\n", + "\n", + "import sys\n", + "\n", + "#Function definition\n", + "def sum1():\n", + " x = int(raw_input(\"Enter Three Values : \"))\n", + " y = int(raw_input(\"Enter Three Values : \"))\n", + " z = int(raw_input(\"Enter Three Values : \"))\n", + " k = x + y + z\n", + " return k\n", + "\n", + "#There is no pointer concept in python\n", + "\n", + "#Function call\n", + "s = sum1()\n", + "\n", + "#Result\n", + "sys.stdout.write(\"Sum = %d\"%(s))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Values : 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Values : 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Values : 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sum = 12" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.15, Page number: 334

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Call by value\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def change(a,b):\n", + " k = a\n", + " a = b\n", + " b = k\n", + " sys.stdout.write(\"\\nIn Change() X = %d Y = %d\"%(a,b))\n", + " \n", + "#Variable Initialization\n", + "x = int(raw_input(\"Enter Values of X & Y : \"))\n", + "y = int(raw_input(\"Enter Values of X & Y : \"))\n", + "\n", + "#Function call\n", + "change(x,y)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nIn main() X = %d Y = %d\"%(x,y))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Values of X & Y : 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Values of X & Y : 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "In Change() X = 4 Y = 5\n", + "In main() X = 5 Y = 4" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.16, Page number: 335

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Call by reference \n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def change(a,b):\n", + " k = a\n", + " a = b\n", + " b = k\n", + " sys.stdout.write(\"\\nIn Change() X = %d Y = %d\"%(a,b))\n", + " \n", + "#There is no pointer concept in python\n", + "\n", + "#Variable Initialization\n", + "x = int(raw_input(\"Enter Values of X & Y : \"))\n", + "y = int(raw_input(\"Enter Values of X & Y : \"))\n", + "\n", + "#Function call\n", + "change(x,y)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nIn main() X = %d Y = %d\"%(y,x))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Values of X & Y : 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Values of X & Y : 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "In Change() X = 4 Y = 5\n", + "In main() X = 4 Y = 5" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.17, Page number: 336

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Return by reference\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def change(a,b):\n", + " c = a + b\n", + " d = a - b\n", + " return c,d\n", + "\n", + "#Variable Initialization\n", + "x = int(raw_input(\"Enter Values of X & Y : \"))\n", + "y = int(raw_input(\"Enter Values of X & Y : \"))\n", + "\n", + "#Function call\n", + "add,sub = change(x,y)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nAddition : %d\"%(add))\n", + "sys.stdout.write(\"\\nSubtraction : %d\"%(sub))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Values of X & Y : 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Values of X & Y : 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Addition : 9\n", + "Subtraction : 1" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.18, Page number: 337

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Call by value and reference\n", + "\n", + "k = 0\n", + "m = 0\n", + "\n", + "#Function Definition\n", + "def other(k,m):\n", + " sys.stdout.write(\"\\nAddress of k & m in other() : %u %u\"%(id(k),id(m)))\n", + " \n", + "#Result\n", + "sys.stdout.write(\"\\nAddress of k & m in main() : %u %u\"%(id(k),id(m)))\n", + "\n", + "#Function call\n", + "other(k,m)\n", + "\n", + "#there is no pointer concept in python and it uses value tagged method in data storage\n", + "#instead of addressing the memory location, values of same variables are tagged together" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Address of k & m in main() : 30922996 30922996\n", + "Address of k & m in other() : 30922996 30922996" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.19, Page number: 338

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#User defined function as an argument to another function.\n", + "\n", + "#Variable Initialization\n", + "y = 2\n", + "\n", + "#Function Definitions\n", + "def double(m):\n", + " return m*2\n", + "\n", + "def square(k):\n", + " return k*k\n", + "\n", + "#Function call\n", + "x = double(square(y))\n", + "\n", + "#Result\n", + "sys.stdout.write(\"x = %d\"%(x))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x = 8" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.20, Page number: 338

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Two functions as arguments for another functions\n", + "\n", + "import sys\n", + "\n", + "#Function definitions\n", + "def x(a,b):\n", + " return abs(a-b)\n", + "\n", + "def y():\n", + " y = int(raw_input(\"Enter First Number : \"))\n", + " return y\n", + "\n", + "def z():\n", + " z = int(raw_input(\"Enter Second Number : \"))\n", + " return z\n", + "\n", + "#Function call\n", + "d = x(y(),z())\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nz() - y() = %d\"%(d))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter First Number : 25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Second Number : 50\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "z() - y() = 25" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.21, Page number: 339

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Return only absolute value like abs() function\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def uabs(y):\n", + " if y < 0:\n", + " return y * -1\n", + " else:\n", + " return y\n", + " \n", + "#Variable Initialization\n", + "x = int(raw_input(\"Enter a Negative Value : \"))\n", + "\n", + "#Function call\n", + "x = uabs(x)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nX = %d\"%(x))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Negative Value : -5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "X = 5" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.22, Page number: 340

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Square and cube of an entered number. \n", + "\n", + "import sys\n", + "\n", + "#Function Definitions\n", + "def input1(): #Since input() is a built in function in python, input1() is used\n", + " k = int(raw_input(\"Number : \"))\n", + " return k\n", + "\n", + "def sqr(m):\n", + " sys.stdout.write(\"\\nSquare : %d\"%(m*m))\n", + " return m\n", + "\n", + "def cube(m):\n", + " return m*m*m\n", + "\n", + "#Function call and Result\n", + "sys.stdout.write(\"\\nCube : %d\"%(cube(sqr(input1()))))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number : 2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Square : 4\n", + "Cube : 8" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.23, Page number: 341

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Assign return value of a function to variable.\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def input1():\n", + " k = int(raw_input(\"Enter Value of x = \"))\n", + " return k\n", + "\n", + "#Function call\n", + "x = input1()\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nx = %d\"%(x))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Value of x = 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "x = 5" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.24, Page number: 342

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Addition and subtraction of numbers with return value of function.\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def input1():\n", + " k = int(raw_input(\"Enter Value of x = \"))\n", + " return k\n", + "\n", + "def sqr(m):\n", + " return pow(m,2)\n", + "\n", + "#Function call\n", + "x = sqr(1 - input1() + 1)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nSquare = %d\"%(x))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Value of x = 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Square = 9" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.25, Page number: 343

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Multiplication and division of numbers with return value of function.\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def input1():\n", + " k = int(raw_input(\"Enter Value of x = \"))\n", + " return k\n", + "\n", + "def sqr(m):\n", + " return pow(m,2)\n", + "\n", + "#Function call\n", + "x = sqr(5 * input1()/2)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nSquare = %d\"%(x))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Value of x = 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Square = 144" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.26, Page number: 344

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# ++ operator with return value of function\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def input1():\n", + " k = int(raw_input(\"Enter Value of x = \"))\n", + " return k\n", + "\n", + "def sqr(m):\n", + " return pow(m,2)\n", + "\n", + "#Function call\n", + "#There is no ++ operator in python. so += operator is used\n", + "y = input1()\n", + "y += 1\n", + "x = sqr(y)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nSquare = %d\"%(x))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Value of x = 7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Square = 64" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.27, Page number: 345

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Use mod(%) with function\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def j():\n", + " x = int(raw_input(\"Enter a Number : \"))\n", + " return x\n", + " \n", + "#Function call & Result\n", + "if j() %2 == 0:\n", + " sys.stdout.write(\"\\nNumber is Even.\")\n", + "else:\n", + " sys.stdout.write(\"\\nNumber is Odd.\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Number : 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Number is Odd." + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.28, Page number: 346

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Conditional operator(?) with function.\n", + "\n", + "import sys\n", + "\n", + "#Function Definitions\n", + "def sqr(x):\n", + " sys.stdout.write(\"Square \")\n", + " return pow(x,2)\n", + "\n", + "def cube(x):\n", + " sys.stdout.write(\"Cube \")\n", + " return pow(x,3)\n", + "\n", + "def y():\n", + " return 10\n", + "\n", + "#Variable Initialization\n", + "x = int(raw_input(\"Enter a Number : \"))\n", + "\n", + "#Function call\n", + "z = sqr(x) if x > y() else cube(x)\n", + "\n", + "#Result\n", + "sys.stdout.write(\" = %d\"%(z))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Number : 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Cube = 125" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.29, Page number: 346

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#compare two return values of functions\n", + "\n", + "import sys\n", + "\n", + "#Function Definitions\n", + "def a():\n", + " x = int(raw_input(\"Enter a Number a() : \"))\n", + " return x\n", + "\n", + "def b():\n", + " x = int(raw_input(\"Enter a Number b() : \"))\n", + " return x\n", + "\n", + "#Function call and Result\n", + "if a() == b():\n", + " sys.stdout.write(\"\\nValue of a() & b() are equal\")\n", + "else:\n", + " sys.stdout.write(\"\\nValue of a() & b() are unique\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Number a() : 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Number b() : 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Value of a() & b() are equal" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.30, Page number: 347

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Evaluate the equation s = sqr(a() + b()) using function\n", + "\n", + "import sys\n", + "\n", + "#Function Definitions\n", + "def a():\n", + " a = int(raw_input(\"Enter value of a : \"))\n", + " return a\n", + "\n", + "def b():\n", + " b = int(raw_input(\"Enter value of b : \"))\n", + " return b\n", + "\n", + "def sqr(x):\n", + " return x*x\n", + "\n", + "#Function call\n", + "s = sqr(a() + b())\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nSquare of Sum = %d\"%(s))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter value of a : 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter value of b : 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Square of Sum = 64" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.31, Page number: 348

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Evaluate the equation y = x^1+x^2..x^n using function\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def b(m):\n", + " m += 1\n", + " #sys.stdout.write(\"%d\"%(m))\n", + " return m\n", + "\n", + "#Variable Initialization\n", + "x = int(raw_input(\"Values of 'x' and 'n' : \"))\n", + "n = int(raw_input(\"Values of 'x' and 'n' : \"))\n", + "y = 0\n", + "z = 1\n", + "m = 0\n", + "\n", + "while(z <= n):\n", + " m = b(m)\n", + " y = y + pow(x,m)\n", + " sys.stdout.write(\"%d + \"%(y))\n", + " z += 1\n", + " \n", + "if z >= n:\n", + " sys.stdout.write(\"\\nValue of y = %d\"%(y))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Values of 'x' and 'n' : 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Values of 'x' and 'n' : 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "3 + 12 + 39 + \n", + "Value of y = 39" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.32, Page number: 350

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Call user defined function through if statement\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def a():\n", + " a = int(raw_input(\"Enter value of a :\"))\n", + " return a\n", + "\n", + "#Function call and Result\n", + "if a()%2 == 0:\n", + " sys.stdout.write(\"\\nThe number is even.\")\n", + "else:\n", + " sys.stdout.write(\"\\nThe number is odd.\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter value of a :5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "The number is odd." + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.33, Page number: 351

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Call user defined function through switch() statement\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def a():\n", + " c = raw_input(\"Enter Your Choice Square(s), Cube(c), Double(d) : \")\n", + " c = c.lower()\n", + " return c\n", + "\n", + "#Variable Initialization\n", + "x = 5\n", + "\n", + "#There is no switch() statement in python.\n", + "c = a()\n", + "if c == 's':\n", + " sys.stdout.write(\"\\nSquare of %d is %d\"%(x,pow(x,2)))\n", + "else:\n", + " if c == 'c':\n", + " sys.stdout.write(\"\\nCube of %d is %d\"%(x,pow(x,3)))\n", + " else:\n", + " if c == 'd':\n", + " sys.stdout.write(\"\\nDouble of %d is %d\"%(x,x*2))\n", + " else:\n", + " sys.stdout.write(\"\\nUnexpected Choice printed as it is : %d\"%(x))\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Your Choice Square(s), Cube(c), Double(d) : D\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Double of 5 is 10" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.34, Page number: 353

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Call function through the for loop\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def plus(k):\n", + " if k == 10:\n", + " return 0\n", + " else:\n", + " return k\n", + " \n", + "#Variable Initialization\n", + "m = 1\n", + "\n", + "#Function call & Result\n", + "#in python, for loop iterates through a range of number. so while loop is used instead.\n", + "while plus(m) != 0:\n", + " sys.stdout.write(\"%3d\"%(m))\n", + " m += 1\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 1 2 3 4 5 6 7 8 9" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.35, Page number: 354

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Call user defined function through while() loop\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def y():\n", + " x = int(raw_input(\"Enter a Number : \"))\n", + " return x\n", + "\n", + "#Function call & Result\n", + "while y() != 0:\n", + " sys.stdout.write(\"Value enter is non-zero\\n\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Number : 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value enter is non-zero\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Number : 0\n" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.36, Page number: 355

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Call user defined function through do while() loop\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def y():\n", + " x = int(raw_input(\"Enter a Number : \"))\n", + " return x\n", + "\n", + "#Function call and Result\n", + "#There is no do-while loop in python\n", + "\n", + "while y() != 0:\n", + " sys.stdout.write(\"\\nValue entered is non-zero\\n\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Number : 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Value entered is non-zero\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Number : 0\n" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.37, Page number: 356

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Initialize an array using functions.\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def c(m):\n", + " n = int(raw_input(\"Enter Number d[%d]\"%(m+1)))\n", + " return n\n", + "\n", + "#Variable Initialization\n", + "d = [c(i) for i in range(0,5)]\n", + "\n", + "sys.stdout.write(\"\\nArray d[] elements are : \")\n", + "for k in range(0,5):\n", + " sys.stdout.write(\"%2d\"%d[k])" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Number d[1]4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Number d[2]5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Number d[3]6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Number d[4]7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Number d[5]8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Array d[] elements are : 4 5 6 7 8" + ] + } + ], + "prompt_number": 28 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.38, Page number: 357

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Pass array element to the function using call by value method.\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def show(m,u):\n", + " sys.stdout.write(\"\\nnum[%d] = %d\"%(m+1,u))\n", + " \n", + "#Variable initialization\n", + "num = [12,13,14,15,16,17,18]\n", + "\n", + "#Function call & Result\n", + "for k in range(0,7):\n", + " show(k,num[k])" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "num[1] = 12\n", + "num[2] = 13\n", + "num[3] = 14\n", + "num[4] = 15\n", + "num[5] = 16\n", + "num[6] = 17\n", + "num[7] = 18" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.39, Page number: 358

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Pass array element to the function using call by reference\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def show(u):\n", + " m = 0\n", + " sys.stdout.write(\"\\nnum[7] = {\")\n", + " while m != 7:\n", + " #There is no pointer concept in python\n", + " sys.stdout.write(\"%2d,\"%(u[m]))\n", + " m += 1\n", + " sys.stdout.write(\"\\b}\")\n", + " \n", + "#Variable Initialization\n", + "num = [12,13,14,15,16,17,18]\n", + "\n", + "#Function call\n", + "show(num)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "num[7] = {12,13,14,15,16,17,18,\b}" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.40, Page number: 359

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Array elements in reverse order.\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def show(u):\n", + " m = 6\n", + " while m != -1:\n", + " sys.stdout.write(\"\\nnum[%d] = %d\"%(m,u[m]))\n", + " m -= 1\n", + " \n", + "#Variable Initialization\n", + "num = [12,13,14,15,16,17,18]\n", + "\n", + "#Function call\n", + "#There is no pointer concept in python\n", + "show(num)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "num[6] = 18\n", + "num[5] = 17\n", + "num[4] = 16\n", + "num[3] = 15\n", + "num[2] = 14\n", + "num[1] = 13\n", + "num[0] = 12" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.41, Page number: 360

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Copy array elements using user defined function.\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def cpy(p,m):\n", + " j = 0\n", + " while j != 5:\n", + " m[j] = p[j]\n", + " j += 1\n", + " \n", + "#Variable Initialization\n", + "a1 = [1,2,3,4,5]\n", + "a2 = [0 for i in range(0,5)]\n", + "\n", + "#Function call\n", + "cpy(a1,a2)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"Source Target\")\n", + "for h in range(0,5):\n", + " sys.stdout.write(\"\\n%5d\\t%d\"%(a1[h],a2[h]))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Source Target\n", + " 1\t1\n", + " 2\t2\n", + " 3\t3\n", + " 4\t4\n", + " 5\t5" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.42, Page number: 361

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read array of other function in main()\n", + "\n", + "import sys\n", + "\n", + "#Function definition\n", + "def arry(k):\n", + " b = [1,2,3,4,5]\n", + " return b[k]\n", + "\n", + "#main() function\n", + "for k in range(0,5):\n", + " sys.stdout.write(\"\\t%d\"%(arry(k)))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\t1\t2\t3\t4\t5" + ] + } + ], + "prompt_number": 29 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.43, Page number: 361

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Interchange array elements of two arrays using function.\n", + "\n", + "import sys\n", + "global a\n", + "global b\n", + "\n", + "#Function Definitions\n", + "def read():\n", + " x = int(raw_input(\"\"))\n", + " return x\n", + "\n", + "def change(a,b):\n", + "#Since there is no pointer concept in python, exchange is done in the function using global variables.\n", + " for x in range(0,5):\n", + " a[x] = a[x] + b[x]\n", + " b[x] = a[x] - b[x]\n", + " a[x] = a[x] - b[x]\n", + " \n", + "#Variable Initialization\n", + "a = [0 for i in range(0,5)]\n", + "b = [0 for i in range(0,5)]\n", + "\n", + "for x in range(0,10):\n", + " if x < 5:\n", + " a[x] = read()\n", + " else:\n", + " b[x-5] = read()\n", + "\n", + "#Swapping and Result\n", + "sys.stdout.write(\"\\nArray A & B \")\n", + "\n", + "for x in range(0,5):\n", + " sys.stdout.write(\"\\n%7d%8d\"%(a[x],b[x]))\n", + " \n", + "#There is no pointer concept in python.\n", + "change(a,b)\n", + " \n", + "sys.stdout.write(\"\\nNow A & B\")\n", + "for x in range(0,5):\n", + " sys.stdout.write(\"\\n%7d%8d\"%(a[x],b[x]))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "9\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "0\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Array A & B \n", + " 1 6\n", + " 2 7\n", + " 3 8\n", + " 4 9\n", + " 5 0\n", + "Now A & B\n", + " 6 1\n", + " 7 2\n", + " 8 3\n", + " 9 4\n", + " 0 5" + ] + } + ], + "prompt_number": 30 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.44, Page number: 363

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read array elements declared in different functions using global\n", + "#pointer declaration\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def call(j):\n", + " m = 0\n", + " u = [5,1,6,0,6]\n", + " q = u\n", + " while m != j:\n", + " sys.stdout.write(\"%3d\"%(u[m]))\n", + " m += 1\n", + " sys.stdout.write(\"\\n\")\n", + " \n", + "#Variable Initialization\n", + "m = 0\n", + "k = [3,8,5,2,5]\n", + "q = k\n", + "\n", + "\n", + "\n", + "#Result\n", + "while m != 5:\n", + " sys.stdout.write(\"%3d\"%(q[m]))\n", + " m += 1\n", + "\n", + "sys.stdout.write(\"\\n\")\n", + "call(5)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 3 8 5 2 5\n", + " 5 1 6 0 6\n" + ] + } + ], + "prompt_number": 30 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.45, Page number: 364

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Sum of 1 to 5 numbers using recursion\n", + "\n", + "import sys\n", + "global s\n", + "\n", + "s = 0\n", + "#Function definition\n", + "def main(x,s):\n", + " s = s + x\n", + " sys.stdout.write(\"\\nx = %d s = %d\"%(x,s))\n", + " if x == 5:\n", + " return\n", + " x += 1\n", + " main(x,s)\n", + " \n", + "main(1,s)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "x = 1 s = 1\n", + "x = 2 s = 3\n", + "x = 3 s = 6\n", + "x = 4 s = 10\n", + "x = 5 s = 15" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.46, Page number: 365

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Calculate triangular number of a given number with recursion function method\n", + "\n", + "import sys\n", + "\n", + "#Function definition\n", + "def tri_num(m):\n", + " f = 0\n", + " if m == 0:\n", + " return f\n", + " else:\n", + " f = f + m + tri_num(m-1)\n", + " return f\n", + "\n", + "#Variable Initialization\n", + "n = int(raw_input(\"Enter a Number : \"))\n", + "\n", + "#Function call\n", + "t = tri_num(n)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nTriangular number of %d is %d\"%(n,t))\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Number : 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Triangular number of 5 is 15" + ] + } + ], + "prompt_number": 31 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.47, Page number: 366

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display the given string using recursion\n", + "\n", + "import sys\n", + "import os\n", + "global x\n", + "\n", + "#Variable Initialization\n", + "x = 0\n", + "str1 = \"Have a Good Day\"\n", + "\n", + "#Function Definition\n", + "def main(x):\n", + " if x == len(str1): #There is no null terminating character in python string\n", + " return\n", + " else:\n", + " if str1[x] == 'H':\n", + " os.system('cls')\n", + " sys.stdout.write(\"%c\"%(str1[x]))\n", + " else:\n", + " sys.stdout.write(\"%c\"%(str1[x]))\n", + " x += 1\n", + " main(x)\n", + " \n", + "#Function call\n", + "main(x)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Have a Good Day" + ] + } + ], + "prompt_number": 47 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.48, Page number: 367

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display the given string 10 times using recursion\n", + "\n", + "import sys\n", + "import os\n", + "\n", + "#Function definition\n", + "def main(x):\n", + " sys.stdout.write(\"\\n%.2d] %s\"%(x,str1))\n", + " x += 1\n", + " if x == 11:\n", + " return\n", + " else:\n", + " if x == 1:\n", + " os.system('cls')\n", + " main(x)\n", + " else:\n", + " main(x)\n", + " \n", + " \n", + "#Variable Initialization\n", + "x = 0\n", + "str1 = \"Have a Good Day\"\n", + "\n", + "#Function call\n", + "main(x)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "00] Have a Good Day\n", + "01] Have a Good Day" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "02] Have a Good Day\n", + "03] Have a Good Day\n", + "04] Have a Good Day\n", + "05] Have a Good Day\n", + "06] Have a Good Day\n", + "07] Have a Good Day\n", + "08] Have a Good Day\n", + "09] Have a Good Day\n", + "10] Have a Good Day" + ] + } + ], + "prompt_number": 51 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.49, Page number: 368

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Factorial using recursive function.\n", + "\n", + "import sys\n", + "\n", + "#Function Definition\n", + "def fact(m):\n", + " f = 1\n", + " if m == 1:\n", + " return 1\n", + " else:\n", + " f = m * fact(m-1)\n", + " return f\n", + " \n", + "#Variable Initialization\n", + "x = int(raw_input(\"Enter a Number : \"))\n", + "\n", + "#Function call\n", + "f = fact (x)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nFactorial of %d is %d\"%(x,f))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Number : 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Factorial of 5 is 120" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.50, Page number: 369

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display address of user defined function\n", + "\n", + "import sys\n", + "\n", + "#Function definition\n", + "def show():\n", + " sys.stdout.write(\"\\nAddress of function show() is : \")\n", + " \n", + "#Function call\n", + "show()\n", + "\n", + "#Result\n", + "sys.stdout.write(\"%u\"%(id(show)))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Address of function show() is : 95041520" + ] + } + ], + "prompt_number": 54 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.51, Page number: 369

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Call function using pointer\n", + "\n", + "import sys\n", + "\n", + "#Function definition\n", + "def show():\n", + " sys.stdout.write(\"\\nAddress of function show() is : \")\n", + " \n", + "#There is no pointer concept in python\n", + "p = id(show)\n", + "show()\n", + "sys.stdout.write(\"%u\"%(id(show)))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Address of function show() is : 95041200" + ] + } + ], + "prompt_number": 55 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.52, Page number: 370

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display the address of library function.\n", + "\n", + "import sys\n", + "import os\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nAddress of printf() is %u\"%(id(sys.stdout.write)))\n", + "sys.stdout.write(\"\\nAddress of scanf() is %u\"%(id(sys.stdout.read)))\n", + "sys.stdout.write(\"\\nAddress of clrscr() is %u\"%(id(os.system('cls'))))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Address of printf() is 60743848\n", + "Address of scanf() is 60743848\n", + "Address of clrscr() is 4774132" + ] + } + ], + "prompt_number": 57 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 10.53, Page number: 371

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Call main() using pointer to main() function\n", + "\n", + "import sys\n", + "\n", + "#Variable Initilization\n", + "x = 0\n", + "\n", + "#Function definition\n", + "def main(x):\n", + " p = id(main)\n", + " x += 1\n", + " sys.stdout.write(\"\\nCall %d Address of main() %u\"%(x,id(main)))\n", + " if x == 3:\n", + " return\n", + " main(x)\n", + " \n", + "#function call\n", + "main(x)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Call 1 Address of main() 95040880\n", + "Call 2 Address of main() 95040880\n", + "Call 3 Address of main() 95040880" + ] + } + ], + "prompt_number": 59 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Programming_in_C_using_ANSI_C/KamthaneChapter11.ipynb b/Programming_in_C_using_ANSI_C/KamthaneChapter11.ipynb new file mode 100755 index 00000000..c8fac375 --- /dev/null +++ b/Programming_in_C_using_ANSI_C/KamthaneChapter11.ipynb @@ -0,0 +1,446 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Chapter 11: Storage Class

" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 11.1, Page number: 376

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Working of auto variable\n", + "\n", + "import sys\n", + "\n", + "#Functio definitions\n", + "def call1():\n", + " v = 20\n", + " sys.stdout.write(\"\\nV = %d\"%(v))\n", + " \n", + "def call2():\n", + " v = 30\n", + " call1()\n", + " sys.stdout.write(\"\\nV = %d\"%(v))\n", + " \n", + "#Variable Initialization\n", + "v = 10\n", + "\n", + "#Function call\n", + "call2()\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nV = %d\"%(v))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "V = 20\n", + "V = 30\n", + "V = 10" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 11.2, Page number: 376

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Working of auto variables in different blocks\n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "x = 10\n", + "\n", + "sys.stdout.write(\"\\nX = %d\"%(x))\n", + "\n", + "x = 20\n", + "sys.stdout.write(\"\\nX = %d\"%(x))\n", + "\n", + "x = 10\n", + "sys.stdout.write(\"\\nX = %d\"%(x))\n", + "\n", + "#In python, block of statements are indicated using intendation.\n", + "#block of statements can be written for conditional,loop or function statements" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "X = 10\n", + "X = 20\n", + "X = 10" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 11.3, Page number: 377

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Use same variable in different blocks with different data types\n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization & Result\n", + "x = 10\n", + "sys.stdout.write(\"\\nX = %d\"%(x))\n", + "\n", + "x = 2.22\n", + "sys.stdout.write(\"\\nX = %g\"%(x))\n", + "\n", + "x = \"Auto Storage Class\"\n", + "sys.stdout.write(\"\\nX = %s\"%(x))\n", + "\n", + "x = 10\n", + "sys.stdout.write(\"\\nX = %d\"%(x))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "X = 10\n", + "X = 2.22\n", + "X = Auto Storage Class\n", + "X = 10" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 11.4, Page number: 378

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Working of external variables\n", + "\n", + "import sys\n", + "\n", + "#Function definitions\n", + "def call1():\n", + " sys.stdout.write(\"\\nIn Call1() V = %d\"%(v))\n", + " \n", + "def call2():\n", + " sys.stdout.write(\"\\nIn call2() V = %d\"%(v))\n", + " \n", + "#Variable Initialization\n", + "global v\n", + "v = 10\n", + "\n", + "call1()\n", + "call2()\n", + "sys.stdout.write(\"\\nIn main() V = %d\"%(v))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "In Call1() V = 10\n", + "In call2() V = 10\n", + "In main() V = 10" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 11.5, Page number: 379

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Working of auto and global variables with same name\n", + "\n", + "import sys\n", + "\n", + "#Function definitions\n", + "def call1():\n", + " v = 20\n", + " sys.stdout.write(\"\\nIn Call1() V = %d\"%(v))\n", + " \n", + "def call2():\n", + " sys.stdout.write(\"\\nIn call2() V = %d\"%(v))\n", + " \n", + "#Variable Initialization\n", + "global v\n", + "v = 10\n", + "\n", + "#Function call\n", + "call1()\n", + "call2()\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nIn main() V = %d\"%(v))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "In Call1() V = 20\n", + "In call2() V = 10\n", + "In main() V = 10" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 11.6, Page number: 380

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Declare external variables using extern keyword\n", + "\n", + "#Variable Initialization\n", + "global m\n", + "m = 10\n", + "\n", + "#There is no extern keyword in python, global is used instead\n", + "sys.stdout.write(\"\\nM = %d\"%(m))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "M = 10" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 11.7, Page number: 380

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Use of static variable\n", + "\n", + "import sys\n", + "\n", + "#Function definition\n", + "def print1(m):\n", + " sys.stdout.write(\"\\nm = %d\"%(m))\n", + " if m == 3:\n", + " return\n", + " \n", + "m = 0\n", + "\n", + "for i in range(0,3):\n", + " m += 1\n", + " print1(m)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "m = 1\n", + "m = 2\n", + "m = 3" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 11.8, Page number: 381

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Difference between variables of auto and static class\n", + "\n", + "import sys\n", + "\n", + "#Result\n", + "y = 0\n", + "sys.stdout.write(\"\\nx = %d & y = %d\"%(x,y))\n", + "\n", + "#Since x display the junk value which stored already, it differs in different systems" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "x = 10 & y = 0" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 11.9, Page number: 382

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Register class variable\n", + "\n", + "import sys\n", + "\n", + "#There is no register keyword in python\n", + "m = 1\n", + "\n", + "#Result\n", + "for m in range(1,5+1):\n", + " sys.stdout.write(\"\\t%d\"%(m))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\t1\t2\t3\t4\t5" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 11.10, Page number: 382

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Register class variable\n", + "\n", + "import sys\n", + "\n", + "#There is no register class variable in python\n", + "m = 1\n", + "\n", + "for m in range(1,6):\n", + " sys.stdout.write(\"\\t%d\"%(m))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\t1\t2\t3\t4\t5" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Programming_in_C_using_ANSI_C/KamthaneChapter12.ipynb b/Programming_in_C_using_ANSI_C/KamthaneChapter12.ipynb new file mode 100755 index 00000000..e1acaa2c --- /dev/null +++ b/Programming_in_C_using_ANSI_C/KamthaneChapter12.ipynb @@ -0,0 +1,849 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Chapter 12: Preprocessor Directives

" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.1, Page number: 386

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Area of circle\n", + "\n", + "import sys\n", + "\n", + "#Defining the macro\n", + "#There is no macro definitions/preprocessors in python\n", + "PI = 3.14\n", + "\n", + "#Variable Initialization\n", + "r = float(raw_input(\"Enter radius of circle in cms.\"))\n", + "\n", + "#Calculation\n", + "area = PI * r * r\n", + "\n", + "#Result\n", + "sys.stdout.write(\"Area of a Circle = %.2f cm2\"%(area))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter radius of circle in cms.7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Area of a Circle = 153.86 cm2" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.2, Page number: 387

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Identifers for 'c' statements and variables\n", + "\n", + "import sys\n", + "import os\n", + "\n", + "#Macro definitions\n", + "#in python, function definitions are used instead of macros\n", + "def N():\n", + " return 10\n", + "\n", + "def cls():\n", + " os.system('cls')\n", + " \n", + "def wait():\n", + " t = raw_input(\"\")\n", + " \n", + "def display(s):\n", + " sys.stdout.write(s)\n", + "\n", + "for k in range(1,N()+1):\n", + " display(\"%d\\t\"%(k))\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.3, Page number: 387

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Macros for logical operators\n", + "\n", + "import sys\n", + "\n", + "#Macro definitions\n", + "#in python, function definitions are used as macros\n", + "\n", + "#There is no preprocessors in python\n", + "\n", + "#Variable Initialization\n", + "a = int(raw_input(\"Enter Three Numbers : \"))\n", + "b = int(raw_input(\"Enter Three Numbers : \"))\n", + "c = int(raw_input(\"Enter Three Numbers : \"))\n", + "\n", + "if a > b and a > c:\n", + " sys.stdout.write(\"%d is the larger number\"%(a))\n", + "else:\n", + " if b > a and b > c:\n", + " sys.stdout.write(\"%d is the larger number\"%(b))\n", + " else:\n", + " if c > a and c > b:\n", + " sys.stdout.write(\"%d is the larger number\"%(c))\n", + " else:\n", + " if a == b and b == c:\n", + " sys.stdout.write(\"\\nNumbers are same.\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Numbers : 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Numbers : 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Three Numbers : 7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "7 is the larger number" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.4, Page number: 388

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Identifier for displaying double and triple of a number.\n", + "\n", + "#Macro definitions\n", + "#Function definitions are used as macros in python\n", + "\n", + "def DOUBLE(a):\n", + " return a*2\n", + "\n", + "def TRIPLE(a):\n", + " return a*3\n", + "\n", + "#Variable initialization\n", + "a = 1\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nSINGLE\\tDOUBLE\\tTRIPLE\")\n", + "\n", + "for a in range(1,5+1):\n", + " sys.stdout.write(\"\\n%d\\t%d\\t%d\"%(a,DOUBLE(a),TRIPLE(a)))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "SINGLE\tDOUBLE\tTRIPLE\n", + "1\t2\t3\n", + "2\t4\t6\n", + "3\t6\t9\n", + "4\t8\t12\n", + "5\t10\t15" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.5, Page number: 389

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Undefine a macro\n", + "\n", + "#There is no preprocessor directives in python\n", + "\n", + "def wait():\n", + " return (raw_input(\"\"))\n", + "\n", + "#Result\n", + "for k in range(1,5+1):\n", + " sys.stdout.write(\"%d\\t\"%(k))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\t2\t3\t4\t5\t" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.6, Page number: 389

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Stringizing operation\n", + "\n", + "#Macro definition\n", + "#in python, function definition can be used as macro\n", + "\n", + "def say(m):\n", + " sys.stdout.write(m)\n", + " \n", + "#Function call\n", + "say(\"Hello\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Hello" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.7, Page number: 390

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Stringizing operation and macro arguments\n", + "\n", + "#There is no macro in python, function definitions can be used as macros\n", + "\n", + "def DOUBLE(x):\n", + " sys.stdout.write(\"Double of m = %d\\n\"%(x*2))\n", + " \n", + "def TRIPLE(x):\n", + " sys.stdout.write(\"Triple of m = %d\\n\"%(x*3))\n", + " \n", + "#Variable Initialization\n", + "m = int(raw_input(\"Enter a number : \"))\n", + "\n", + "#Function call & Result\n", + "DOUBLE(m)\n", + "TRIPLE(m)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a number : 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Double of m = 10\n", + "Triple of m = 15\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.8, Page number: 390

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Larger of two numbers using macro with arguments.\n", + "\n", + "import sys\n", + "\n", + "#Macro definition //function definition itself is used as macro\n", + "def MAX(x,y):\n", + " if x > y:\n", + " c = x\n", + " else:\n", + " c = y\n", + " return c\n", + "\n", + "#Variable Initialization\n", + "x = 5\n", + "y = 8\n", + "\n", + "#Function call\n", + "c = MAX(x,y)\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nLarger of two numbers = %d\"%(c))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Larger of two numbers = 8" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.9, Page number: 391

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Function defined in \"udf.c\" file.\n", + "\n", + "import sys\n", + "#since ipython notebook does not support this function, function is used\n", + "#in python, the udf.c file can be written and saved in udf.py and import command\n", + "#can be used to include that file in this program\n", + "\n", + "def display():\n", + " sys.stdout.write(\"\\nFunction Called\")\n", + " \n", + "#Function call\n", + "display()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Function Called" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.10, Page number: 392

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Conditional compilation \n", + "\n", + "import sys\n", + "\n", + "#There is no preprocessor directives in python\n", + "\n", + "LINE = 1\n", + "\n", + "if LINE:\n", + " sys.stdout.write(\"This is line number one\")\n", + "else:\n", + " sys.stdout.write(\"This is line number two\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is line number one" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.11, Page number: 393

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Conditional compilation \n", + "import sys\n", + "\n", + "#There is no preprocessor directives in python\n", + "def E():\n", + " return 1\n", + "\n", + "#Function call\n", + "if E():\n", + " a = 2\n", + " b = 3\n", + " sys.stdout.write(\"A = %d & B = %d\"%(a,b))\n", + "else:\n", + " c = 2\n", + " d = 3\n", + " sys.stdout.write(\"C = %d & D = %d\"%(c,d))\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "A = 2 & B = 3" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.12, Page number: 394

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Conditional compilation directives \n", + "\n", + "import sys\n", + "\n", + "#There is no preprocessor directives in python\n", + "T = 8\n", + "\n", + "#Result\n", + "if T == 0:\n", + " sys.stdout.write(\"\\nMacro is not defined.\")\n", + "else:\n", + " sys.stdout.write(\"\\nMacro is defined\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Macro is defined" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.13, Page number: 394

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#User defined error message \n", + "\n", + "import sys\n", + "\n", + "#There is no preprocessor directives in python\n", + "B = 1\n", + "A = 0\n", + "\n", + "#Result\n", + "if A == 0:\n", + " sys.stdout.write(\"MACRO A IS NOT DEFINED.\")\n", + "else:\n", + " sys.stdout.write(\"Macro found.\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "MACRO A IS NOT DEFINED." + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.14, Page number: 397

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Set off certain errors \n", + "\n", + "import sys\n", + "\n", + "#There is no preprocessor directives in python\n", + "x = 2\n", + "y = 1\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\ny = %d\"%(y))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "y = 1" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.15, Page number: 398

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Predefined macros \n", + "\n", + "import sys\n", + "import datetime\n", + "\n", + "#Variable Initialization\n", + "FILE = 'PRE_MA~1.C'\n", + "LINE = 10\n", + "STDC = 1\n", + "\n", + "#Date/time can be set using datetime.date(2001,5,12)\n", + "#Result\n", + "sys.stdout.write(\"\\nDATE : %s\"%('Dec 05 2001')) \n", + "sys.stdout.write(\"\\nTIME : %s\"%(datetime.time(21,7,39)))\n", + "sys.stdout.write(\"\\nFILE NAME : %s\"%(FILE))\n", + "sys.stdout.write(\"\\nLINE NO : %d\"%(LINE))\n", + "sys.stdout.write(\"\\n_STDC_ : %x\"%(STDC))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "DATE : Dec 05 2001\n", + "TIME : 21:07:39\n", + "FILE NAME : PRE_MA~1.C\n", + "LINE NO : 10\n", + "_STDC_ : 1" + ] + } + ], + "prompt_number": 31 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.16, Page number: 399

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display the name of memory model that is currently in use.\n", + "\n", + "import sys\n", + "\n", + "#There is no formal memory model and preprocessor directives in python\n", + "\n", + "TINY = 0\n", + "SMALL = 0\n", + "MEDIUM = 0\n", + "COMPACT = 0\n", + "LARGE = 1\n", + "HUGE = 0\n", + "\n", + "#Result\n", + "if TINY:\n", + " sys.stdout.write(\"\\nTINY %d\"%(TINY))\n", + "else:\n", + " if SMALL:\n", + " sys.stdout.write(\"\\nSMALL %d\"%(SMALL))\n", + " else:\n", + " if MEDIUM:\n", + " sys.stdout.write(\"\\nMEDIUM %d\"%(MEDIUM))\n", + " else:\n", + " if COMPACT:\n", + " sys.stdout.write(\"\\nCOMPACT %d\"%(COMPACT))\n", + " else:\n", + " if LARGE:\n", + " sys.stdout.write(\"\\nLARGE %d\"%(LARGE))\n", + " else:\n", + " sys.stdout.write(\"\\nHUGE %d\"%(HUGE))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "LARGE 1" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.17, Page number: 400

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Macro expansions\n", + "\n", + "import sys\n", + "\n", + "#There is no preprocessor directives in python\n", + "ch = raw_input(\"Input a Text : \")\n", + "\n", + "#Result\n", + "sys.stdout.write(\"Text Input : %s\"%(ch))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Input a Text : Programming\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Text Input : Programming" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 12.18, Page number: 401

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Predefined macros.\n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "d = raw_input(\"Enter any character : \")\n", + "\n", + "#Result\n", + "f = d.isalpha()\n", + "\n", + "if f != 0:\n", + " sys.stdout.write(\"\\n%c is a letter in\"%(d))\n", + " f = d.isupper()\n", + " if f != 0:\n", + " sys.stdout.write(\" Capital case\")\n", + " else:\n", + " sys.stdout.write(\" Small case\")\n", + "else:\n", + " f = d.isdigit()\n", + " if f != 0:\n", + " sys.stdout.write(\"\\n%c is a digit\"%(d))\n", + " else:\n", + " f = d.ispunct()\n", + " if f != 0:\n", + " sys.stdout.write(\"\\n%c is a punctuation symbol\"%(d))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter any character : C\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "C is a letter in Capital case" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Programming_in_C_using_ANSI_C/KamthaneChapter13.ipynb b/Programming_in_C_using_ANSI_C/KamthaneChapter13.ipynb new file mode 100755 index 00000000..f9222003 --- /dev/null +++ b/Programming_in_C_using_ANSI_C/KamthaneChapter13.ipynb @@ -0,0 +1,2367 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Chapter 13: Structure and Union

" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.1, Page number: 409

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display size of structure elements\n", + "\n", + "import sys\n", + "\n", + "#Class is used instead of structure in python\n", + "class book1:\n", + " book = ''\n", + " pages = 0\n", + " price = 0.00\n", + "\n", + "#Python variables uses value tagged methods for storing the values\n", + "\n", + "#Class variable declaration\n", + "bk1 = book1()\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nSize of Structure Elements\")\n", + "sys.stdout.write(\"\\nBook : %d\"%(sys.getsizeof(bk1.book)))\n", + "sys.stdout.write(\"\\nPages : %d\"%(sys.getsizeof(bk1.pages)))\n", + "sys.stdout.write(\"\\nPrice : %d\"%(sys.getsizeof(bk1.price)))\n", + "sys.stdout.write(\"\\nTotal Bytes : %d\"%(sys.getsizeof(bk1)))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Size of Structure Elements\n", + "Book : 21\n", + "Pages : 12\n", + "Price : 16\n", + "Total Bytes : 36" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.2, Page number: 410

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Define a structure and initialize its member variables\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class book1:\n", + " book = ''\n", + " pages = 0\n", + " price = 0.0\n", + " \n", + "#Class variable declaration and Initialization\n", + "bk1 = book1()\n", + "bk1.book = \"C++\"\n", + "bk1.pages = 300\n", + "bk1.price = 285\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nBook Name : %s\"%(bk1.book))\n", + "sys.stdout.write(\"\\nNo. of Pages : %d\"%(bk1.pages))\n", + "sys.stdout.write(\"\\nBook Price : %d\"%(bk1.price))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Book Name : C++\n", + "No. of Pages : 300\n", + "Book Price : 285" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.3, Page number: 411

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Copy structure elements from one object to another object\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class disk:\n", + " co = ''\n", + " type1 = 0.0\n", + " price = 0\n", + " \n", + "#Class variable declaration\n", + "d1 = disk()\n", + "d2 = disk()\n", + "d3 = disk()\n", + "\n", + "#Class variable initialization\n", + "d1.co = \"SONY\"\n", + "d1.type1 = 1.44\n", + "d1.price = 20\n", + "\n", + "#Copying\n", + "d2.co = d1.co\n", + "d2.type1 = d1.type1\n", + "d2.price = d1.price\n", + "\n", + "d3 = d2\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\n%s %g %d\"%(d1.co,d1.type1,d1.price))\n", + "sys.stdout.write(\"\\n%s %g %d\"%(d2.co,d2.type1,d2.price))\n", + "sys.stdout.write(\"\\n%s %g %d\"%(d3.co,d3.type1,d3.price))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "SONY 1.44 20\n", + "SONY 1.44 20\n", + "SONY 1.44 20" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.4, Page number: 412

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read values and assign them to structure variables\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class book1:\n", + " book = ''\n", + " pages = 0\n", + " price = 0.0\n", + " \n", + "#Class variable declaration\n", + "bk1 = book1()\n", + "\n", + "#Variable initialization\n", + "bk1.book = raw_input(\"Enter Book name,pages,price : \")\n", + "bk1.pages = int(raw_input(\"Enter Book name,pages,price : \"))\n", + "bk1.price = float(raw_input(\"Enter Book name, pages,price : \"))\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nBook Name : %s\"%(bk1.book))\n", + "sys.stdout.write(\"\\nNo. of Pages : %d\"%(bk1.pages))\n", + "sys.stdout.write(\"\\nBook Price : %d\"%(bk1.price))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Book name,pages,price : C\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Book name,pages,price : 500\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Book name, pages,price : 450\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Book Name : C\n", + "No. of Pages : 500\n", + "Book Price : 450" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.5, Page number: 414

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read and display car details\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class time:\n", + " second = 0\n", + " minute = 0\n", + " hour = 0\n", + " \n", + "class t:\n", + " carno = 0\n", + " st = time()\n", + " rt = time()\n", + " \n", + "#Class variable declaration\n", + "r1 = t()\n", + "\n", + "#Variable Initialization\n", + "r1.carno = int(raw_input(\"Car No., Starting Time, Reaching Time :\"))\n", + "r1.st.hour = int(raw_input(\"Car No., Starting Time, Reaching Time :\"))\n", + "r1.st.minute = int(raw_input(\"Car No., Starting Time, Reaching Time :\"))\n", + "r1.st.second = int(raw_input(\"Car No., Starting Time, Reaching Time :\"))\n", + "r1.rt.hour = int(raw_input(\"Car No., Starting Time, Reaching Time :\"))\n", + "r1.rt.minute = int(raw_input(\"Car No., Starting Time, Reaching Time :\"))\n", + "r1.rt.second = int(raw_input(\"Car No., Starting Time, Reaching Time :\"))\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nCar No. \\tStarting Time \\tReaching Time\\n\")\n", + "sys.stdout.write(\"%d\\t\"%(r1.carno))\n", + "sys.stdout.write(\"\\t%d:%d:%d\\t\\t\"%(r1.st.hour,r1.st.minute,r1.st.second))\n", + "sys.stdout.write(\"%d:%d:%d\"%(r1.rt.hour,r1.rt.minute,r1.rt.second))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No., Starting Time, Reaching Time :125\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No., Starting Time, Reaching Time :2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No., Starting Time, Reaching Time :50\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No., Starting Time, Reaching Time :30\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No., Starting Time, Reaching Time :3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No., Starting Time, Reaching Time :50\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No., Starting Time, Reaching Time :25\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Car No. \tStarting Time \tReaching Time\n", + "125\t\t2:50:30\t\t3:50:25" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.6, Page number: 415

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read and display the details of a person\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class name:\n", + " first = ''\n", + " second = ''\n", + " last = ''\n", + " \n", + "class b_date:\n", + " day = 0\n", + " month = 0\n", + " year = 0\n", + " \n", + "class data:\n", + " nm = name()\n", + " bt = b_date()\n", + " \n", + "#Class variable declaration\n", + "r1 = data()\n", + "\n", + "#Variable Initialization\n", + "r1.nm.first = raw_input(\"Enter Name (First/Second/Last)\")\n", + "r1.nm.second = raw_input(\"Enter Name (First/Second/Last)\")\n", + "r1.nm.last = raw_input(\"Enter Name (First/Second/Last)\")\n", + "r1.bt.day = int(raw_input(\"Enter Birth Date Day/Month/Year\"))\n", + "r1.bt.month = int(raw_input(\"Enter Birth Date Day/Month/Year\"))\n", + "r1.bt.year = int(raw_input(\"Enter Birth Date Day/Month/Year\"))\n", + "\n", + "#Result\n", + "sys.stdout.write(\"Name : %s %s %s\\n\"%(r1.nm.first,r1.nm.second,r1.nm.last))\n", + "sys.stdout.write(\"Birth Date : %d.%d.%d\"%(r1.bt.day,r1.bt.month,r1.bt.year))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Name (First/Second/Last)Ram\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Name (First/Second/Last)Sham\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Name (First/Second/Last)Pande\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Birth Date Day/Month/Year12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Birth Date Day/Month/Year12\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Birth Date Day/Month/Year1980\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name : Ram Sham Pande\n", + "Birth Date : 12.12.1980" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.7, Page number: 416

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Create array of structure objects\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class time:\n", + " second = 0\n", + " minute = 0\n", + " hour = 0\n", + " \n", + "class t:\n", + " carno = 0\n", + " st = time()\n", + " rt = time()\n", + " \n", + "#Class variable declaration\n", + "r1 = [t() for i in range(0,3)]\n", + "\n", + "#Variable Initialization\n", + "for k in range(0,3):\n", + " r1[k].carno = int(raw_input(\"Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)\"))\n", + " r1[k].st.hour = int(raw_input(\"Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)\"))\n", + " r1[k].st.minute = int(raw_input(\"Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)\"))\n", + " r1[k].st.second = int(raw_input(\"Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)\"))\n", + " r1[k].rt.hour = int(raw_input(\"Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)\"))\n", + " r1[k].rt.minute = int(raw_input(\"Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)\"))\n", + " r1[k].rt.second = int(raw_input(\"Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)\"))\n", + " \n", + "#Result\n", + "sys.stdout.write(\"\\nCar No.\\t\\tStarting Time\\tReaching Time\")\n", + "for k in range(0,3):\n", + " sys.stdout.write(\"\\n%d\\t\"%(r1[k].carno))\n", + " sys.stdout.write(\"\\t%d:%d:%d\\t\"%(r1[k].st.hour,r1[k].st.minute,r1[k].st.second))\n", + " sys.stdout.write(\"\\t%d:%d:%d\\t\"%(r1[k].rt.hour,r1[k].rt.minute,r1[k].rt.second))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)120\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)20\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)58\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)121\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)40\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)40\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)122\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)30\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)52\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)40\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Car No. Starting Time(hh:mm:ss),Reaching Time(hh:mm:ss)10\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Car No.\t\tStarting Time\tReaching Time\n", + "120\t\t4:30:52\t\t5:40:10\t\n", + "121\t\t4:30:52\t\t5:40:10\t\n", + "122\t\t4:30:52\t\t5:40:10\t" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.8, Page number: 417

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read and display student details\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class stud:\n", + " name = ''\n", + " rollno = 0\n", + " grade = ''\n", + " \n", + "#Class variable declaration\n", + "st = [stud() for i in range(0,3)]\n", + "\n", + "#Variable Initialization\n", + "k = 0 \n", + "while k < 3:\n", + " st[k].name = raw_input(\"Name :\")\n", + " st[k].rollno = int(raw_input(\"Roll No. :\"))\n", + " st[k].grade = raw_input(\"Grade : \")\n", + " k += 1\n", + " \n", + "#Result\n", + "k = 0\n", + "sys.stdout.write(\"\\nName \\tRollno \\tGrade\\n\")\n", + "while k < 3:\n", + " sys.stdout.write(\"\\n%s\\t%d\\t%s\"%(st[k].name,st[k].rollno,st[k].grade))\n", + " k += 1\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name :Suresh\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Roll No. :125\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Grade : A\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name :Mahesh\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Roll No. :126\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Grade : B\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name :Rajesh\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Roll No. :127\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Grade : A\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Name \tRollno \tGrade\n", + "\n", + "Suresh\t125\tA\n", + "Mahesh\t126\tB\n", + "Rajesh\t127\tA" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.9, Page number: 419

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Pointer to structure \n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class book:\n", + " name = ''\n", + " author = ''\n", + " pages = 0\n", + " \n", + "#Class variable declaration\n", + "b1 = book()\n", + "\n", + "#Variable Initialization\n", + "b1.name = \"JAVA COMPLETE REFERENCE\"\n", + "b1.author = \"P.NAUGHTON\"\n", + "b1.pages = 886\n", + "\n", + "#There is no pointer concept in python\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\n%s by %s of %d pages\"%(b1.name,b1.author,b1.pages))\n", + "sys.stdout.write(\"\\n%s by %s of %d pages\"%(b1.name,b1.author,b1.pages))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "JAVA COMPLETE REFERENCE by P.NAUGHTON of 886 pages\n", + "JAVA COMPLETE REFERENCE by P.NAUGHTON of 886 pages" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.10, Page number: 420

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Pointer as members of structure \n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class boy:\n", + " name = ''\n", + " age = 0\n", + " height = 0.0\n", + " \n", + "#Class variable declaration\n", + "sp = boy()\n", + "\n", + "#Variable Initialization\n", + "sp.name = \"Mahesh\"\n", + "sp.age = 20\n", + "sp.height = 5.40\n", + "\n", + "#There is no pointer concept in python\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nName = %s\"%(sp.name))\n", + "sys.stdout.write(\"\\nAge = %s\"%(sp.age))\n", + "sys.stdout.write(\"\\nHeight = %s\"%(sp.height))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Name = Mahesh\n", + "Age = 20\n", + "Height = 5.4" + ] + } + ], + "prompt_number": 28 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.11, Page number: 421

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Pointer as members of structure \n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class boy:\n", + " name = ''\n", + " age = 0\n", + " height = 0.0\n", + " \n", + "#Class variable declaration\n", + "b = boy()\n", + "\n", + "#Variable Initialization\n", + "nm = \"Somesh\"\n", + "ag = 20\n", + "ht = 5.40\n", + "\n", + "#There is no pointer concept in python\n", + "b.name = nm\n", + "b.age = ag\n", + "b.height = ht\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nName : %s\"%(b.name))\n", + "sys.stdout.write(\"\\nAge = %d\"%(b.age))\n", + "sys.stdout.write(\"\\nHeight = %.2g\"%(b.height))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Name : Somesh\n", + "Age = 20\n", + "Height = 5.4" + ] + } + ], + "prompt_number": 30 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.12, Page number: 422

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display the contents of the structure using ordinary pointer\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class num:\n", + " a = 0\n", + " b = 0\n", + " c = 0\n", + "\n", + "#Class variable declaration\n", + "d = num()\n", + "\n", + "#Variable Initialization\n", + "d.a = 2\n", + "d.b = 3\n", + "d.c = 4\n", + "\n", + "#There is no pointer concept in python\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\na = %d\"%(d.a))\n", + "sys.stdout.write(\"\\nb = %d\"%(d.b))\n", + "sys.stdout.write(\"\\nc = %d\"%(d.c))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "a = 2\n", + "b = 3\n", + "c = 4" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.13, Page number: 423

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Passing address of structure variable\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class book:\n", + " name = ''\n", + " author = ''\n", + " pages = 0\n", + " \n", + "#Class variable declaration and initialization\n", + "b1 = book()\n", + "b1.name = \"JAVA COMPLETE REFERENCE\"\n", + "b1.author = \"P.NAUGHTON\"\n", + "b1.pages = 886\n", + "\n", + "#Function definition\n", + "def show(b1):\n", + " sys.stdout.write(\"\\n%s by %s of %d pages\"%(b1.name,b1.author,b1.pages))\n", + "\n", + "#Function call\n", + "show(b1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "JAVA COMPLETE REFERENCE by P.NAUGHTON of 886 pages" + ] + } + ], + "prompt_number": 34 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.14, Page number: 424

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Passing structure elements to function\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class boy:\n", + " name = ''\n", + " age = 0\n", + " wt = 0\n", + " \n", + "#Class variable declaration and initialization\n", + "b1 = boy()\n", + "b1.name = \"Amit\"\n", + "b1.age = 20\n", + "b1.wt = 25\n", + "\n", + "#Function definition\n", + "def print1(s,t,n):\n", + " sys.stdout.write(\"\\n%s %d %d\"%(s,t,n))\n", + " \n", + "#Function call\n", + "print1(b1.name,b1.age,b1.wt)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Amit 20 25" + ] + } + ], + "prompt_number": 36 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.15, Page number: 425

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Pass entire structure to user defined function\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class boy:\n", + " name = ''\n", + " age = 0\n", + " wt = 0\n", + " \n", + "#Class variable declaration and initialization\n", + "b1 = boy()\n", + "b1.name = \"Amit\"\n", + "b1.age = 20\n", + "b1.wt = 25\n", + "\n", + "#Function definition\n", + "def print1(b):\n", + " sys.stdout.write(\"\\n%s %d %d\"%(b.name,b.age,b1.wt))\n", + " \n", + "#Function call\n", + "print1(b1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Amit 20 25" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.16, Page number: 426

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#User defined data type \n", + "\n", + "import sys\n", + "\n", + "#There is no preprocessor directive in python\n", + "H = 60\n", + "\n", + "#There is no typedef function in python and no separate variable declaration is needed\n", + "hrs = int(raw_input(\"Enter Hours :\"))\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nMinutes = %d\"%(hrs*H))\n", + "sys.stdout.write(\"\\nSeconds = %d\"%(hrs*H*H))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Hours :2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Minutes = 120\n", + "Seconds = 7200" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.17, Page number: 426

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#String data type\n", + "\n", + "import sys\n", + "\n", + "#There is no typedef function in python\n", + "a = \" Hello \"\n", + "b = raw_input(\"Enter Your Name : \")\n", + "\n", + "#Result\n", + "sys.stdout.write(\"%s %s\"%(a,b))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Your Name : KAMAL\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Hello KAMAL" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.18, Page number: 427

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Create user defined data type from structure\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "#There is no typedef function in python\n", + "class struct:\n", + " name = ''\n", + " sex = ''\n", + " acno = 0\n", + " \n", + "#class variable declaration and initialization\n", + "employee = struct()\n", + "employee.name = \"Sanjay\"\n", + "employee.sex = \"M\"\n", + "employee.acno = 125\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nName\\tSex\\tA/c No.\\n\")\n", + "sys.stdout.write(\"%s\\t\"%(employee.name))\n", + "sys.stdout.write(\"%s\\t\"%(employee.sex))\n", + "sys.stdout.write(\"%s\\n\"%(employee.acno))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Name\tSex\tA/c No.\n", + "Sanjay\tM\t125\n" + ] + } + ], + "prompt_number": 44 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.19, Page number: 427

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Create user defined data type from structure\n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class struct:\n", + " name = ''\n", + " sex = ''\n", + " acno = 0\n", + " \n", + "#class Variable declaration and initialization\n", + "employee = [struct() for i in range(0,2)]\n", + "\n", + "for k in range(0,2):\n", + " employee[k].name = raw_input(\"Name of the Employee :\")\n", + " employee[k].sex = raw_input(\"Sex\")\n", + " employee[k].acno = raw_input(\"A/c No.\")\n", + " \n", + "#Result\n", + "sys.stdout.write(\"\\nName\\tSex\\tA/c No.\\n\")\n", + "for k in range(0,2):\n", + " sys.stdout.write(\"%s\\t\"%(employee[k].name))\n", + " sys.stdout.write(\"%s\\t\"%(employee[k].sex))\n", + " sys.stdout.write(\"%s\\n\"%(employee[k].acno))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name of the Employee :AJAY\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "SexM\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "A/c No.122\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name of the Employee :ANITA\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "SexF\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "A/c No.124\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Name\tSex\tA/c No.\n", + "AJAY\tM\t122\n", + "ANITA\tF\t124\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.20, Page number: 429

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Structure containing the details of the employees\n", + "\n", + "import sys\n", + "\n", + "#There is no typedef function in python\n", + "\n", + "#Class definition\n", + "class struct:\n", + " first = ''\n", + " middle = ''\n", + " last = ''\n", + " city = ''\n", + " pincode = 0\n", + " \n", + "#Class variable declaration and initialization\n", + "person = [struct() for i in range(0,2)]\n", + "\n", + "for j in range(0,2):\n", + " person[j].first = raw_input(\"First Name :\")\n", + " person[j].middle = raw_input(\"Middle Name : \")\n", + " person[j].last = raw_input(\"Last Name : \")\n", + " person[j].city = raw_input(\"City & Pincode\")\n", + " person[j].pincode = int(raw_input(\"City & Pincode\"))\n", + " \n", + "#Result\n", + "for j in range(0,2):\n", + " sys.stdout.write(\"\\nRecord No : %d\"%(j+1))\n", + " sys.stdout.write(\"\\nFirst Name : %s\"%(person[j].first))\n", + " sys.stdout.write(\"\\nMiddle Name : %s\"%(person[j].middle))\n", + " sys.stdout.write(\"\\nLast Name : %s\"%(person[j].last))\n", + " sys.stdout.write(\"\\nCity & Pincode : %s - %d\\n\"%(person[j].city,person[j].pincode))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "First Name :Jay\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Middle Name : Mohan\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Last Name : Deshmukh\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "City & PincodeNanded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "City & Pincode431602\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "First Name :Vijay\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Middle Name : Kamal\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Last Name : Nandedkar\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "City & PincodeNanded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "City & Pincode431602\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Record No : 1\n", + "First Name : Jay\n", + "Middle Name : Mohan\n", + "Last Name : Deshmukh\n", + "City & Pincode : Nanded - 431602\n", + "\n", + "Record No : 2\n", + "First Name : Vijay\n", + "Middle Name : Kamal\n", + "Last Name : Nandedkar\n", + "City & Pincode : Nanded - 431602\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.21, Page number: 431

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Information of vehicles\n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "PETROL = 1\n", + "DISEL = 2\n", + "TWO_WH = 3\n", + "FOUR_WH = 4\n", + "OLD = 5\n", + "NEW = 6\n", + "\n", + "#Class declaration\n", + "class vehicle:\n", + " type1 = 3\n", + " fuel = 2\n", + " model = 3\n", + " \n", + "#Class variable declaration and initialization\n", + "v = vehicle()\n", + "v.type1 = FOUR_WH\n", + "v.fuel = DISEL\n", + "v.model = OLD\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nType of Vehicle : %d\"%(v.type1))\n", + "sys.stdout.write(\"\\nFuel : %d\"%(v.fuel))\n", + "sys.stdout.write(\"\\nModel : %d\"%(v.model))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Type of Vehicle : 4\n", + "Fuel : 2\n", + "Model : 5" + ] + } + ], + "prompt_number": 52 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.22, Page number: 432

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display the examination result of the student \n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "#There is no preprocessor directives in python\n", + "PASS = 1\n", + "FAIL = 0\n", + "A = 0\n", + "B = 1\n", + "C = 2\n", + "\n", + "#Class declaration\n", + "class student:\n", + " name = ''\n", + " result = 1\n", + " grade = 2\n", + " \n", + "#Class variable declaration and initialization\n", + "v = student()\n", + "\n", + "v.name = \"Sachin\"\n", + "v.result = PASS\n", + "v.grade = C\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nName : %s\"%(v.name))\n", + "sys.stdout.write(\"\\nResult : %d\"%(v.result))\n", + "sys.stdout.write(\"\\nGrade : %d\"%(v.grade))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Name : Sachin\n", + "Result : 1\n", + "Grade : 2" + ] + } + ], + "prompt_number": 53 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.23, Page number: 433

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Enumerated data type for 12 months\n", + "\n", + "import sys\n", + "\n", + "#There is no enumerated data type in python and an alternate is to use class\n", + "#Class declaration\n", + "class month:\n", + " Jan = 0\n", + " Feb = 1\n", + " Mar = 2\n", + " Apr = 3\n", + " May = 4\n", + " June = 5\n", + " July = 6\n", + " Aug = 7\n", + " Sep = 8\n", + " Oct = 9\n", + " Nov = 10\n", + " Dec = 11\n", + " \n", + "#Class variable declaration\n", + "c = month()\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nJan = %d\"%(c.Jan))\n", + "sys.stdout.write(\"\\nFeb = %d\"%(c.Feb))\n", + "sys.stdout.write(\"\\nJune = %d\"%(c.June))\n", + "sys.stdout.write(\"\\nDec = %d\"%(c.Dec))\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Jan = 0\n", + "Feb = 1\n", + "June = 5\n", + "Dec = 11" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.24, Page number: 434

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Enumerated data type \n", + "\n", + "import sys\n", + "\n", + "#There is no enumerated data type in python and an alternate is to use class\n", + "#Class declaration\n", + "class month:\n", + " Jan = 1\n", + " Feb = 2\n", + " Mar = 3\n", + " Apr = 4\n", + " May = 5\n", + " June = 6\n", + " July = 7\n", + " Aug = 8\n", + " Sep = 9\n", + " Oct = 10\n", + " Nov = 11\n", + " Dec = 12\n", + " \n", + "#Class variable declaration\n", + "c = month()\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nJan = %d\"%(c.Jan))\n", + "sys.stdout.write(\"\\nFeb = %d\"%(c.Feb))\n", + "sys.stdout.write(\"\\nJune = %d\"%(c.June))\n", + "sys.stdout.write(\"\\nDec = %d\"%(c.Dec))\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Jan = 1\n", + "Feb = 2\n", + "June = 6\n", + "Dec = 12" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.25, Page number: 434

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display name of month using enumerated data type\n", + "\n", + "import sys\n", + "\n", + "#There is no enumerated data type in python and an alternate is to use class\n", + "#Class declaration\n", + "class month:\n", + " Jan = 1\n", + " Feb = 2\n", + " Mar = 3\n", + " Apr = 4\n", + " May = 5\n", + " June = 6\n", + " July = 7\n", + " Aug = 8\n", + " Sep = 9\n", + " Oct = 10\n", + " Nov = 11\n", + " Dec = 12\n", + " \n", + "#Class variable declaration\n", + "c = month()\n", + "\n", + "#Result\n", + "for f in range(c.Jan,c.Dec+1):\n", + " #There is no switch case statement in python\n", + " if f == c.Jan:\n", + " sys.stdout.write(\"\\nJanuary\")\n", + " else:\n", + " if f == c.Feb:\n", + " sys.stdout.write(\"\\nFebruary\")\n", + " else:\n", + " if f == c.Mar:\n", + " sys.stdout.write(\"\\nMarch\")\n", + " else:\n", + " if f == c.Apr:\n", + " sys.stdout.write(\"\\nApril\")\n", + " else:\n", + " if f == c.May:\n", + " sys.stdout.write(\"\\nMay\")\n", + " else:\n", + " if f == c.June:\n", + " sys.stdout.write(\"\\nJune\")\n", + " else:\n", + " if f == c.July:\n", + " sys.stdout.write(\"\\nJuly\")\n", + " else:\n", + " if f == c.Aug:\n", + " sys.stdout.write(\"\\nAugust\")\n", + " else:\n", + " if f == c.Sep:\n", + " sys.stdout.write(\"\\nSeptember\")\n", + " else:\n", + " if f == c.Oct:\n", + " sys.stdout.write(\"\\nOctober\")\n", + " else:\n", + " if f == c.Nov:\n", + " sys.stdout.write(\"\\nNovember\")\n", + " else:\n", + " sys.stdout.write(\"\\nDecember\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "January\n", + "February\n", + "March\n", + "April\n", + "May\n", + "June\n", + "July\n", + "August\n", + "September\n", + "October\n", + "November\n", + "December" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.26, Page number: 436

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Enumerated data type\n", + "\n", + "import sys\n", + "\n", + "#There is no enumerated data type in python. class is used instead\n", + "class capital:\n", + " Mumbai = 0\n", + " Hyderabad = 1\n", + " Bangalore = 2\n", + "\n", + "class state:\n", + " name = ''\n", + " c = capital()\n", + " \n", + "#Class variable declaration\n", + "s = state()\n", + "c1 = capital()\n", + "\n", + "#Class variable initialization\n", + "s.name = \"Andhra Pradesh\"\n", + "s.c = s.c.Hyderabad\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nState : %s\"%(s.name))\n", + "sys.stdout.write(\"\\nCapital : %d\"%(s.c))\n", + "\n", + "if s.c == c1.Hyderabad:\n", + " sys.stdout.write(\"\\nHyderabad is Capital of %s\"%(s.name))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "State : Andhra Pradesh\n", + "Capital : 1\n", + "Hyderabad is Capital of Andhra Pradesh" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.27, Page number: 437

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Identify the type of entered character using enumerated data type.\n", + "\n", + "import sys\n", + "\n", + "#Class declaration instead of enumerated data type\n", + "class ctype:\n", + " Letter = 0\n", + " Digit = 1\n", + " Other = 2\n", + " \n", + "#Variable Initialization\n", + "ch = raw_input(\"Enter any character\")\n", + "c = ctype()\n", + "f = ch.isalpha()\n", + "\n", + "#Result\n", + "if f != 0:\n", + " sys.stdout.write(\"\\n%c is %d type of symbol\"%(ch,c.Letter))\n", + "else:\n", + " f = ch.isdigit()\n", + " if f != 0:\n", + " sys.stdout.write(\"\\n%c is %d type of symbol\"%(ch,c.Digit))\n", + " else:\n", + " sys.stdout.write(\"\\n%c is %d type of symbol\"%(ch,c.Other))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter any character=\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "= is 2 type of symbol" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.28, Page number: 438

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Size of union and number of bytes reserved for it\n", + "\n", + "import sys\n", + "\n", + "#There is no union/structure in python. class is used instead\n", + "#Class declaration\n", + "class result:\n", + " marks = 0\n", + " grade = ''\n", + " \n", + "class res:\n", + " name = ''\n", + " age = 0\n", + " perf = result()\n", + " \n", + "#Class variable declaration\n", + "data = res()\n", + "\n", + "#Result\n", + "sys.stdout.write(\"Size of Union : %d\\n\"%(sys.getsizeof(data.perf)))\n", + "sys.stdout.write(\"Size of Structure : %d\\n\"%(sys.getsizeof(data)))\n", + "\n", + "#in python, value tagged method is used for data storage and can represent large numbers" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Size of Union : 36\n", + "Size of Structure : 36\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.29, Page number: 440

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Memory size of the computer\n", + "\n", + "import psutil\n", + "\n", + "psutil.phymem_usage()\n", + "\n", + "#Displays current status of the memory\n", + "#different systems will have different memory status" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "pyout", + "prompt_number": 4, + "text": [ + "usage(total=1600512000L, used=1496383488L, free=104128512L, percent=93.5)" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.30, Page number: 440

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display the system time at specified cursor position\n", + "\n", + "import sys\n", + "import datetime\n", + "\n", + "#Result\n", + "sys.stdout.write(\"%s\"%(datetime.datetime.now()))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2013-09-20 11:04:15.649000" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.31, Page number: 441

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Change the cursor in different sizes\n", + "\n", + "import turtle\n", + "#Ipython supports graphics through turtle module\n", + "\n", + "from Tkinter import *\n", + "import Tkinter\n", + "\n", + "top = Tkinter.Tk()\n", + "\n", + "B1 = Tkinter.Button(top, text =\"circle\", relief=RAISED,\\\n", + " cursor=\"circle\")\n", + "B2 = Tkinter.Button(top, text =\"plus\", relief=RAISED,\\\n", + " cursor=\"plus\")\n", + "B1.pack()\n", + "B2.pack()\n", + "#top.mainloop()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.32, Page number: 441

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Create a directory using dos interrupt\n", + "\n", + "import os\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "dir1 = raw_input(\"Enter Directory Name : \")\n", + "\n", + "#Result\n", + "if not os.path.exists(dir1):\n", + " os.makedirs(dir1)\n", + " sys.stdout.write(\"Directory %s created\"%(dir1))\n", + "else:\n", + " sys.stdout.write(\"Directory %s not created\"%(dir1))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Directory XYZ created" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.33, Page number: 442

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display the given character on the screen\n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "dl = 67\n", + "\n", + "#Result\n", + "sys.stdout.write(\"%c\"%(chr(dl)))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "C" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.34, Page number: 442

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display the attributes of a file using DOS interrupt\n", + "\n", + "import sys\n", + "\n", + "import os\n", + "\n", + "print os.stat(\"IO.SYS\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "nt.stat_result(st_mode=33206, st_ino=0L, st_dev=0, st_nlink=0, st_uid=0, st_gid=0, st_size=0L, st_atime=1383454467L, st_mtime=1383454467L, st_ctime=1383454467L)\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.35, Page number: 444

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Delete a file using dos interrupt\n", + "\n", + "import os\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "file1 = raw_input(\"Enter a file name : \")\n", + "\n", + "try:\n", + " os.remove(file1)\n", + " sys.stdout.write(\"File successfully deleted\")\n", + "except:\n", + " sys.stdout.write(\"File could not be deleted\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "File successfully deleted" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 13.36, Page number: 445

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Structuret within union\n", + "\n", + "import sys\n", + "\n", + "#there is no union/structure in python. class is used instead\n", + "#Class declaration\n", + "class x:\n", + " f = 0.0\n", + " p = ['' for i in range(0,2)]\n", + " \n", + "class z:\n", + " set1 = x()\n", + " \n", + "#Class variable declaration and initialization\n", + "st = z()\n", + "\n", + "st.set1.f = 5.5\n", + "st.set1.p[0] = 65\n", + "st.set1.p[1] = 66\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\n%g\"%(st.set1.f))\n", + "sys.stdout.write(\"\\n%c\"%(st.set1.p[0]))\n", + "sys.stdout.write(\"\\n%c\"%(st.set1.p[1]))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "5.5\n", + "A\n", + "B" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Programming_in_C_using_ANSI_C/KamthaneChapter14.ipynb b/Programming_in_C_using_ANSI_C/KamthaneChapter14.ipynb new file mode 100755 index 00000000..409585bd --- /dev/null +++ b/Programming_in_C_using_ANSI_C/KamthaneChapter14.ipynb @@ -0,0 +1,2311 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Chapter 14: Files

" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.1, Page number: 454

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Write data to text file and read it\n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','a')\n", + "\n", + "#Write data to file if successfully created the file\n", + "if fp == 0:\n", + " sys.stdout.write(\"Cannot open file\")\n", + "else:\n", + " sys.stdout.write(\"Write data & to stop press '.'\")\n", + " c = ''\n", + " while c != '.':\n", + " c = raw_input(\"Write data & to stop press '.'\")\n", + " fp.write(c)\n", + " fp.close()\n", + "\n", + " #Read and display the contents of file\n", + " sys.stdout.write(\"\\nContents read : \")\n", + " fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','r')\n", + " f = fp.readlines()\n", + " for f1 in f:\n", + " print f1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Write data & to stop press '.'" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Write data & to stop press '.'ABCDEFGHIJK\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Write data & to stop press '.'.\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Contents read : ABCDEFGHIJK.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.2, Page number: 455

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display the contents of the file before and after appending.\n", + "\n", + "import sys\n", + "\n", + "#Open file for read data\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','r')\n", + "\n", + "#Read and display the contents of file\n", + "sys.stdout.write(\"\\nContents of file before appending :\\n\")\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','r')\n", + "f = fp.readlines()\n", + "for f1 in f:\n", + " print f1\n", + "\n", + "#Open file for appending\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','a')\n", + "\n", + "if f == 0:\n", + " sys.stdout.write(\"File can not appended\")\n", + "else:\n", + " c = ''\n", + " #fp.write('\\n')\n", + " while c != '.':\n", + " c = raw_input(\"Enter string to append\")\n", + " fp.write(c)\n", + " \n", + " fp.close()\n", + " \n", + " #Read and display the contents of file\n", + " sys.stdout.write(\"\\nContents of file After appending\\n\")\n", + " fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','r')\n", + " f = fp.readlines()\n", + " for f1 in f:\n", + " print f1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Contents of file before appending :\n", + "String is terminated with '\\0'.\n", + "\n", + "Contents of file After appending\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "String is terminated with '\\0'.This character is called as NULL character.\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.3, Page number: 457

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Writing and reading of a file.\n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','w+')\n", + "\n", + "#Write data to file if successfully created the file\n", + "if fp == 0:\n", + " sys.stdout.write(\"Cannot open file\")\n", + "else:\n", + " sys.stdout.write(\"Write data & to stop press '.'\")\n", + " c = ''\n", + " while c != '.':\n", + " c = raw_input(\"Write data & to stop press '.'\")\n", + " fp.write(c)\n", + " fp.close()\n", + "\n", + " #Read and display the contents of file\n", + " sys.stdout.write(\"\\nContents read : \")\n", + " fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','r')\n", + " f = fp.readlines()\n", + " for f1 in f:\n", + " print f1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Write data & to stop press '.'\n", + "Contents read : " + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "ABCDEFGHIJK.\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.4, Page number: 458

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Open a file in append mode and add new records in it.\n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','a+')\n", + "\n", + "#Write data to file if successfully created the file\n", + "if fp == 0:\n", + " sys.stdout.write(\"Cannot open file\")\n", + "else:\n", + " sys.stdout.write(\"Write data & to stop press '.'\")\n", + " c = ''\n", + " while c != '.':\n", + " c = raw_input(\"Write data & to stop press '.'\")\n", + " fp.write(c)\n", + " fp.close()\n", + "\n", + " #Read and display the contents of file\n", + " sys.stdout.write(\"\\nContents read : \")\n", + " fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','a+')\n", + " f = fp.readlines()\n", + " for f1 in f:\n", + " print f1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Write data & to stop press '.'\n", + "Contents read : " + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "This is append and read mode.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.5, Page number: 459

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Open a file in read/write mode in it\n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','r+')\n", + "\n", + "#Write data to file if successfully created the file\n", + "if fp == 0:\n", + " sys.stdout.write(\"Cannot open file\")\n", + "else:\n", + " #Read and display the contents of file\n", + " sys.stdout.write(\"\\nContents read : \")\n", + " f = fp.readlines()\n", + " for f1 in f:\n", + " print f1\n", + " \n", + " sys.stdout.write(\"Write data & to stop press '.'\")\n", + " c = ''\n", + " while c != '.':\n", + " c = raw_input(\"Write data & to stop press '.'\")\n", + " fp.write(c)\n", + " fp.close()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Contents read : Help me.\n", + "Write data & to stop press '.'" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.6, Page number: 460

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Open a file for read/write operation in binary mode\n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','wb')\n", + "\n", + "#Write data to file if successfully created the file\n", + "if fp == 0:\n", + " sys.stdout.write(\"Cannot open file\")\n", + "else:\n", + " sys.stdout.write(\"Write data & to stop press '.'\")\n", + " c = ''\n", + " while c != '.':\n", + " c = raw_input(\"Write data & to stop press '.'\")\n", + " fp.write(c)\n", + " fp.close()\n", + "\n", + " #Read and display the contents of file\n", + " sys.stdout.write(\"\\nContents read : \")\n", + " fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','rb')\n", + " f = fp.readlines()\n", + " for f1 in f:\n", + " print f1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Write data & to stop press '.'\n", + "Contents read : " + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "ABCDEFGHIJK.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.7, Page number: 462

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Open a text file and write some text \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','w')\n", + "\n", + "#Read the string\n", + "text = raw_input(\"Enter Text Here : \")\n", + "\n", + "#Write to the file\n", + "#fp.write() is the equivalent function for fprintf() in python\n", + "fp.write(\"%s\"%(text))\n", + "\n", + "#To see the result, open the data.txt file" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.8, Page number: 463

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Enter data into the text file and read the same. \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','w')\n", + "\n", + "#Read the data\n", + "text = raw_input(\"Name & Age\")\n", + "age = int(raw_input(\"Name & Age\"))\n", + "\n", + "#Write to file\n", + "fp.write(\"%s %d\"%(text,age))\n", + "\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\data.txt','r')\n", + "#Result\n", + "sys.stdout.write(\"Name\\tAge\\n\")\n", + "text = fp.read()\n", + "age = fp.read()\n", + "sys.stdout.write(\"%s\\t%s\\n\"%(text,age))\n", + "fp.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name\tAge\n", + "AMIT 12\t\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.9, Page number: 463

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read the contents of the file \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "f = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\list.txt','r')\n", + "\n", + "if f == 0:\n", + " sys.stdout.write(\"Cannot open file\")\n", + "else:\n", + " for c in f:\n", + " sys.stdout.write(\"%s\"%(c))\n", + " #Python gives iterative statements there is no getc() fucntion" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "aman\n", + "akash\n", + "amit\n", + "ajay\n", + "ankit" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.10, Page number: 464

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Write some text into the file \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\words.doc','w')\n", + "\n", + "#Write data to file\n", + "c = ''\n", + "while c != '*':\n", + " c = raw_input(\"Enter Few Words '*' to Exit\")\n", + " fp.write(c)\n", + "\n", + "fp.close()\n", + " #There is no putc() function in python\n", + " #Open the file to see the result" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.11, Page number: 465

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Count\n", + "\n", + "# Total number of statements\n", + "# Total number of included files\n", + "# Total number of blocks and brackets\n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fs = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\PRG2.C','r')\n", + "\n", + "#variable initialization\n", + "i = 0\n", + "c = 0\n", + "sb = 0\n", + "b = 0\n", + "\n", + "if fs == 0:\n", + " sys.stdout.write(\"File opening error\")\n", + "else:\n", + " for line in fs:\n", + " k = 0\n", + " while k < len(line):\n", + " if line[k] == ';':\n", + " c += 1\n", + " else:\n", + " if line[k] == '{':\n", + " sb += 1\n", + " else:\n", + " if line[k] == '(':\n", + " b += 1\n", + " else:\n", + " if line[k] == '#':\n", + " i += 1\n", + " k += 1\n", + " \n", + " #Result\n", + " sys.stdout.write(\"\\nSummary of 'C' Program\\n\")\n", + " sys.stdout.write(\"===========================\")\n", + " sys.stdout.write(\"\\nTotal Statments : %d\"%(c+i))\n", + " sys.stdout.write(\"\\nInclude Statements : %d\"%(i))\n", + " sys.stdout.write(\"\\nTotal Blocks {} : %d\"%(sb))\n", + " sys.stdout.write(\"\\nTotal Brackets () : %d\"%(b))\n", + " sys.stdout.write(\"\\n============================\")\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Summary of 'C' Program\n", + "===========================\n", + "Total Statments : 8\n", + "Include Statements : 2\n", + "Total Blocks {} : 2\n", + "Total Brackets () : 9\n", + "============================" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.12, Page number: 466

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Write text to a file \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open('C:\\Users\\Aathira\\Documents\\IPython Notebooks\\lines.txt','w')\n", + "\n", + "if fp == 0:\n", + " sys.stdout.write(\"\")\n", + "else:\n", + " #Write data to file\n", + " c = ''\n", + " while c != '*':\n", + " c = raw_input(\"\")\n", + " fp.write(c)\n", + " fp.close()\n", + " #There is no fputc() function in python\n", + " #Open the file to see the result" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 10 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.13, Page number: 467

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read text from the given file \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "\n", + "file1 = raw_input(\"Enter File Name : \")\n", + "fp = open(file1,'r')\n", + "\n", + "if fp == 0:\n", + " sys.stdout.write(\"File not found\\n\")\n", + "else:\n", + " for text in fp:\n", + " print text\n", + " #File pointer itself is iterable in python" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "#include \n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.14, Page number: 468

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Write a string into a file \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "\n", + "file1 = raw_input(\"Enter the name of file : \")\n", + "fp = open(file1,'w')\n", + "\n", + "if fp == 0:\n", + " sys.stdout.write(\"File can not opened\\n\")\n", + "else:\n", + " text = raw_input(\"Enter Text Here : \")\n", + " fp.write(text)\n", + " \n", + " #Write() function is used to write character or string into the file in python\n", + " # there is no fputc() function in python\n", + "#open the file to see the result" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 13 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.15, Page number: 469

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Write integers in a file \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open('num.txt','w')\n", + "\n", + "if fp == 0:\n", + " sys.stdout.write(\"File does not exist\\n\")\n", + "else:\n", + " v = ' '\n", + " while v != '0':\n", + " fp.write(v)\n", + " v = raw_input(\"Enter Numbers\")\n", + " \n", + " #open the file to see the result" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.16, Page number: 470

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read integers from the file \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open('num.txt','r')\n", + "\n", + "if fp == 0:\n", + " sys.stdout.write(\"File does not exist\\n\")\n", + "else:\n", + " for v in fp:\n", + " print v" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1 2 3 4 5\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.17, Page number: 471

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Write a block of structure elements to the given file \n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class student:\n", + " name = ''\n", + " age = 0\n", + " \n", + "#Class variable declaration\n", + "stud = [student() for i in range(0,5)]\n", + "\n", + "#Open file\n", + "file1 = raw_input(\"Enter the file name : \")\n", + "fp = open(file1,'w')\n", + "\n", + "if fp == 0:\n", + " sys.stdout.write(\"File does not exist\\n\")\n", + "else:\n", + " n = int(raw_input(\"How Many Records : \"))\n", + " for i in range(0,n):\n", + " stud[i].name = raw_input(\"Name : \")\n", + " stud[i].age = int(raw_input(\"Age : \"))\n", + " \n", + " j = 0\n", + " while j < n:\n", + " fp.write(\"%s %d\\n\"%(stud[j].name,stud[j].age))\n", + " j += 1\n", + " \n", + " fp.close()\n", + " \n", + " #open the file to see the result" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.18, Page number: 472

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Write and read the information about the player \n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class record:\n", + " player = ''\n", + " age = 0\n", + " runs = 0\n", + " \n", + "#Class variable declaration\n", + "emp = record()\n", + "\n", + "#Open file\n", + "fp = open('record.dat','w')\n", + "\n", + "if fp == 0:\n", + " sys.stdout.write(\"Can not open the file\\n\")\n", + "else:\n", + " emp.player = raw_input(\"Enter Player Name\")\n", + " emp.age = int(raw_input(\"Enter Age\"))\n", + " emp.runs = int(raw_input(\"Enter runs scored\"))\n", + " fp.write(\"%s %d %d\"%(emp.player,emp.age,emp.runs))\n", + " fp.close()\n", + " \n", + " fp = open('record.dat','r')\n", + " if fp == 0:\n", + " sys.stdout.write(\"Error in opening file\")\n", + " else:\n", + " sys.stdout.write(\"\\nRecord Entered is\\n\")\n", + " emp.player,emp.age,emp.runs = fp.read().split(' ')\n", + " sys.stdout.write(\"\\n%s %s %s\"%(emp.player,emp.age,emp.runs))\n", + " fp.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Player NameSachin\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Age25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter runs scored10000\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Record Entered is\n", + "\n", + "Sachin 25 10000" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.19, Page number: 473

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Write a block of structure elements to the given file \n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "next1 = 'Y'\n", + "\n", + "#Class declaration\n", + "class bike:\n", + " name = ''\n", + " avg = 0\n", + " cost = 0.0\n", + " \n", + "#Class variable declaration\n", + "e = bike()\n", + "\n", + "#open file\n", + "fp = open('bk.txt','wb')\n", + "\n", + "if fp == 0:\n", + " sys.stdout.write(\"Cannot open file\")\n", + "else:\n", + " while next1 == 'Y':\n", + " e.name = raw_input(\"Model Name\")\n", + " e.avg = int(raw_input(\"Average\"))\n", + " e.cost = float(raw_input(\"Price\"))\n", + " fp.write(\"%s %d %f\\n\"%(e.name,e.avg,e.cost))\n", + " \n", + " next1 = raw_input(\"Add Another (Y/N):\")\n", + " fp.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Model NameHONDA\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average80\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Price45000\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Add Another (Y/N):Y\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Model NameSUZUKI\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average65\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Price43000\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Add Another (Y/N):Y\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Model NameYAMAHA\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average55\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Price48000\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Add Another (Y/N):N\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.20, Page number: 474

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read the information about the bike \n", + "\n", + "import sys\n", + "\n", + "#Class declaration\n", + "class bike:\n", + " name = ''\n", + " avg = 0\n", + " cost = 0.0\n", + " \n", + "#Class variable declaration\n", + "e = bike()\n", + "\n", + "#open file\n", + "fp = open('bk.txt','rb')\n", + "\n", + "if fp == 0:\n", + " sys.stdout.write(\"Cannot open file\")\n", + "else:\n", + " lines = fp.readlines()\n", + " for line in lines:\n", + " e.name,e.avg,e.cost = line.split(' ')\n", + " e.avg = int(e.avg)\n", + " e.cost = float(e.cost)\n", + " sys.stdout.write(\"\\n%s %d %.2f\"%(e.name,e.avg,e.cost))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "HONDA 80 45000.00\n", + "SUZUKI 65 43000.00\n", + "YAMAHA 55 48000.00" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.21, Page number: 476

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read the text after skipping n characters from beginning of the file\n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open(\"text.txt\",\"r\")\n", + "\n", + "sys.stdout.write(\"\\nContents of file\\n\")\n", + "ch = fp.read()\n", + "sys.stdout.write(\"%s\"%(ch))\n", + "\n", + "#Read n\n", + "n = int(raw_input(\"How many characters including spaces would you like to skip?\"))\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nInformation after %d bytes\\n\"%(n))\n", + "\n", + "ch = ch[n:]\n", + "sys.stdout.write(\"%s\"%(ch))\n", + "\n", + "fp.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Contents of file\n", + "THE C PROGRAMMING LANGUAGE INVENTED BY DENNIS RITCHIE" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many characters including spaces would you like to skip?18\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Information after 18 bytes\n", + "LANGUAGE INVENTED BY DENNIS RITCHIE" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.22, Page number: 477

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read last few characters of the file \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open(\"text.txt\",\"r\")\n", + "\n", + "sys.stdout.write(\"\\nContents of file\\n\")\n", + "ch = fp.read()\n", + "sys.stdout.write(\"%s\"%(ch))\n", + "\n", + "#Read n\n", + "n = int(raw_input(\"How many characters including spaces would you like to skip?\"))\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nInformation after %d bytes\\n\"%(n))\n", + "\n", + "print ch[-n:]\n", + "\n", + "fp.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Contents of file\n", + "HELLO WORLD" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many characters including spaces would you like to skip?5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Information after 5 bytes\n", + "WORLD\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.23, Page number: 477

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display 'c' program files in current directory. \n", + "\n", + "import sys\n", + "\n", + "#Variable initialization\n", + "l = 0\n", + "c = 0\n", + "\n", + "#Open file\n", + "file1 = raw_input(\"Enter the file name : \")\n", + "fp = open(file1,'r')\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nContents of 'c' program file in capital case\")\n", + "sys.stdout.write(\"\\n============================================\\n\")\n", + "\n", + "ch = fp.readlines()\n", + "\n", + "for line in ch:\n", + " i = 0\n", + " #print line.upper()\n", + " while i < len(line):\n", + " if line[i] =='\\n':\n", + " l += 1\n", + " else:\n", + " c += 1\n", + " sys.stdout.write(\"%c\"%(line[i].upper()))\n", + " i += 1\n", + "\n", + "sys.stdout.write(\"\\nTotal Characters : %d\"%(c))\n", + "sys.stdout.write(\"\\nTotal Lines : %d\"%(l))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Contents of 'c' program file in capital case\n", + "============================================\n", + "MAIN()\n", + "{\n", + "PRINTF(\" HELLO WORLD\");\n", + "}\n", + "\n", + "Total Characters : 31\n", + "Total Lines : 4" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.24, Page number: 479

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Detect the end of file \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open(\"text.txt\",\"r\")\n", + "\n", + "#there is no feof() function in python\n", + "c = fp.tell()\n", + "sys.stdout.write(\"File pointer at the beginning of the file : %d\\n\"%(c))\n", + "\n", + "c = fp.read()\n", + "sys.stdout.write(\"%s\"%(c))\n", + "\n", + "c = fp.tell()\n", + "sys.stdout.write(\"\\nFile pointer at the end of file : %d\"%(c))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "File pointer at the beginning of the file : 0\n", + "TECHNOCRATS LEAD THE WORLD \n", + "File pointer at the end of file : 32" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.25, Page number: 480

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Detect an error while read/write operation of a file is in use.\n", + "\n", + "import sys\n", + "\n", + "#Variable initialization\n", + "next1 = 'Y'\n", + "\n", + "#open file\n", + "fp = open('marks.dat','r')\n", + "\n", + "if fp == 0:\n", + " sys.stdout.write(\"Can not open file\")\n", + "else:\n", + " while next1 == 'Y':\n", + " name = raw_input(\"Enter Name, Marks, Percentage\")\n", + " marks = int(raw_input(\"Enter Name, Marks, Percentage\"))\n", + " \n", + " p = marks/7\n", + " try:\n", + " fp.write(\"%s %d %f\"%(name,marks,p))\n", + " except:\n", + " sys.stdout.write(\"\\nUnable to write data?\")\n", + " sys.stdout.write(\"\\nFile opening mode is incorrect.\")\n", + " fp.close()\n", + " \n", + " next1 = raw_input(\"Continue Y/N:\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Name, Marks, PercentageKAMAL\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Name, Marks, Percentage540\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Unable to write data?\n", + "File opening mode is incorrect." + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Continue Y/N:N\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.26, Page number: 481

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Catch the error that is occurred while file operation\n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "f = open(\"io8.c\",\"w\")\n", + "\n", + "if f == 0:\n", + " sys.stdout.write(\"\\nCannot open file\")\n", + "else:\n", + " #Exception handling\n", + " try:\n", + " c = fp.readlines()\n", + " sys.stdout.write(\"%s\"%(c))\n", + " except:\n", + " sys.stdout.write(\"\\nCan't read file.\")\n", + "#There is no ferror() function python." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Can't read file." + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.27, Page number: 482

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Detect and print the error message\n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "file1 = \"lines.txt\"\n", + "\n", + "#Open file\n", + "fr = open(file1,\"w\")\n", + "\n", + "sys.stdout.write(\"%s : \"%(file1))\n", + "#Exception handling\n", + "try:\n", + " c = fp.readlines()\n", + "except:\n", + " sys.stdout.write(\"Permission Denied\")\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "lines.txt : Permission Denied" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.28, Page number: 482

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Print the current position of the file pointer \n", + "\n", + "import sys\n", + "\n", + "#Open file\n", + "fp = open(\"text.txt\",\"r\")\n", + "\n", + "#Set the pointer\n", + "fp.seek(21)\n", + "\n", + "#Result\n", + "while True:\n", + " c = fp.read(1)\n", + " if not c:\n", + " break\n", + " sys.stdout.write(\"%c\\t%d\\n\"%(c,fp.tell()))\n", + "#There is no endof file in python" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "W\t22\n", + "O\t23\n", + "R\t24\n", + "L\t25\n", + "D\t26\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.29, Page number: 483

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Detect beginning of file\n", + "\n", + "import sys\n", + "\n", + "#open file\n", + "fp = open(\"text.txt\",\"r\")\n", + "\n", + "fp.seek(12)\n", + "sys.stdout.write(\"Pointer is at %d\\n\"%(fp.tell()))\n", + "sys.stdout.write(\"Before rewind() : \")\n", + "\n", + "#Result\n", + "while True:\n", + " c = fp.read(1)\n", + " if not c:\n", + " break\n", + " sys.stdout.write(\"%c\"%(c))\n", + " \n", + "sys.stdout.write(\"\\nAfter rewind() : \")\n", + "fp.seek(0)\n", + "#There is no rewind function in python\n", + "\n", + "while True:\n", + " c = fp.read(1)\n", + " if not c:\n", + " break\n", + " sys.stdout.write(\"%c\"%(c))\n", + " \n", + "fp.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Pointer is at 12\n", + "Before rewind() : LEAD THE WORLD\n", + "After rewind() : TECHNOCRATS LEAD THE WORLD" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.30, Page number: 484

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Delete the given file \n", + "\n", + "import sys\n", + "import os\n", + "\n", + "#Read file name\n", + "file1 = raw_input(\"Enter The File Name : \")\n", + "\n", + "#There is no remove or unlink file function in python.\n", + "#A file can be deleted using remove function in the os module.\n", + "\n", + "try:\n", + " os.remove(file1)\n", + " sys.stdout.write(\"\\nFile (%s) has been deleted!\"%(file1))\n", + "except:\n", + " sys.stdout.write(\"\\nFile does not exist\")\n", + "\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "File (TEXT.TXT) has been deleted!" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.31, Page number: 485

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Change the name of the file\n", + "\n", + "import os\n", + "import sys\n", + "\n", + "old = raw_input(\"Old File Name : \")\n", + "\n", + "new = raw_input(\"New File Name : \")\n", + "\n", + "os.rename(old, new)\n", + "\n", + "#Check the directory to see the result\n" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 22 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.32, Page number: 486

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Copy the contents of one file to another file\n", + "\n", + "import sys\n", + "\n", + "fs = open(\"a.txt\",\"r\")\n", + "ft = open(\"b.txt\",\"w\")\n", + "c = 0\n", + "\n", + "if fs == 0:\n", + " sys.stdout.write(\"\\nSource file opening error.\")\n", + "else:\n", + " if ft == 0:\n", + " sys.stdout.write(\"\\nTarget file opening error.\")\n", + " else:\n", + " while True:\n", + " ch = fs.read(1)\n", + " if not ch:\n", + " break\n", + " ft.write(\"%c\"%(ch))\n", + " c += 1\n", + " sys.stdout.write(\"\\n%d Bytes copied from 'a.txt' to 'b.txt'.\"%(c))\n", + " c = 0\n", + " #there is no fcloseall() function in python\n", + " fs.close()\n", + " c += 1\n", + " ft.close()\n", + " c += 1\n", + " sys.stdout.write(\"\\n%d files closed.\"%(c))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "45 Bytes copied from 'a.txt' to 'b.txt'.\n", + "2 files closed." + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.33, Page number: 487

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read the contents of three files and find the largest file\n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "y = 0\n", + "k = 0\n", + "t = 0\n", + "name = [\"1.txt\",\"2.txt\",\"3.txt\"]\n", + "f = [0 for i in range(0,3)]\n", + "x = [0 for i in range(0,3)]\n", + "\n", + "#Open all the files\n", + "for l in range(0,3):\n", + " fp = open(name[l],\"r\")\n", + " f[l] = fp\n", + " if fp == 0:\n", + " sys.stdout.write(\"\\n%s file not found.\"%(name[l]))\n", + " break\n", + " \n", + "#Read contents of all files\n", + "for l in range(0,3):\n", + " while True:\n", + " c1 = f[l].read(1)\n", + " if not c1:\n", + " break\n", + " x[l] = y\n", + " y += 1\n", + " y = 0\n", + "\n", + "#close the files\n", + "for l in range(0,3):\n", + " f[l].close()\n", + "\n", + "#Print size of all files\n", + "for l in range(0,2+1):\n", + " sys.stdout.write(\"File : %s Bytes : %d\\n\"%(name[l],x[l]))\n", + " t = t + x[l]\n", + " \n", + "#Find largest\n", + "for l in range(t,1,-1):\n", + " for k in range(0,3):\n", + " if l == x[k]:\n", + " sys.stdout.write(\"\\n%s are the largest file.\"%(name[k]))\n", + " break\n", + " if l == x[k]:\n", + " break" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "File : 1.txt Bytes : 16\n", + "File : 2.txt Bytes : 20\n", + "File : 3.txt Bytes : 25\n", + "\n", + "3.txt are the largest file." + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.34, Page number: 488

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Copy 100 characters from a file to an array\n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "SIZE = 100\n", + "s = 0\n", + "x = 0\n", + "ch = ['0' for i in range(0,100)]\n", + "\n", + "#Open the files\n", + "f = open(\"poem.txt\",\"r\")\n", + "f2 = open(\"alpha.txt\",\"w\")\n", + "\n", + "if f ==0 or f2 == 0:\n", + " sys.stdout.write(\"?\")\n", + "else:\n", + " while True:\n", + " c = f.read(1)\n", + " x += 1\n", + " if not c:\n", + " break\n", + " else:\n", + " if x == 99:\n", + " break\n", + " else:\n", + " ch[s] = c\n", + " s += 1\n", + "\n", + "for s in range(0,100):\n", + " f2.write(\"%c\"%(ch[s]))\n", + "\n", + "sys.stdout.write(\"Process Completed : Error 0\")\n", + "f.close()\n", + "f2.close()\n", + "\n", + "#There is no perror() function in python" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Process Completed : Error 0" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.35, Page number: 491

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Low level disk I/O operations.\n", + "\n", + "import sys\n", + "\n", + "\n", + "#Variable Initialization\n", + "file1 = raw_input(\"Enter a file name : \")\n", + "\n", + "#Open file\n", + "s = open(file1,\"w\")\n", + "\n", + "#Result\n", + "if s == -1:\n", + " sys.stdout.write(\"File does not exits\")\n", + "else:\n", + " buff = raw_input(\"Enter text below:\")\n", + " s.write(\"%s\"%(buff))\n", + " s.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a file name : TEXT\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter text below:PROGRAMMING IN C\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.36, Page number: 492

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read text from a specified file \n", + "\n", + "import sys\n", + "\n", + "#Variable initialization\n", + "file1 = raw_input(\"Enter a file name \")\n", + "\n", + "#open file\n", + "s = open(file1,\"r\")\n", + "\n", + "#Result\n", + "if s == -1:\n", + " sys.stdout.write(\"File does not exists\")\n", + "else:\n", + " while True:\n", + " ch = s.read(1)\n", + " if not ch:\n", + " break\n", + " sys.stdout.write(\"%c\"%(ch))\n", + " \n", + "s.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a file name TEXT\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "PROGRAMMING IN C" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.37, Page number: 493

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Set a buffer size \n", + "\n", + "import sys\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nThis book teaches C\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "This book teaches C" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.38, Page number: 494

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display number of arguments and their names\n", + "\n", + "import sys\n", + "\n", + "#Result\n", + "sys.stdout.write(\"\\nTotal number of arguments are %d\\n\"%(len(sys.argv)))\n", + "\n", + "print str(sys.argv)\n", + "\n", + "#Command line arguments can be given in python by the command\n", + "\n", + "# python pgmname.py arg1 arg2 arg3\n", + "\n", + "#This is not possible in ipython notebook" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 8 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.39, Page number: 495

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read any file from command prompt\n", + "\n", + "import sys\n", + "\n", + "#open file\n", + "fp = open(sys.argv[1],\"r\")\n", + "\n", + "#Result\n", + "if fp == 0:\n", + " sys.stdout.write(\"Can not open file\")\n", + "else:\n", + " while True:\n", + " ch = fp.read(1)\n", + " if not ch:\n", + " break\n", + " sys.stdout.write(\"%c\"%(ch))\n", + " \n", + "fp.close()\n", + "\n", + "#This program can be run in python as\n", + "\n", + "# python pgmname.py filename" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.40, Page number: 495

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Command line argument to perform the task of DEL command\n", + "\n", + "import sys\n", + "\n", + "#Check number of arguments\n", + "if len(sys.argv) < 2:\n", + " sys.stdout.write(\"Insufficient Arguments\")\n", + "else:\n", + " fp = open(sys.argv[1],\"r\")\n", + " if fp == 0:\n", + " sys.stdout.write(\"File Not Found\")\n", + " fp.close()\n", + " os.remove(sys.argv[1])\n", + " sys.stdout.write(\"File has been deleted\")\n", + " \n", + "#This program can be deleted using\n", + "# python pgmname.py filename\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.41, Page number: 496

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Command line argument to perform the task of REN command\n", + "\n", + "import sys\n", + "\n", + "#Check number of arguments\n", + "if len(sys.srgv) < 3:\n", + " sys.stdout.write(\"Insufficient Arguments\")\n", + "else:\n", + " fp = open(sys.argv[1],\"r\")\n", + " if fp == 0:\n", + " sys.stdout.write(\"File Not Found\")\n", + " else:\n", + " sp = open(sys.argv[2],\"r\")\n", + " if sp == 0:\n", + " fp.close()\n", + " sp.close()\n", + " #Rename file\n", + " os.rename(sys.argv[1],sys.argv[2])\n", + " else:\n", + " sys.stdout.write(\"Duplicate file name or file is in use\")\n", + " \n", + "#This program can be executed as\n", + "\n", + "# python pgmname.py oldfilename newfilename\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.42, Page number: 497

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Environment variable and display the various settings.\n", + "\n", + "import sys\n", + "import os\n", + "\n", + "#Result\n", + "print os.environ\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "{'TMP': 'C:\\\\Users\\\\Aathira\\\\AppData\\\\Local\\\\Temp', 'COMPUTERNAME': 'AATHIRA-PC', 'GUROBI_HOME': 'B:\\\\gurobi510\\\\win32', 'USERDOMAIN': 'Aathira-PC', 'PSMODULEPATH': 'C:\\\\Windows\\\\system32\\\\WindowsPowerShell\\\\v1.0\\\\Modules\\\\', 'COMMONPROGRAMFILES': 'C:\\\\Program Files (x86)\\\\Common Files', 'PROCESSOR_IDENTIFIER': 'Intel64 Family 6 Model 15 Stepping 13, GenuineIntel', 'PROGRAMFILES': 'C:\\\\Program Files (x86)', 'PROCESSOR_REVISION': '0f0d', 'SYSTEMROOT': 'C:\\\\Windows', 'PATH': 'C:\\\\Anaconda\\\\lib\\\\site-packages\\\\numpy\\\\core;B:\\\\gurobi510\\\\win32\\\\bin;C:\\\\Windows\\\\system32;C:\\\\Windows;C:\\\\Windows\\\\System32\\\\Wbem;C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\;C:\\\\Program Files (x86)\\\\Common Files\\\\Adobe\\\\AGL;C:\\\\Program Files\\\\MATLAB\\\\R2009a\\\\bin;C:\\\\Program Files\\\\MATLAB\\\\R2009a\\\\bin\\\\win64;c:\\\\python27\\\\scripts;C:\\\\Program Files (x86)\\\\MiKTeX 2.9\\\\miktex\\\\bin\\\\;C:\\\\Anaconda;C:\\\\Anaconda\\\\Scripts;C:\\\\Program Files (x86)\\\\ffmpeg', 'CLICOLOR': '1', 'PROGRAMFILES(X86)': 'C:\\\\Program Files (x86)', 'COMSPEC': 'C:\\\\Windows\\\\system32\\\\cmd.exe', 'TK_LIBRARY': 'C:\\\\Anaconda\\\\tcl\\\\tk8.5', 'TERM': 'xterm-color', 'TEMP': 'C:\\\\Users\\\\Aathira\\\\AppData\\\\Local\\\\Temp', 'COMMONPROGRAMFILES(X86)': 'C:\\\\Program Files (x86)\\\\Common Files', 'PROCESSOR_ARCHITECTURE': 'x86', 'TIX_LIBRARY': 'C:\\\\Anaconda\\\\tcl\\\\tix8.4.3', 'ALLUSERSPROFILE': 'C:\\\\ProgramData', 'LOCALAPPDATA': 'C:\\\\Users\\\\Aathira\\\\AppData\\\\Local', 'HOMEPATH': '\\\\Users\\\\Aathira', 'PROGRAMW6432': 'C:\\\\Program Files', 'USERNAME': 'Aathira', 'LOGONSERVER': '\\\\\\\\AATHIRA-PC', 'SESSIONNAME': 'Console', 'PROGRAMDATA': 'C:\\\\ProgramData', 'TCL_LIBRARY': 'C:\\\\Anaconda\\\\tcl\\\\tcl8.5', 'GIT_PAGER': 'cat', 'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC', 'FP_NO_HOST_CHECK': 'NO', 'WINDIR': 'C:\\\\Windows', 'APPDATA': 'C:\\\\Users\\\\Aathira\\\\AppData\\\\Roaming', 'HOMEDRIVE': 'C:', 'PAGER': 'cat', 'SYSTEMDRIVE': 'C:', 'NUMBER_OF_PROCESSORS': '2', 'PROCESSOR_LEVEL': '6', 'PROCESSOR_ARCHITEW6432': 'AMD64', 'COMMONPROGRAMW6432': 'C:\\\\Program Files\\\\Common Files', 'OS': 'Windows_NT', 'PUBLIC': 'C:\\\\Users\\\\Public', 'USERPROFILE': 'C:\\\\Users\\\\Aathira'}\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.43, Page number: 498

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Read character from keyboard \n", + "\n", + "import sys\n", + "\n", + "c = '0'\n", + "\n", + "#Result\n", + "while c != ' ':\n", + " c = raw_input(\"\")\n", + " sys.stdout.write(\"%c \"%(c))\n", + " \n", + "#Give space at the end" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1 2 " + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "3 4 " + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "5 6 " + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "7 8 " + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "9 " + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 14.44, Page number: 499

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display A to Z characters\n", + "\n", + "import sys\n", + "\n", + "#Result\n", + "for a in range(65,91):\n", + " sys.stdout.write(\"%c\\t\"%(chr(a)))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "A\tB\tC\tD\tE\tF\tG\tH\tI\tJ\tK\tL\tM\tN\tO\tP\tQ\tR\tS\tT\tU\tV\tW\tX\tY\tZ\t" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/Programming_in_C_using_ANSI_C/KamthaneChapter15.ipynb b/Programming_in_C_using_ANSI_C/KamthaneChapter15.ipynb new file mode 100755 index 00000000..0c5ac02f --- /dev/null +++ b/Programming_in_C_using_ANSI_C/KamthaneChapter15.ipynb @@ -0,0 +1,754 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Chapter 15: Additional in 'C'

" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 15.1, Page number: 505

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Allocate memory to pointer variable. \n", + "\n", + "import sys\n", + "\n", + "#Variable initialization\n", + "j = 0\n", + "k = int(raw_input(\"How many number : \"))\n", + "p = [0 for i in range(0,k)]\n", + "\n", + "#in python, all variables are allocated using dynamic memory allocation technique and no\n", + "#malloc function and pointer concept is available in python.\n", + "\n", + "#Read the numbers\n", + "while j != k:\n", + " p[j] = int(raw_input(\"Number %d = \"%(j+1)))\n", + " j += 1\n", + " \n", + "j = 0\n", + "\n", + "#Result\n", + "sys.stdout.write(\"The numbers are : \")\n", + "while j != k:\n", + " sys.stdout.write(\"%d\\t\"%(p[j]))\n", + " j += 1\n", + " \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many number : 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number 1 = 1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number 2 = 2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number 3 = 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number 4 = 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The numbers are : 1\t2\t3\t4\t" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 15.2, Page number: 506

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Memory allocation to pointer variable. \n", + "\n", + "import sys\n", + "\n", + "#Variable initialization\n", + "j = 0\n", + "k = int(raw_input(\"How many Number : \"))\n", + "p = [0 for i in range(0,k)]\n", + "\n", + "#in python, all variables are allocated using dynamic memory allocation technique and no\n", + "#calloc function and pointer concept is available in python.\n", + "\n", + "#Read the numbers\n", + "while j != k:\n", + " p[j] = int(raw_input(\"Number %d = \"%(j+1)))\n", + " j += 1\n", + " \n", + "j = 0\n", + "\n", + "#Result\n", + "sys.stdout.write(\"The numbers are : \")\n", + "while j != k:\n", + " sys.stdout.write(\"%d\\t\"%(p[j]))\n", + " j += 1\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many Number : 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number 1 = 45\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number 2 = 58\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number 3 = 98\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The numbers are : 45\t58\t98\t" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 15.3, Page number: 507

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Reallocate memory \n", + "\n", + "import sys\n", + "\n", + "#Variable Initialization\n", + "str1 = \"India\"\n", + "\n", + "#in python, value tagged method is used for data storage instead of memory tagging.\n", + "#no realloc function is in python\n", + "\n", + "#Result\n", + "sys.stdout.write(\"str = %s\"%(str1))\n", + "str1 = \"Hindustan\"\n", + "sys.stdout.write(\"\\nNow str = %s\"%(str1))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "str = India\n", + "Now str = Hindustan" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 15.4, Page number: 508

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display unused memory \n", + "\n", + "import psutil\n", + "\n", + "psutil.phymem_usage()\n", + "\n", + "#There is no coreleft() function in python. phymem_usage function in the module psutil gives the \n", + "#status and usage of physical memory in python." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 6, + "text": [ + "usage(total=3165270016L, used=987840512L, free=2177429504L, percent=31.2)" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 15.5, Page number: 510

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Linked list\n", + "\n", + "import sys\n", + "\n", + "#Variable Initialziation\n", + "ch = 'y'\n", + "p = 0\n", + "q = []\n", + "\n", + "#Function Definitions\n", + "def gen_rate(m):\n", + " q.append(m)\n", + " \n", + "def show():\n", + " print q\n", + " \n", + "def addatstart(m):\n", + " q.insert(0,m)\n", + " \n", + "def append(m,po):\n", + " q.insert(po,m)\n", + "\n", + "def erase(d):\n", + " q.remove(d)\n", + " \n", + "def count():\n", + " print len(q)\n", + " \n", + "def descending():\n", + " q.sort(reverse=True)\n", + " \n", + "#Get choice\n", + "while ch == 'y':\n", + " n = int(raw_input(\"1. Generate\\n2. Add at starting\\n3. Append\\n4. Delete\\n5. Show\\n6.Count\\n7.Descending\\nEnter your choice: \"));\n", + " #There is no switch statement in python\n", + " if n == 1:\n", + " i = int(raw_input(\"How many node you want : \"))\n", + " for j in range(0,i):\n", + " m = int(raw_input(\"Enter the element : \"))\n", + " gen_rate(m)\n", + " show()\n", + " else:\n", + " if n == 2:\n", + " m = int(raw_input(\"Enter the element : \"))\n", + " addatstart(m)\n", + " show()\n", + " else:\n", + " if n == 3:\n", + " m = int(raw_input(\"Enter the element and position \"))\n", + " po = int(raw_input(\"Enter the element and position\"))\n", + " append(m,po)\n", + " show()\n", + " else:\n", + " if n == 4:\n", + " d = int(raw_input(\"Enter the number for deletion : \"))\n", + " erase(d)\n", + " show()\n", + " else:\n", + " if n == 5:\n", + " show()\n", + " else:\n", + " if n == 6:\n", + " count()\n", + " else:\n", + " if n == 7:\n", + " descending()\n", + " show()\n", + " else:\n", + " sys.stdout.write(\"Enter value between 1 to 7\")\n", + " \n", + " ch = raw_input(\"Do u wnat to continue (y/n)\")\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1. Generate\n", + "2. Add at starting\n", + "3. Append\n", + "4. Delete\n", + "5. Show\n", + "6.Count\n", + "7.Descending\n", + "Enter your choice: 1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many node you want : 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the element : 1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the element : 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the element : 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the element : 7\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "[1, 5, 4, 7]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Do u wnat to continue (y/n)n\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 15.6, Page number: 518

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Draw circle, line and arc using graphics function\n", + "\n", + "%pylab inline\n", + "import pylab\n", + "import matplotlib.pyplot as plt\n", + "\n", + "#Tkinter package is used for graphics\n", + "#Give proportionate sizes to draw\n", + "#draw circle\n", + "circle2=plt.Circle((.5,.5),.2,color='b')\n", + "fig = plt.gcf()\n", + "fig.gca().add_artist(circle2)\n", + "\n", + "\n", + "#draw line\n", + "figure()\n", + "pylab.plot([210,110],[150,150])\n", + "\n", + "#Draw ellipse\n", + "figure()\n", + "from matplotlib.patches import Ellipse\n", + "e = Ellipse(xy=(35, -50), width=10, height=5, linewidth=2.0, color='g')\n", + "fig = plt.gcf()\n", + "fig.gca().add_artist(e)\n", + "e.set_clip_box(ax.bbox)\n", + "e.set_alpha(0.7)\n", + "pylab.xlim([20, 50])\n", + "pylab.ylim([-65, -35])" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Populating the interactive namespace from numpy and matplotlib\n" + ] + }, + { + "output_type": "stream", + "stream": "stderr", + "text": [ + "WARNING: pylab import has clobbered these variables: ['pylab', 'e']\n", + "`%pylab --no-import-all` prevents importing * from pylab and numpy\n" + ] + }, + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 61, + "text": [ + "(-65, -35)" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEACAYAAABI5zaHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGXlJREFUeJzt3X9w1HV+x/HXQjaQREB+2BzsZg5IIgmNBNogclS76Hlg\nnEtbYe5Cb+4UmZhj6ng6bc+rthp0RsE/buqZaxumqFUhhyPOxRlhvUJZ7QhcPFHwgKEBQTfxpAbB\nYICQbL7941MDMbDZJLv73f3s8zGzE5b95LtvPiSvfPL5fr6fr8dxHEcAAKuMcrsAAED8Ee4AYCHC\nHQAsRLgDgIUIdwCwEOEOABYaNNzvvvtu5efn67rrrrtim/vuu0/FxcUqLy/Xe++9F9cCAQBDN2i4\nr1y5UsFg8Iqvb926VUeOHFFLS4vWr1+v1atXx7VAAMDQDRruN954oyZOnHjF11977TXdeeedkqQF\nCxbo9OnTOnHiRPwqBAAM2Yjn3Nva2lRQUND33O/3q7W1daSHBQCMQFxOqH59BwOPxxOPwwIAhilr\npAfw+XwKh8N9z1tbW+Xz+Qa0Kyoq0tGjR0f6dgCQUQoLC3XkyJEhf96IR+5VVVV64YUXJEl79uzR\n1Vdfrfz8/AHtjh49KsdxeDiOHn30UddrSJUHfUFf0BfRH8MdFA86cl+xYoXefPNNtbe3q6CgQGvW\nrFF3d7ckqba2VpWVldq6dauKioqUl5en5557bliFAADiZ9Bwb2xsHPQg9fX1cSkGABAfXKHqgkAg\n4HYJKYO+uIi+uIi+GDmP4zhJuVmHx+NRkt4KAKwx3Oxk5A4AFiLcAcBChDsAWIhwBwALEe4AYCHC\nHQAsRLgDgIUIdwCwEOEOABYi3AHAQoQ7AFiIcAcACxHuAGAhwh0ALES4A4CFCHcAsBDhDgAWItwB\nwEKEOwBYiHAHAAsR7gBgIcIdACxEuAOAhQh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iqTWmgqGlZtxOyPgOE53d7czc+ZM59ixY05XV9egJ1R3795t\n7UnEWPrio48+cgoLC53du3e7VGVyxNIXl7rrrrucLVu2JLHC5IilHw4dOuTccsstTk9Pj9PZ2emU\nlZU5Bw4ccKnixImlLx544AGnrq7OcRzH+fTTTx2fz+ecPHnSjXKT4tixYzGdUI01N+M6cueip4ti\n6YvHHntMp06d6ptn9nq9am5udrPshIilLzJBLP1QUlKipUuXas6cORo1apRqamo0e/ZslyuPv1j6\n4qGHHtLKlStVXl6u3t5ePfXUU5o0aZLLlSfGihUr9Oabb6q9vV0FBQVas2aNuru7JQ0/N7mICQAs\nxG32AMBChDsAWIhwBwALEe4AYCHCHQAsRLgDgIUIdwCwEOEOABb6P0Anxcrjn3WCAAAAAElFTkSu\nQmCC\n", + "text": [ + "" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEACAYAAABS29YJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAF0tJREFUeJzt3XtsU+f9x/GPM8JWljCCBiaKU2JugzR28AK0MKXzr8CA\nomzrZdVcAVUcpIr+tZoxtj+gttZCCIuqNtO2TKIwiXX8g4BpgghP4ACquCdKRqVBWaIkkKVLQ6YR\nKNfn90dVizQ3nDi0yfN+SZYOz3l8zvfblk9OnuNTO4wxRgCAUS3lyy4AADD8CHsAsABhDwAWIOwB\nwAKEPQBYgLAHAAv0G/bBYFBOp1Mejyc+Fg6H5XK55PP55PP5dOjQIUnSp59+qkAgIK/Xq9zcXJWW\nlg5v5QCAh9Zv2BcXF6uqqqrbmMPhUCgUUk1NjWpqarRixQpJ0p49eyRJdXV1OnfunCorK9XU1DRM\nZQMAEtFv2BcWFiojI6PHeG/PYWVmZqqrq0v37t1TV1eXxo4dq/HjxyevUgDAoA1qzb6iokL5+fkq\nKSlRZ2enJGnZsmUaP368MjMzlZOTow0bNmjChAlJLRYAMDgJh/26devU0NCg2tp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Xq1aTlyyP5\nH6G1tbXJ6XRKkpxOZ/zTPFevXpXL5YrPc7lcunLlyqMoadi89957evbZZyWNnv76eohuNPR36dIl\nHTt2TE899ZT8fr/Onj0raXT0JkmlpaVav369Hn/8cW3YsEFbt26VNPL7a2xsVE1NjZ588slRmS8P\n9vegoeTLI/+/XjocDjkcjn73j1RvvfWWxo4dq5dffrnPOSOtv88footEIvEx0889/ZHW3927d3Xt\n2jWdPHlS27dv10svvdTn3JHWmySVlJTo3XffVVNTk95++20Fg8E+546U/q5fv64XXnhB77zzjtLT\n07vtGw35cv36db344ot65513lJaWFh8far48krB3Op3697//LUlqbW3V5MmTJUlZWVlqbm6Oz2tp\naYn/mjnS7Nq1SwcPHtSf//zn+Nho6O/y5ctqbGxUfn6+3G63WlpaVFBQoLa2tlHRn8vl0vPPPy9J\nmj9/vlJSUtTe3j4qepM+u0H73HPPSZJefPHF+K/5I7W/O3fu6IUXXtDq1av14x//WNLoypfP+1u1\nalW8PylJ+TIcNxoefOLWmM9u0JaWlhpjjNm6dWuPGwy3bt0y//rXv8y0adPM/fv3h6OkpPpif4cO\nHTK5ubnmP//5T7d5o6W/B/V2g3Yk9ffF3v7whz+YzZs3G2OM+ec//2mys7ONMSOzN2N69ufz+Uws\nFjPGGPP3v//dzJs3zxgzMvu7f/++Wb16tfnZz37WbXy05Etf/SUrX5Ie9j/96U9NZmamSU1NNS6X\ny7z33nvmk08+MYsXLzYzZ840S5cuNdeuXYvPf+utt8z06dPNd77znfinBr7Kvtjfjh07zIwZM8zj\njz9u5s6da+bOnWvWrVsXnz9S+xs7dmz839+D3G53POyNGVn99dbb7du3zapVq0xeXp757ne/a44e\nPRqfP5J6M6b3v3tnzpwxCxYsMPn5+eapp54y58+fj88faf0dP37cOBwOk5+fH/+7dujQoVGTL731\nd/DgwaTlCw9VAYAF+FpCALAAYQ8AFiDsAcAChD0AWICwBwALEPYAYAHCHgAsQNgDgAX+Hze/zGOH\nVK27AAAAAElFTkSuQmCC\n", + "text": [ + "" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEACAYAAAC9Gb03AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAG+xJREFUeJzt3X1QU2e+B/DvyQtJgCDvCskqCLSIIqR2lbvjbGOVTmd2\naFnb8Y6dup1R94/6z3Zpbx1nR4t3inbtujtdp7rM1umt/af27lwLu1s7Mlsz1O5aFHGtUgUEWt5i\nhcBKgBCSPPcPylkp6EgSCTx+P8MZT56QnN/jo9/zkpNzFCGEABERSUsT6QKIiOj+YtATEUmOQU9E\nJDkGPRGR5Bj0RESSY9ATEUku6KDfvXs3CgoKUFhYiPXr16OjowMA0N7eDpPJBJvNBpvNhh07doSt\nWCIimjkl2PPoBwcHYTabAQCHDh3CP//5T7zzzjtob29HSUkJvvzyy7AWSkREwQl6i34i5AHA7XYj\nOTk5LAUREVF46UJ58a9+9Su8//77iI6OxtmzZ9X2trY22Gw2LFiwAK+//jrWrl0bcqFERBScux66\nKS4uhtPpnNK+b98+lJSUqI/feOMNXLt2De+++y68Xi+GhoaQkJCACxcuoLS0FFeuXJm0B0BERLNI\nhMHXX38tli9fPu1zdrtd1NfXT2nPysoSADhx4sSJ0wymrKysGWd00Mfom5ub1fmqqirYbDYAQG9v\nL/x+PwCgtbUVzc3NWLp06ZTXX79+HUIIaafXXnst4jWwf+zfg9g/mfsmhMD169dnnNdBH6PftWsX\nrl27Bq1Wi6ysLBw5cgQAUFtbiz179kCv10Oj0aCyshLx8fHBLoaIiEIUdND/6U9/mrZ948aN2Lhx\nY9AFERFRePGbsfeJ3W6PdAn3Ffs3v8ncP5n7FqygvzAV8oIVBRFaNBHRvBVMdnKLnohIcgx6IiLJ\nMeiJiCTHoCcikhyDnohIcgx6IiLJMeiJiCTHoCcikhyDnohIcgx6IiLJMeiJiCTHoCcikhyDnohI\ncgx6IiLJMeiJiCTHoCcikhyDnohIcgx6IiLJMeiJiCT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LZxOZ6RLnbFLly4Jm80mCgoKRH5+vjhw4IAQQkgzdnfqnwxj930O\nh0OUlJQIIeQZv9udPn1a7d/zzz8vxfi1traKgoICUVBQIJYvXy727dsnhJj5+PELU0REkuOtBImI\nJMegJyKSHIOeiEhyDHoiIskx6ImIJMegJyKSHIOeiEhyDHoiIsn9P/ox1+CwlWHmAAAAAElFTkSu\nQmCC\n", + "text": [ + "" + ] + } + ], + "prompt_number": 61 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 15.7, Page number: 519

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Draw boxes and fill with different designs.\n", + "\n", + "%pylab\n", + "#Tkinter package is used for graphics\n", + "from matplotlib.patches import Rectangle\n", + "from matplotlib.collections import PatchCollection\n", + "\n", + "e = Rectangle(xy=(35, -50), width=10, height=5, linewidth=2.0, color='b')\n", + "fig = plt.gcf()\n", + "fig.gca().add_artist(e)\n", + "e.set_clip_box(ax.bbox)\n", + "e.set_alpha(0.7)\n", + "pylab.xlim([20, 50])\n", + "pylab.ylim([-65, -35])\n", + "\n", + "#There are no different automatic fill styles. user should create the styles." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAEACAYAAAC9Gb03AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAErZJREFUeJzt3X9MVff9x/HXuXKbaEoEV3UtN6kILooinNYpf5jsOLlL\nk4WW0YXEpq6J9p/6V0uXOrOIkBRxbizpyDRka5raf+qyxMKW2kBWb2i3uFsQ6w+SggW6C3LNmDZR\nt4Xpzv5ovN8yfqT33At8fe/5SE5y77ncez6ffPTZc4/3Usf3fV8AALNCiz0AAMD8IvQAYByhBwDj\nCD0AGEfoAcA4Qg8AxgUO/cGDB1VWVqby8nLt3LlTiURCkjQyMqKlS5fKdV25rqt9+/ZlbbAAgPQ5\nQT9Hf/PmTeX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hyHGchh5N1t27d0ve//3299tprevDBB/XC\nCy9oeHhY58+f18MPP6yXX355sYcYSCgU0vnz5zU6Oqru7m6dOXNmyuP3+9r99/xisZiZtfv973+v\nVatWyXXdWc9w7+f1m21+VtZPkv74xz+qr69Pp0+f1i9/+Ut98MEHUx7/Kuu3YKH/17/+paefflq7\nd+9WdXW1pC/+S3Tvm7fj4+NatWrVQg0n6+7N79lnn03Nb9WqValFeP755xWPxxd5lJlZvny5vvvd\n76q3t9fU2t1zb349PT1m1u5Pf/qTOjo6VFhYqF27dun999/X7t27zazfTPP7wQ9+YGb9JOnhhx+W\n9MXvE/ve976neDye9votSOh939fevXtVUlKiF198MbX/ySef1JtvvilJevPNN1OBvN/MNr/x8fHU\n7VOnTqm0tHQxhpeRiYmJ1Nvef/zjH+rq6pLrumbWbrb5fflXf9yvaydJhw8fViKR0PDwsN5++219\n+9vf1ltvvWVm/Waa34kTJ0z83ZO++KDAzZs3JUm3b99WZ2enSktL01+/tL9LG8AHH3zgO47jl5WV\n+eXl5X55ebl/+vRp/29/+5u/c+dOf926dX40GvVv3LixEMPJupnm9+677/q7d+/2S0tL/c2bN/tP\nPfWUn0wmF3uoabtw4YLvuq5fVlbml5aW+kePHvV93zezdrPNz8La/bdYLOZXVVX5vm9n/b7szJkz\nqfk9++yzJtZvaGjILysr88vKyvyNGzf6hw8f9n0//fXjC1MAYBz/K0EAMI7QA4BxhB4AjCP0AGAc\noQcA4wg9ABhH6AHAOEIPAMb9B4rEH5DkLOd4AAAAAElFTkSuQmCC\n", + "text": [ + "" + ] + } + ], + "prompt_number": 72 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 15.8, Page number: 520

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display text in different size, font, vertically and horizontally \n", + "\n", + "%pylab\n", + "\n", + "from pylab import *\n", + "\n", + "#Tkinter package is used for graphics\n", + "# set limits so that it no longer looks on screen to be 45 degrees\n", + "xlim([-5,5])\n", + "\n", + "# Locations to plot text\n", + "l1 = array((1,1))\n", + "l2 = array((5,5))\n", + "\n", + "# Rotate angle\n", + "angle = 90\n", + "trans_angle = gca().transData.transform_angles(array((45,)),\n", + " l2.reshape((1,2)))[0]\n", + "\n", + "# Plot text\n", + "th2 = text(l2[0],l2[1],'Hello(Horizontal Text with fontsize 25)\\n\\n',fontsize=25,\n", + " rotation=0)\n", + "th2 = text(l2[0],l2[1],'Hello(Horizontal Text with fontsize 16)',fontsize=16,\n", + " rotation=0)\n", + "th1 = text(l1[0],l1[1],'Hello(Vertical Text)',fontsize=16,\n", + " rotation=angle)\n", + "show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Using matplotlib backend: module://IPython.kernel.zmq.pylab.backend_inline\n", + "Populating the interactive namespace from numpy and matplotlib\n" + ] + }, + { + "output_type": "stream", + "stream": "stderr", + "text": [ + "WARNING: pylab import has clobbered these variables: ['power', 'draw_if_interactive', 'random', 'fft', 'angle', 'linalg', 'info']\n", + "`%pylab --no-import-all` prevents importing * from pylab and numpy\n" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAA5AAAATCCAYAAADLrQlWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XeUFFXC/vGnezIwMMOQBASGLIIoAgKSg+ASX0AQV5II\nKuqCArqGV4FFF8EAiLrKLkFAMawSDSgZBFxAlrQknSGpIBJkkORwf3/w63q7Ot6BIa3fzzl9znTV\nrVu3blWHZ6r6lscYYwQAAAAAQBTey90AAAAAAMDVgQAJAAAAALBCgAQAAAAAWCFAAgAAAACsECAB\nAAAAAFYIkAAAAAAAKwRIAMAF83q9rseUKVNc8ydPnhxU5mLbsmWLYmNjnfUNHTr0oq/zcunVq5er\nb5s0aXK5m/RfY/HixUHH7u7duy93sxDGxdhfl/r1lZ2drTfeeEMNGzZUWlqaYmJiLul755WM12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NHnyZN1///0R63vxxRfDntmUpCJFioScnpycrDZt2ujDDz+UdO7y\n2kWLFkX8re/v+5e4AADHzp07NWTIENWqVUtpaWmKi4tT4cKFVb9+fT333HM6fPjwJWnH4cOHNXr0\naDVv3lzFihVTQkKCkpOTVbFiRfXo0UPz58+PuPzf//531/OuXbtezOaGtWTJEvXp00fXXXedChQo\noPj4eBUtWlSNGzfWc889p4MHD4ZdNtSgRL/88oueeuopValSRXny5HENHhFtkI/A+dEeS5YsCWqT\nMUZz5szRXXfdpfLlyys5OVkJCQkqXry4WrZsqbFjx+rYsWMhtyczMzPkOo4ePaqnn35aVapUUVJS\nklJSUtS8eXN9/vnnYfsk8PeEw4YNCztAU3Z2tqZPn65BgwapWbNmqlSpkgoXLqy4uDglJyerXLly\n6tixo6ZOner6wpabSpQooVKlSrkepUuXDjqbFBsbG1SuVKlSKl68uKTg4ykhIUElSpRQmzZtNGnS\nJP32229B6/773//u6pfY2NigM1ynT59W9erVXeWaNm0qY4zKlCkjr9cb9LvrKVOmnPdAJoH7q1mz\nZkFlSpUq5czPkydP0L7p3r27q45+/fo58yINsuIbzKtp06au+owxSk9Pdy0T7QyMdO6fAx07dlTR\nokWVkJCg8uXLa/DgwTp69KhVX/jzvUb9rySQzv1eM1q7vvnmGz344IOqXr26UlNTnffuOnXq6Mkn\nn4y4b3z72PcYNmyYzp49qzfffFP16tVTgQIFlDdvXtWoUUOvvvpqUDBs3LixvF6v6/JV6dzxGul9\n5ddff9W4cePUokULlShRQomJiUpMTFTJkiV18803q3fv3nr99de1Y8cOV73RBtEJNT/SI9x+vpif\nh/ny5dOzzz6rffv26fXXX1fbtm1VuXJl1alTRyNHjtQLL7wQtMzixYuj1puWlhbyPcT3iHQG8847\n73Q9nzBhQuSVGQDAVaNRo0bG4/E4D6/XG7ZsZmamq6zH4zG9e/cOKpednW2eeuop4/V6g8r7P1JT\nU828efNCriuw7JQpU1zzJ02aZNXuf/7znyYlJSViOzwej2nevLk5cOBAyDpuuOEGV9k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vXv3\nzvXL/Dp27Oi6XE06N2DISy+9pPXr12vBggVq3bq16xI3SUFnTNLS0lSlShXn+YkTJyLfyyqXBbYn\nIyNDzZo10/z587Vhwwa99tprQQMBpaam6q677rqo7Xr44YeDvnwPGjRIt9xyizIzM4MevkEi4uPj\ndc8997iWW758uTp16qTFixfrm2++0XPPPaf//d//dZUpX768brvttouyLYGXVX388cdavny5MjIy\nlJmZ6VyGFeryq2effVarV6/Wli1bNHXqVDVp0uSKvRxbkvr37+96/vHHH6tVq1aaNWuWNm3apP/8\n5z9avHixxo4dq9atW6tkyZIaM2ZMUD2jRo3SggULnOcFCxbUihUr1KFDB2faiRMn1K1bt6ABQqTg\nvlywYIG++OILfffdd8rMzNT+/ftzvG1Vq1Z11XvgwAHn91/+Z1n9//a/JD0+Pt7qbGwogcHcGKMx\nY8Zoy5YtQa+BK1Xge82xY8fUoEEDzZ49W5s2bdLbb78ddNYuLi5O/fr1uyjtCTxG1q9fr48++kg7\nd+5UZmam9u7d68x7+OGHdf311+uxxx7TP//5T61bt047d+7Uxo0b9dprr+nLL7901ZWTgXSWLVum\nLl26uH5LWKVKFY0cOVK7d+8Oeq/zv2zzUn0e7tu3T7feeqtr0B6v16uXXnpJ7du3D/meHPgPMd/v\n8itWrKj27dtr0qRJ+uabb7R582Z9+OGHqlu3btC9e4sVKxYUzn3279+v3bt3O88LFiwYNABTYAMA\nAFeJwOH0A2+H4S/UrRNCDb8f6j5/kR5er9dkZ2e76ggsk9PbeBhjzKxZs0xMTIx1O2rUqBFymPwh\nQ4a4yo0ZMyZsHwXWGWno+cBtCLWdp06dMrfeemuO+vKdd96J2q7A9QSKNoR+Tvavx+MxixcvdpY9\ndOiQqVixovWyCQkJZsmSJa71hzoWA8sYY3e7iMGDB0dcf69evZyygfebC3zExsYG3SojcJ2X8z6Q\nv/76a9C966I9GjRo4Krj66+/Drplx3vvvWeMMeann34yxYoVc817+OGHg9oxfvz4iOts3LjxefVB\n165dQ9bna58xxixdujRkmfr164es02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w89FFRn\nr169jDHGtGjRImhexYoVnb8bN24cdb3RhNsv7777btht9t9PZ86ccUYAzpcvn9m5c6fZt2+fMwhP\nlSpVzIkTJ5x6fQPs+D8mT54ctZ2lSpVyypcoUcKZXr58eWd64cKFXcuEO9bXrFkTcpt8fM+bNGni\nqs83vUyZMlHbG2l/+AabCfVIT083+/fvd8r69k/gOv33m79I/Rtuf3q9XjN27FhjTOhBdBYvXhzx\ndeI7Xvfv3+8MphRuPdGEGp3Y/xHYD507dw5ZLiYmxkydOtVVdsuWLc78SZMmRW0L8HvHGUgAuEp4\nLC6v8wT8Fi4pKUlLly7ViBEjVL16deXNm1d58uRRuXLl1LFjR02cOFHXXHNNxPpDTS9atKjWrFmj\ngQMHqly5cs59IOvWratJkybp9ddfd9Vx7733Sjo3QEXgYBm+NofarnBtaty4sb7++mt17drVuQ9k\nWlqa2rRpo8WLF6tbt27W/RZpvn/bAh+SdNddd2nx4sVq06aNChUq5NyPsWvXrvr6669d97zMSf9K\n537neuedd6pIkSJB6502bZq6du2qggULKiUlRd27d9d7773narPt9ocTbr/ceeedWr58uTp16qRi\nxYopLi5ORYoUUa1atfTnP/9ZgwYNctr/9ddfy+PxaNSoUSpXrpyKFy+u1157TZK0detWPfroo069\nU6dOVcOGDVWgQIGoAyn5812a6vF4XL+78x+cqHHjxkHbFqpPbr75Zo0bN07lypVTfHx8yDZEOo5s\n2htpf/ztb3/TpEmTVLduXSUnJys+Pl7lypXTwIEDtWbNGtclrOH6KNz0SP37xBNPqEGDBs59PfPm\nzev0xZ/+9Kew22/+/xnaaK+TIkWKaM2aNXrsscdUuXJlJSYmKjk5WZUqVdIf//hHzZgxI0f9Fmld\nPu+++65eeOEFXXfddUpISFCBAgV022236YsvvtDdd9/tKutbf4ECBdS1a9eobQF+7zzG8GthAMDF\nd+utt2rlypXq1q2bpk+ffrmbAwA6c+aMypcvrz179ujJJ5+M+ptPAARIAMAlsmrVKtWrV0+xsbHa\nunWr9W8DAeBimThxou69914VLVpUO3fudEaxBRAeARIAAAAAYIXfQAIAAAAArBAgAQAAAABWCJAA\nAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAA\nAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAA\nrBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFgh\nQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAE\nAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAA\nAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAA\nYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAK\nARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIk\nAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAA\nAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAA\nACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABW\nCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAg\nAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIA\nAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAA\nAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACw\nQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUA\nCQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIA\nAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAA\nAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACA\nFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsE\nSAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAA\nAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAA\nAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAA\nrBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFgh\nQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAE\nAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAA\nAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAA\nYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAK\nARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIk\nAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAA\nAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAA\nACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABW\nCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAg\nAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIA\nAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAA\nAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACw\nQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUA\nCQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIA\nAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAA\nAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACA\nFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsE\nSAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAA\nAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAArBAgAQAA\nAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFghQAIAAAAA\nrBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAEAAAAAFgh\nQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAAAACwQoAE\nAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAAYIUACQAA\nAACwQoAEAAAAAFghQAIAAAAArBAgAQAAAABWCJAAAAAAACsESAAAAACAFQIkAAAAAMAKARIAAAAA\nYIUACQAAAACwQoAEAAAA8P/Yu/cgver6juOfZ3O/SLgnyiUkUiiNXGJoKwq4toNVLgrDRa3EWJCa\ncBEGREp1KNG0A5V2qI46VQyYUrENxtRQEcaWQImkViUhVq3BxAQZIGQwlEsW4ubpHzQLayD5xjH7\nHNjX658s5znJftmZ/c2+93fOeaBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIB\nCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACg\nREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEA\nACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhI\nACrWxdwAACAASURBVAAASgQkAAAAJQISAACAEgEJAABAiYAEAACgREACAABQIiABAAAoEZAAAACU\nCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAA\nACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJ\nAABAiYAEAACgREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBE\nQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAA\nKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACgREACAABQIiABAAAoEZAAAACUCEgA\nAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUC\nEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABA\niYAEAACgREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIA\nAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQ\nAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACgREACAABQIiABAAAoEZAAAACUCEgAAABK\nBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAA\ngBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAE\nAACgREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAi\nIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAA\nlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACgREACAABQIiABAAAoEZAAAACUCEgAAABKBCQA\nAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIB\nCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACg\nREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEA\nACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhI\nAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACgREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAl\nAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAA\nQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACgREAC\nAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgR\nkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAA\nSgQkAAAAJQISAACAEgEJAABAiYAEAACgREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIA\nAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImA\nBAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACgREACAABQ\nIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAA\nAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQk\nAAAAJQISAACAEgEJAABAiYAEAACgREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIAS\nAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAA\noERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACgREACAABQIiAB\nAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQI\nSAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAA\nJQISAACAEgEJAABAiYAEAACgREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkA\nAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERA\nAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACgREACAABQIiABAAAo\nEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAA\nAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQIS\nAACAEgEJAABAiYAEAACgREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJ\ngAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAA\nUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACgREACAABQIiABAAAoEZAA\nAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoE\nJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACA\nEgEJAABAiYAEAACgREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQA\nAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAAACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIg\nAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJAABAiYAEAACgREACAABQIiABAAAoEZAAAACU\nCEgAAABKBCQAAAAlAhIAAIASAQkAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJQISAAAAEoEJAAA\nACUCEgAAgBIBCQAAQImABAAAoERAAgAAUCIgAQAAKBGQAAAAlAhIAAAASgQkAAAAJQISAACAEgEJ\nAABAiYAEAACgREACAABQIiABAAAoEZAAAACUCEgAAABKBCQAAAAlAhIAAICSoZ0eAHhpTz/9dO69\n99488sgjabfbmTBhQqZOnZrRo0d3ejQAAAYhAQkNs2nTpixYsCBf+MIXcvfdd2fTpk1pt9tJklar\nlaFDh+aoo47KOeeckzPOOCPDhg3r8MQAAAwWrfaWn0yBjps/f34uv/zyrFq1qnT+pEmTctVVV+X0\n00/fyZMBAICAhEbp6nr+tuTf+73fyzHHHJPDDz88e+yxR5Jk/fr1Wb58ef7jP/4j//Vf/5XkuV3J\n3t7ejswLAMDgIiChQcaNG5fzzz8/H/jABzJp0qRtnrtq1apcd911+exnP5sNGzYM0IQAAAxmAhIa\nZMOGDdl11113+t8BAIBfh4CEhlqzZk1arVb233//To8CAABJCu8D+aEPfSjjx49PV1dXTjrppJc8\nb+HChTnwwAMzatSovOUtb8nPfvaz3+ScMOhMmjTpJS9jnTRpUiZPnjzAEwEAMNhtNyBbrVbe8573\n9H38Yh5++OG8+93vzq677pprrrkm3/ve9zJjxozf7KRAkqTdbmfNmjVZs2ZNp0cBAGCQ2e77QP7d\n3/1d1qxZk0996lMvec5NN92UZ599NpdffnlOPfXU/Od//mduvPHGrFq1yi4J7IDHH388jz/+eF54\nZfnatWvTbrf7foGzbNmyJMmQIUM6MiMAAIPXdgMySbZ3m+Tq1auTJPvss0+SZN999+07LiCh7tpr\nr83s2bP7YrHdbm91GeuW78fXvOY1Az4fAACDWykgd9S2gvOII47I8uXLd8anhVeMF34PvdT305aH\n7DA4HH744X27zwAAnfJrB2RPT0+GDBmSYcOG9e0yPvDAA3nDG96QBx98MEledPdx+fLl293RHAhX\nXnllrrzyyk6P0Qi+Fs/r9Ndi4cKFWbhwYZJk3rx5SZIZM2b0fc+0Wq3sueeeecMb3pBTTz11p87S\n6a9FkzTha+GXBQBAE2w3IP/1X/81P/jBD5I8dy/WF7/4xRx77LE5+OCDM2XKlKxYsSLvfve782d/\n9me5+uqr8/DDD+drX/tajjnmmO2+ETrQ38knn5yTTz45yfMBef3113dyJAAA6LPdp7Bec801ufzy\ny9NqtXLfffflT//0T/Ptb387yfO/EZ8wYUJuuummbNiwIZdeemmmTZuWG264YacODq90GzZsyObN\nm1/y9VWrVg3gNAAAUAjIO+64I5s3b05vb2/fnzNmzMjmzZtz33339Z13yimn5P77709PT08WL17c\n+N3H7u7uTo/QGL4Wz2vS1+KII47I0qVLX/S1L33pS5k6depO/fxN+lp0mq8FAMBzWu0BviGx1Wo1\n4h5IaLqurq4MHTo0f/EXf5GPfvSjSZ57m4+ZM2fmn/7pn9JqtdLb29vhKRko1k4AoAkEJDTU+PHj\n8+ijjyZJjj322HzoQx/KxRdfnLVr1yZJDj30UE80HkSsnQBAEwhIaKhHH300s2bNyoIFC/od7+rq\nyiWXXJJPfOITGT58eIemY6BZOwGAJhCQ0HDveMc7csstt/T990c/+tF84hOf6OBEdIK1EwBogu0+\nRAfojLVr1+a4447rF49J8ld/9Vf54Ac/mKeffrpDkwEAMFjZgYSGGjduXJ544okkyYknnpiLL744\n559/fn74wx8mSSZPnpz777+/kyMygKydAEAT2IGEhnriiScycuTIfPrTn87Xv/71dHd357vf/W5m\nzZqVJFm9enWHJwQAYLCxAwkNdeihh+YrX/lKpkyZstVrixYtytlnn51169Z1YDI6wdoJADSBgISG\neuaZZzJixIiXfP2hhx7Kq1/96gGciE6ydgIATTC00wMAL25LPN577725/fbb89hjj+Xqq6/OmjVr\n0mq1xCMAAAPODiQ02AUXXJDPfOYzSZ773unt7c3RRx+de+65J3Pnzs2MGTM6PCEDxdoJADSBh+hA\nQ11//fV98fhCs2bNSrvdzqJFizowFQAAg5mAhIb63Oc+lyQ544wz+h1/85vfnCRZvnz5gM8EAMDg\n5hJWaKgxY8akp6cn69aty1577dV3CeumTZsyYsSIjB49Ok8++WSnx2SAWDsBgCawAwkNtSUWRo4c\n2e/4mjVrkjwXFAAAMJAEJDTUa1/72rTb7cybN6/v2EMPPZQLLrggSXLggQd2ajQAAAYpAQkN9a53\nvStJct555yV5bkdy3333zW233ZYkOf300zs2GwAAg5N7IKFBZs+enVarlSuuuCI9PT3p7u7Od77z\nna3OO/LII3PXXXdtdXkrr1zWTgCgCQQkNEhXV1ffw3KS5Omnn86nPvWpLFq0KOvWrcv48eNz4okn\n5sILL8yoUaM6PC0DydoJADSBgIQG+dWAhC2snQBAE7gHEgAAgJKhnR4A6K/dbuess84qnTt37tyd\nPA0AADzPJazQIF1d9YsCXOo6uFg7AYAmcAkrvEyJCQAABppLWKFhWq1W5s6du91AbLVaAzQRAAA8\nxyWs0CCewspLsXYCAE3gElYAAABKBCQ0jF0mAACayj2Q0CD//u//7t5GAAAayz2QAC8D1k4AoAlc\nwgoAAECJgAQAAKBEQAIAAFAiIAEAACgRkAAAAJRs9208lixZklmzZuUnP/lJpkyZkuuuuy5Tp07t\nd0673c7FF1+cr3zlK9mwYUMOOOCAzJ49O2ecccZOGxxeif7kT/5kh97GY+7cuTtxGgAA6G+bb+PR\n09OTAw44IGPGjMmll16aOXPmZMSIEVm5cmW6up7fvLz11ltzwgknZNq0aXn/+9+fyy+/PL/85S/z\nxBNPZMiQIf0/oUfRw0t64ffV9rRarfT29u7EaWgSaycA0ATb/Gn11ltvzbp163Luuedm5syZOfvs\ns7N69eosXry433m77rprkuS1r31t/vAP/zC77LJLdtlllx36YRjYMWICAICBts1LWFevXp0k2Wef\nffr9ueX4FkcddVSuuOKKfPzjH88///M/Z+TIkbnlllt26FI8IFm1alWnRwAAgJe03XsgX+ildjy+\n853v5C//8i/zR3/0R5k5c2YuuuiizJgxI//zP/+T0aNHb3X+lVde2fdxd3d3uru7d2hoeKU64IA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k2W+//To5HgAAg5CAhIY64YQTkiQLFizIhAkTcuihh2bChAm5+eabkyTH\nH398J8cDAGAQcg8kNNTDDz+cI444ou+S1RcaP358li1blvHjx3dgMjrB2gkANIEdSGioCRMm5O67\n787b3va2DBkyJEkydOjQvP3tb8/dd98tHgEAGHB2IOFlYOPGjXnsscey++67Z9SoUZ0ehw6wdgIA\nTSAgAV4GrJ0AQBMM7fQAwPMmTZqUVquVVatW9X38Ytrtdt95AAAwUOxAQoN0dXWl1Wqlt7c3XV3b\nvkV5y3kMDtZOAKAJ7EBCg+y///59u47777//Ns99qd1JAADYWexAArwMWDsBgCbwNh7QUF/60pcy\nb968F31t7dq1Wbt27QBPBADAYGcHEhrqhfdD7shrvDJZOwGAJrADCS8zohEAgE7xEB1okOXLl2f5\n8uV9O03tdnury1hXrFiRJBkxYsSAzwcAwOAmIKFBFi5cmNmzZ/c79v73v/9Fz508efIATAQAAM9z\nCSs0SPUet+HDh+eKK67YydMAAEB/HqIDDbJs2bIsW7YsSXLWWWclSa6//vq+75lWq5U999wzU6dO\nzWte85qOzcnAs3YCAE0gIKGhuru702q1cscdd3R6FBrA2gkANIFLWKGBNm7cmLVr12bNmjX58Y9/\n3OlxAAAgiR1IaKxx48blySefzMaNGzN8+PBOj0OHWTsBgCawAwkNddxxx6XdbvfdEwkAAJ1mBxIa\n6u67784pp5yScePGZc6cOZk6dWpGjRrV75z999+/Q9Mx0KydAEATCEhoqK6u/hcItFqtvo/b7XZa\nrVZ6e3sHeiw6xNoJADTB0E4PANT8ajyICQAABpqAhIZ63/vet83XX7gjCQAAA2G7l7AuWbIks2bN\nyk9+8pNMmTIl1113XaZOnbrVeQ888EDOP//8fOtb38qwYcNy4okn5sYbb9z6E7oMC2CHWTsBgCbY\n5lNYe3p6cuqpp+app57Ktddem0ceeSSnnXZaNm/e3O+8drudU045Jf/2b/+Wyy67LJ/85Cez9957\n79TBYTBZt25dfvSjH3V6DAAABrltBuStt96adevW5dxzz83MmTNz9tlnZ/Xq1Vm8eHG/8+644458\n//vfz8UXX5zLLrss55xzTv72b/92Z84Ng8Ldd9+dww8/PBMmTMjrXve6JMm73/3u/MEf/EGWLl3a\n4ekAABhsthmQq1evTpLss88+/f7ccnyLH/7wh0mSm2++OaNHj84uu+yST3/607/xYWEwWbFiRd76\n1rdmxYoV/Y7/zu/8ThYvXpyvfOUrHZoMAIDBaoceovNS998888wzSZLhw4dn4cKF+djHPpaLLroo\nb3vb2/Jbv/VbW51/5ZVX9n3c3d2d7u7uHRkDBoWPf/zj6enpyV577ZVHH3207/g73/nOXHnllbnz\nzjs7OB072+LFi7e62gMAoNO2GZCTJ09O8twDcpLkwQcf7Dve09OTIUOGZNiwYX3nnXDCCTnppJPy\n7W9/OytWrMjPfvaz7QYk8OLuvPPOtFqt3HbbbXn961/fd/zggw9Okvz85z/v1GgMgF/95drs2bM7\nNwwAwP/b5lNYn3nmmUycODGjR4/OpZdemjlz5mTkyJFZuXJlhg4dmilTpmTFihXZuHFjJk2alHHj\nxuUjH/lIrr766jzyyCP56U9/mj333LP/J/QkQSgZPnx4ent709PTkxEjRqTVaqW3tzcbNmzI7rvv\nnuHDh6enp6fTYzJArJ0AQBNs8x7IESNGZP78+Rk7dmwuuuiiTJgwIfPnz09X13N/bcv70I0aNSo3\n33xzRowYkfPPPz9jx47NggULtopHoG6vvfZKkvz3f/93v+Nf+tKXkiTjx48f8JkAABjctvs+kL/x\nT+i36FAyffr0/OM//mMOOOCA/OxnP0uSHHfccfnWt76Vdrud973vfbnhhhs6OiMDx9oJADSBgISG\n+tGPfpRp06a96GWqI0eOzPe+970ccsghHZiMTrB2AgBNsM1LWIHOOeSQQ3L77bf3PTRni4MOOijf\n/OY3xSMAAAPODiQ0SHd3d6ZPn57TTz89u+yyS9/xlStXZt26dRk/fnwOPPDADk5Ip1g7AYAmEJDQ\nIFseUDVy5MiceOKJOfPMM3P88cdn6NAdestWXoGsnQBAEwhIaJAtAflCe+yxR84444yceeaZOeqo\nozowFU1g7QQAmkBAQoN861vfyk033ZQFCxbk8ccf7/daq9XKpEmTcuaZZ+bMM890KesgY+0EAJpA\nQEIDPfvss7n11ltz0003ZdGiRdm4cWO/11utVn73d383S5cu7dCEDDRrJwDQBAISGu6pp57Kv/zL\nv+Smm27K7bffnk2bNiV57nupt7e3w9MxUKydAEATeDIHNNyYMWNy8sknp9VqZcOGDVmyZEmnRwIA\nYJASkNBQmzZtym233ZYvf/nL+frXv56NGzf224GyGwUAwEATkNAg7XY7d955Z7785S/nq1/9an7x\ni19sdc6kSZPy3ve+N9OnT+/AhAAADGYCEhpkv/32y0MPPbTV7uLuu++e008/PdOnT88b3/jGDk0H\nAMBg5yE60CAvfB/IESNG5IQTTsj06dNz/PHHZ9iwYR2cjE6zdgIATWAHEhrmmGOOyfTp03P66adn\n3LhxnR4HAAD6CEhokNWrV2fixImdHgMAAF5U1/ZPAQbKr/O+jqtWrdoJkwAAwNYEJDTIwQcfnDPP\nPDN33XXXds+988478973vje//du/PQCTAQCAh+hAo2x5iE6r1cqrX/3qvOlNb8phhx2WPffcM0ny\n6KOP5r777suSJUvy8MMP930vbd68uWMzMzCsnQBAEwhIaJClS5fmkksuyT333FM6/6ijjsrf/M3f\n5A1veMNOnoxOs3YCAE0gIKGBlixZks9//vO5/fbb88gjj/R7bfz48XnrW9+aD3zgAznmmGM67JKU\ndAAAD19JREFUNCEDzdoJADSBgISGe+CBB/Lwww8neS4e999//w5PRCdYOwGAJhCQAC8D1k4AoAm8\nDyQ03D333JNvfOMbefTRR7P33nvnhBNOyO///u93eiwAAAYhO5DQYDNnzsznP//5fsdarVY++MEP\n5rOf/WyHpqITrJ0AQBMISGioG264IWedddZLvn799ddnxowZAzgRnWTtBACaoKvTAwAvbsvO48SJ\nE3PttddmwYIFufbaazNx4sR+rwMAwECxAwkN9apXvSpPP/10li1blkMPPbTv+A9+8IMcdthhedWr\nXpXHH3+8gxMykKydAEAT2IGEhnr22WeTJPvtt1+/4/vuu2+/1wEAYKAISGio/fbbL+12O5dcckk2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PJFIKB6Py+v1rhjft2+f5ufn\ncxUvp35VC7vdrmQyKY/Hozt37igYDMrj8RhIaE5ZWZkkKRqNStLyNW+Z8XwzNjam2tpaFRUV6f79\n+3l5ivfU1JQ+fvwol8u1PHbr1i3ZbDZdv37dYDIAAACz8nIbjx8/fuju3buyWCxKp9Nqb2/X9+/f\n1d/fr7q6OtPxcu7EiRO6ffu2jh07psbGRqXTaVVXV8vpdJqOlhNzc3NyOBwqKiqSz+eT3++XzWbT\ny5cv8+7GKdFoVFVVVfry5Yv8fr8cDock5d1BhfHxcY2Pj0uSnj17posXL+ro0aPy+/06ePCg4XQA\nAADm5GUD+VelpaX6/Pmzvn37ZjqKEaWlpXr79u3yqZsWi0V9fX06deqU4WS5Ew6H5fV6NTExoYqK\nCgWDQVVWVpqOlXOhUEi1tbXLB1ekpe/D4uKi4WTmjIyMqKamRp2dnbpy5YrpOAAAAEbRQAIAAAAA\n1uSPvokOAAAAAOD3oYEEAAAAAKwJDSQAAAAAYE1oIAEAAAAAa0IDCQAAAABYExpIAAAAAMCa0EAC\nAAAAANbkf1M+pbyPupgkAAAAAElFTkSuQmCC\n", + "text": [ + "" + ] + } + ], + "prompt_number": 95 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "

Example 15.9, Page number: 521

" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Display status of mouse button pressed \n", + "\n", + "from Tkinter import *\n", + "from tkFileDialog import askopenfilename\n", + "import Image, ImageTk\n", + "\n", + "if __name__ == \"__main__\":\n", + " root = Tk()\n", + "\n", + " #setting up a tkinter canvas with scrollbars\n", + " frame = Frame(root, bd=2, relief=SUNKEN)\n", + " frame.grid_rowconfigure(0, weight=1)\n", + " frame.grid_columnconfigure(0, weight=1)\n", + " xscroll = Scrollbar(frame, orient=HORIZONTAL)\n", + " xscroll.grid(row=1, column=0, sticky=E+W)\n", + " yscroll = Scrollbar(frame)\n", + " yscroll.grid(row=0, column=1, sticky=N+S)\n", + " canvas = Canvas(frame, bd=0, xscrollcommand=xscroll.set, yscrollcommand=yscroll.set)\n", + " canvas.grid(row=0, column=0, sticky=N+S+E+W)\n", + " xscroll.config(command=canvas.xview)\n", + " yscroll.config(command=canvas.yview)\n", + " frame.pack(fill=BOTH,expand=1)\n", + "\n", + " \n", + "\n", + " #function to be called when mouse is clicked\n", + " def printcoords(event):\n", + " #outputting x and y coords to console\n", + " print \"Mouse Button pressed\"\n", + " print (event.x,event.y)\n", + " #mouseclick event\n", + " canvas.bind(\"