diff options
author | kinitrupti | 2015-10-15 17:40:30 +0530 |
---|---|---|
committer | kinitrupti | 2015-10-15 17:40:30 +0530 |
commit | 4a735f833653551e3321fbe9a8e47faa879d282f (patch) | |
tree | db91b182e06d1695ad8db15d757f669ad929c0b6 /Practical_C_Programming | |
parent | 78784b374b2d1a9be66eb4ad41470409e2bd4dfa (diff) | |
download | Python-Textbook-Companions-4a735f833653551e3321fbe9a8e47faa879d282f.tar.gz Python-Textbook-Companions-4a735f833653551e3321fbe9a8e47faa879d282f.tar.bz2 Python-Textbook-Companions-4a735f833653551e3321fbe9a8e47faa879d282f.zip |
solved errors
Diffstat (limited to 'Practical_C_Programming')
-rwxr-xr-x | Practical_C_Programming/.ipynb_checkpoints/Chapter_14_1-checkpoint.ipynb | 175 | ||||
-rwxr-xr-x | Practical_C_Programming/.ipynb_checkpoints/Chapter_15_1-checkpoint.ipynb | 351 | ||||
-rwxr-xr-x | Practical_C_Programming/Chapter_14_1.ipynb | 30 | ||||
-rwxr-xr-x | Practical_C_Programming/Chapter_15_1.ipynb | 72 | ||||
-rw-r--r-- | Practical_C_Programming/numbers.dat | 1 | ||||
-rw-r--r-- | Practical_C_Programming/numbers.dat~ | 0 |
6 files changed, 564 insertions, 65 deletions
diff --git a/Practical_C_Programming/.ipynb_checkpoints/Chapter_14_1-checkpoint.ipynb b/Practical_C_Programming/.ipynb_checkpoints/Chapter_14_1-checkpoint.ipynb new file mode 100755 index 00000000..c25523b7 --- /dev/null +++ b/Practical_C_Programming/.ipynb_checkpoints/Chapter_14_1-checkpoint.ipynb @@ -0,0 +1,175 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:aaf3603d1f605477459dd54990dcc4c8c154c9c808805468e92c30fde9487343" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Chapter 14: File input/output" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.1, Page number: 253" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variable declaration\n", + "import os\n", + "count = 0\n", + "in_file = open ('input.txt', 'r')\n", + " \n", + "# Calculation and result\n", + "if not os.path.exists ('input.txt') :\n", + " print ('Cannot open input.txt\\n')\n", + "\n", + "while (1) :\n", + " ch = in_file.read(1)\n", + " if not ch :\n", + " break\n", + " count += 1\n", + "\n", + "print ('Number of characters in input.txt is %d\\n' % count)\n", + "\n", + "in_file.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number of characters in input.txt is 0\n", + "\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.3, Page number: 257" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "# Variable declaration\n", + "import sys\n", + "import os\n", + "in_file = open ('input.txt', 'r')\n", + " \n", + "# Calculation and result\n", + "if not os.path.exists ('input.txt') :\n", + " print ('Could not open file\\n')\n", + " sys.exit(1)\n", + "print ('File found\\n')\n", + "\n", + "in_file.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "File found\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.4, Page number: 260" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variable declaration\n", + "import sys\n", + "import os\n", + "out_file = open ('test.out', 'w')\n", + " \n", + "# Calculation and result\n", + "if not os.path.exists ('test.out') :\n", + " print ('Cannot open output file\\n')\n", + " sys.exit(1)\n", + "\n", + "for cur_char in range (0, 128) :\n", + " out_file.write(str (cur_char))\n", + " out_file.write('\\n')\n", + "\n", + "out_file.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.5, Page number: 267" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "# Variable declaration\n", + "txt_file = open ('input.txt')\n", + "\n", + "source_content = txt_file.read()\n", + "\n", + "target = open ('output.txt', 'w')\n", + "\n", + "# Calculation and result\n", + "target.write(source_content)\n", + "print ('Content copied')\n", + "\n", + "target.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Practical_C_Programming/.ipynb_checkpoints/Chapter_15_1-checkpoint.ipynb b/Practical_C_Programming/.ipynb_checkpoints/Chapter_15_1-checkpoint.ipynb new file mode 100755 index 00000000..05286d0f --- /dev/null +++ b/Practical_C_Programming/.ipynb_checkpoints/Chapter_15_1-checkpoint.ipynb @@ -0,0 +1,351 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:23b3891085deb8af52412d44380b6187a4110d7e026531ec90b3b2ae79d61d0f" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 15: Debugging and optimization" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 15.1, Page number: 275" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Function declaration\n", + "def lookup (name) :\n", + " lists = ['John', 'Jim', 'Jane', 'Clyde']\n", + " result = 0\n", + "\n", + " for index in range (0, 4) :\n", + " if (lists[index] == name) :\n", + " result = 1\n", + " break\n", + " \n", + " return result\n", + "\n", + "# Calculation and result\n", + "name = 'John'\n", + "\n", + "if (lookup (name)) :\n", + " print ('%s is in the list\\n' % name)\n", + "else :\n", + " print ('%s is not in the list\\n' % name)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "John is in the list\n", + "\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 15.6, Page number: 288" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variable and function declaration\n", + "seven_count = 0\n", + "three_count = 0\n", + "data = []\n", + "\n", + "def get_data (data) :\n", + " for i in range (0, 5) :\n", + " x = 3\n", + " data.append(int(x))\n", + " print (data)\n", + "\n", + "# Calculation\n", + "get_data (data)\n", + "for index in range (0, 5) :\n", + " if data[index] == 3 :\n", + " three_count += 1\n", + "\n", + " if data[index] == 7 :\n", + " seven_count += 1\n", + "\n", + "# Result\n", + "print ('Threes %d Sevens %d' % (three_count, seven_count))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "[3, 3, 3, 3, 3]\n", + "Threes 5 Sevens 0\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 15.7, Page number: 292" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variable declaration\n", + "import sys\n", + "import os\n", + "in_file = open ('numbers.dat', 'r')\n", + "\n", + "data = []\n", + "max_count = 0\n", + " \n", + "# Calculation and result\n", + "if not os.path.exists ('numbers.dat') :\n", + " print ('Error:Unable to open numbers.dat\\n')\n", + " sys.exit(1)\n", + "\n", + "for line in in_file :\n", + " data.append(line)\n", + " max_count += 1\n", + "\n", + "while (1) :\n", + " search = 6\n", + " \n", + " if (search == -1) :\n", + " break\n", + "\n", + " low = 0\n", + " high = max_count\n", + "\n", + " while (1) :\n", + " mid = (low + high) / 2\n", + " middle = int (mid) \n", + "\n", + " if (int (data[middle]) == search) :\n", + " print ('Found at index %d\\n' % (middle + 1))\n", + " break\n", + "\n", + " if (low == high) :\n", + " print ('Not found\\n')\n", + " break\n", + "\n", + " if (int (data[middle]) < search) :\n", + " low = middle\n", + " else :\n", + " high = middle \n", + "\n", + "in_file.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": "*" + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 15.8, Page number: 300" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "# Variable declaration\n", + "import sys\n", + "import os\n", + "in_file = open ('numbers.dat', 'r')\n", + "\n", + "data = []\n", + "max_count = 0\n", + " \n", + "# Calculation and result\n", + "if not os.path.exists ('numbers.dat') :\n", + " print ('Error:Unable to open numbers.dat\\n')\n", + " sys.exit(1)\n", + "\n", + "for line in in_file :\n", + " data.append(line)\n", + " max_count += 1\n", + "\n", + "while (1) :\n", + " search = 14\n", + " \n", + " if (search == -1) :\n", + " break\n", + "\n", + " low = 0\n", + " high = max_count\n", + "\n", + " while (1) :\n", + " mid = (low + high) / 2\n", + " middle = int (mid) \n", + "\n", + " if (int (data[middle]) == search) :\n", + " print ('Found at index %d\\n' % (middle + 1))\n", + " break\n", + "\n", + " if (low == high) :\n", + " print ('Not found\\n')\n", + " break\n", + "\n", + " if (int (data[middle]) < search) :\n", + " low = middle\n", + " else :\n", + " high = middle \n", + "\n", + "in_file.close()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": "*" + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 15.10, Page number: 304" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variable declaration\n", + "i = 1\n", + "j = 1\n", + "\n", + "# Calculation and result\n", + "print ('Starting\\n')\n", + "print ('Before divide...')\n", + "i = i / j\n", + "print ('After\\n')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Starting\n", + "\n", + "Before divide...\n", + "After\n", + "\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 15.11, Page number: 304" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "# Variable declaration\n", + "import sys\n", + "i = 1\n", + "j = 1\n", + "\n", + "# Calculation and result\n", + "print ('Starting\\n')\n", + "sys.stdout.flush()\n", + "print ('Before divide...')\n", + "sys.stdout.flush()\n", + "i = i / j\n", + "print ('After\\n')\n", + "sys.stdout.flush()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Starting\n", + "\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Before divide...\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After\n", + "\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Practical_C_Programming/Chapter_14_1.ipynb b/Practical_C_Programming/Chapter_14_1.ipynb index 6d3c736e..c25523b7 100755 --- a/Practical_C_Programming/Chapter_14_1.ipynb +++ b/Practical_C_Programming/Chapter_14_1.ipynb @@ -52,17 +52,15 @@ "metadata": {}, "outputs": [ { - "ename": "IOError", - "evalue": "[Errno 2] No such file or directory: 'input.txt'", - "output_type": "pyerr", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIOError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-1-038814efe2a7>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mcount\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[0min_file\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'input.txt'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'r'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[1;31m# Calculation and result\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mIOError\u001b[0m: [Errno 2] No such file or directory: 'input.txt'" + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number of characters in input.txt is 0\n", + "\n" ] } ], - "prompt_number": 1 + "prompt_number": 2 }, { "cell_type": "heading", @@ -84,7 +82,7 @@ "in_file = open ('input.txt', 'r')\n", " \n", "# Calculation and result\n", - "if not os.path.exists (name) :\n", + "if not os.path.exists ('input.txt') :\n", " print ('Could not open file\\n')\n", " sys.exit(1)\n", "print ('File found\\n')\n", @@ -95,17 +93,15 @@ "metadata": {}, "outputs": [ { - "ename": "IOError", - "evalue": "[Errno 2] No such file or directory: 'input.txt'", - "output_type": "pyerr", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIOError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-2-370dc09ecbc3>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0msys\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[0min_file\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'input.txt'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'r'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[1;31m# Calculation and result\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mIOError\u001b[0m: [Errno 2] No such file or directory: 'input.txt'" + "output_type": "stream", + "stream": "stdout", + "text": [ + "File found\n", + "\n" ] } ], - "prompt_number": 2 + "prompt_number": 5 }, { "cell_type": "heading", diff --git a/Practical_C_Programming/Chapter_15_1.ipynb b/Practical_C_Programming/Chapter_15_1.ipynb index 34a86a67..05286d0f 100755 --- a/Practical_C_Programming/Chapter_15_1.ipynb +++ b/Practical_C_Programming/Chapter_15_1.ipynb @@ -173,19 +173,8 @@ ], "language": "python", "metadata": {}, - "outputs": [ - { - "ename": "IOError", - "evalue": "[Errno 2] No such file or directory: 'numbers.dat'", - "output_type": "pyerr", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIOError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-5-ce867c3a4ec5>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0msys\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[0min_file\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'numbers.dat'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'r'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[0mdata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mIOError\u001b[0m: [Errno 2] No such file or directory: 'numbers.dat'" - ] - } - ], - "prompt_number": 5 + "outputs": [], + "prompt_number": "*" }, { "cell_type": "heading", @@ -248,19 +237,8 @@ ], "language": "python", "metadata": {}, - "outputs": [ - { - "ename": "IOError", - "evalue": "[Errno 2] No such file or directory: 'numbers.dat'", - "output_type": "pyerr", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIOError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-6-8cd3b79f72a3>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0msys\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[0min_file\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'numbers.dat'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'r'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[0mdata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mIOError\u001b[0m: [Errno 2] No such file or directory: 'numbers.dat'" - ] - } - ], - "prompt_number": 6 + "outputs": [], + "prompt_number": "*" }, { "cell_type": "heading", @@ -277,7 +255,7 @@ "\n", "# Variable declaration\n", "i = 1\n", - "j = 0\n", + "j = 1\n", "\n", "# Calculation and result\n", "print ('Starting\\n')\n", @@ -289,26 +267,18 @@ "metadata": {}, "outputs": [ { - "ename": "ZeroDivisionError", - "evalue": "integer division or modulo by zero", - "output_type": "pyerr", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-7-289ff2a55d4d>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'Starting\\n'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'Before divide...'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 12\u001b[1;33m \u001b[0mi\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mi\u001b[0m \u001b[1;33m/\u001b[0m \u001b[0mj\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 13\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'After\\n'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mZeroDivisionError\u001b[0m: integer division or modulo by zero" - ] - }, - { "output_type": "stream", "stream": "stdout", "text": [ "Starting\n", "\n", - "Before divide...\n" + "Before divide...\n", + "After\n", + "\n" ] } ], - "prompt_number": 7 + "prompt_number": 9 }, { "cell_type": "heading", @@ -322,11 +292,11 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + "from __future__ import division\n", "# Variable declaration\n", "import sys\n", "i = 1\n", - "j = 0\n", + "j = 1\n", "\n", "# Calculation and result\n", "print ('Starting\\n')\n", @@ -356,17 +326,23 @@ ] }, { - "ename": "ZeroDivisionError", - "evalue": "integer division or modulo by zero", - "output_type": "pyerr", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-8-eedd2fda3e82>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 13\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'Before divide...'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 14\u001b[0m \u001b[0msys\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstdout\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mflush\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 15\u001b[1;33m \u001b[0mi\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mi\u001b[0m \u001b[1;33m/\u001b[0m \u001b[0mj\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 16\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'After\\n'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 17\u001b[0m \u001b[0msys\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstdout\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mflush\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mZeroDivisionError\u001b[0m: integer division or modulo by zero" + "output_type": "stream", + "stream": "stdout", + "text": [ + "After\n", + "\n" ] } ], "prompt_number": 8 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] } ], "metadata": {} diff --git a/Practical_C_Programming/numbers.dat b/Practical_C_Programming/numbers.dat new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/Practical_C_Programming/numbers.dat @@ -0,0 +1 @@ +0 diff --git a/Practical_C_Programming/numbers.dat~ b/Practical_C_Programming/numbers.dat~ new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Practical_C_Programming/numbers.dat~ |