summaryrefslogtreecommitdiff
path: root/Digital_Fundamentals/chapterno2.ipynb
diff options
context:
space:
mode:
authorhardythe12015-06-03 15:27:17 +0530
committerhardythe12015-06-03 15:27:17 +0530
commitdf60071cf1d1c18822d34f943ab8f412a8946b69 (patch)
treeab059cf19bad4a1233a464ccf5d72cf8b3fb323c /Digital_Fundamentals/chapterno2.ipynb
parentfba055ce5aa0955e22bac2413c33493b10ae6532 (diff)
downloadPython-Textbook-Companions-df60071cf1d1c18822d34f943ab8f412a8946b69.tar.gz
Python-Textbook-Companions-df60071cf1d1c18822d34f943ab8f412a8946b69.tar.bz2
Python-Textbook-Companions-df60071cf1d1c18822d34f943ab8f412a8946b69.zip
add books
Diffstat (limited to 'Digital_Fundamentals/chapterno2.ipynb')
-rwxr-xr-xDigital_Fundamentals/chapterno2.ipynb2445
1 files changed, 2445 insertions, 0 deletions
diff --git a/Digital_Fundamentals/chapterno2.ipynb b/Digital_Fundamentals/chapterno2.ipynb
new file mode 100755
index 00000000..a16a883e
--- /dev/null
+++ b/Digital_Fundamentals/chapterno2.ipynb
@@ -0,0 +1,2445 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:429d17d285f29f09acb2aad43b7b48023cb37d7be51ecf4ab3c1853aad55390a"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 2: Number Systems,Operations, And Codes"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-1, Page NO:17"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"The Digit 4 has a weight of 10,which is 10^1, as indicated by its position. The digit 7 has a weight of 1, ehich is 10^0, as indicated by its position.\"\n",
+ "#Results\n",
+ "print\"47=(4*10^1)+(7*10^0)\"\n",
+ "print\" =(4*10)+(7*1)\"\n",
+ "print\" =40+7\"\n",
+ "print\" =47\"\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Digit 4 has a weight of 10,which is 10^1, as indicated by its position. The digit 7 has a weight of 1, ehich is 10^0, as indicated by its position.\n",
+ "47=(4*10^1)+(7*10^0)\n",
+ " =(4*10)+(7*1)\n",
+ " =40+7\n",
+ " =47\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-2, Page No:18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"The whole Number digit 5 has weight of 100, which is 10^2, the digit 6 has a weight of 10,which is 10^-1, the digit 8 has a weight of 1,which is 10^0, the fractional digit 2 has a weight of 0.1 is 10^-1, and the fractional digit has a weight of 0.01,which is 10^-2.\"\n",
+ "\n",
+ "print\"568.23=(5*10^2)+(6*10^1)+(8*10^0)+(2*10^-1)+(3*10^-2)\"\n",
+ "print\" =(5*100)+(6*10)+(8*1)+(2*0.1)+(3*0.01)\"\n",
+ "print\" = 500 + 60 + 8 + 0.2 + 0.03\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The whole Number digit 5 has weight of 100, which is 10^2, the digit 6 has a weight of 10,which is 10^-1, the digit 8 has a weight of 1,which is 10^0, the fractional digit 2 has a weight of 0.1 is 10^-1, and the fractional digit has a weight of 0.01,which is 10^-2.\n",
+ "568.23=(5*10^2)+(6*10^1)+(8*10^0)+(2*10^-1)+(3*10^-2)\n",
+ " =(5*100)+(6*10)+(8*1)+(2*0.1)+(3*0.01)\n",
+ " = 500 + 60 + 8 + 0.2 + 0.03\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-3, Page NO:20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"Determine the weight of each bit that is a 1, and then find the sum of the weights to get the decimal number.\"\n",
+ "\n",
+ "print\"Weight: 2^6 2^5 2^4 2^3 2^2 2^1 2^0\"\n",
+ "print\"Binary: 1 1 0 1 1 0 1 \"\n",
+ "\n",
+ "print\"1101101=2^6+2^5+2^3+2^2+2^0\"\n",
+ "k=64+32+8+4+1\n",
+ "\n",
+ "print\"1101101=\",k,"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Determine the weight of each bit that is a 1, and then find the sum of the weights to get the decimal number.\n",
+ "Weight: 2^6 2^5 2^4 2^3 2^2 2^1 2^0\n",
+ "Binary: 1 1 0 1 1 0 1 \n",
+ "1101101=2^6+2^5+2^3+2^2+2^0\n",
+ "1101101= 109\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-4, Page NO:20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"Determine the weight of each bit that is a 1, and then find the sum of the weights to get the decimal fraction.\"\n",
+ "\n",
+ "print\"Weight: 2^-1 2^-2 2^-3 2^-4\"\n",
+ "print\"Binary: 0. 1 0 1 1 \"\n",
+ "\n",
+ "print\"0.1011=2^-1+2^-3+2^-4\"\n",
+ "k=0.5+0.125+0.0625\n",
+ "\n",
+ "print\"0.1011=\",k,"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Determine the weight of each bit that is a 1, and then find the sum of the weights to get the decimal fraction.\n",
+ "Weight: 2^-1 2^-2 2^-3 2^-4\n",
+ "Binary: 0. 1 0 1 1 \n",
+ "0.1011=2^-1+2^-3+2^-4\n",
+ "0.1011= 0.6875\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-5, Page No:21"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=int('1100',2)\n",
+ "b=int('11001',2)\n",
+ "c=int('111010',2)\n",
+ "d=int('1010010',2)\n",
+ "\n",
+ "print\"\",a\n",
+ "print\"\",b\n",
+ "print\"\",c\n",
+ "print\"\",d"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 12\n",
+ " 25\n",
+ " 58\n",
+ " 82\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-6, Page NO:22"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"(a) Remainder 19 (b)Remainder 45 \"\n",
+ "print\"19/2=9 (1) 45/2=22 (1)\"\n",
+ "print\"9/2=4 (1) 22/2=11 (0)\"\n",
+ "print\"4/2=2 (0) 11/2=5 (1)\"\n",
+ "print\"2/2=1 (0) 5/2=2 (1)\"\n",
+ "print\"1/2=0 (1) 2/2=1 (0)\"\n",
+ "print\" 1/2=0 (0)\"\n",
+ "\n",
+ "print\"MSB>>10011<<LSB MSB>>101101<<LSB\"\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) Remainder 19 (b)Remainder 45 \n",
+ "19/2=9 (1) 45/2=22 (1)\n",
+ "9/2=4 (1) 22/2=11 (0)\n",
+ "4/2=2 (0) 11/2=5 (1)\n",
+ "2/2=1 (0) 5/2=2 (1)\n",
+ "1/2=0 (1) 2/2=1 (0)\n",
+ " 1/2=0 (0)\n",
+ "MSB>>10011<<LSB MSB>>101101<<LSB\n"
+ ]
+ }
+ ],
+ "prompt_number": 20
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-7, Page NO:24"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"Binary Addition & The equivalent decimal addition is also shown for refrence.\"\n",
+ "a = '11'\n",
+ "b = '11'\n",
+ "c = bin(int(a,2) + int(b,2))\n",
+ "print\"11+11=\",c\n",
+ "int('c',2)\n",
+ "\n",
+ "d = '100'\n",
+ "e = '10'\n",
+ "f = bin(int(d,2) + int(e,2))\n",
+ "print\"100+10=\",f\n",
+ "\n",
+ "g = '111'\n",
+ "h = '11'\n",
+ "i = bin(int(g,2) + int(h,2))\n",
+ "print\"111+11\",i\n",
+ "\n",
+ "j = '110'\n",
+ "k = '100'\n",
+ "\n",
+ "l = bin(int(j,2) + int(k,2))\n",
+ "print\"110+100=\",l"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Binary Addition & The equivalent decimal addition is also shown for refrence.\n",
+ "11+11= 0b110\n"
+ ]
+ },
+ {
+ "ename": "ValueError",
+ "evalue": "invalid literal for int() with base 2: 'c'",
+ "output_type": "pyerr",
+ "traceback": [
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
+ "\u001b[1;32m<ipython-input-21-6606cdba5431>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[0mc\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mbin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mb\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;32mprint\u001b[0m\u001b[1;34m\"11+11=\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mc\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 6\u001b[1;33m \u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'c'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 7\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 8\u001b[0m \u001b[0md\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'100'\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
+ "\u001b[1;31mValueError\u001b[0m: invalid literal for int() with base 2: 'c'"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-8, Page NO:25"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"11+01=10 >>> 3-1=2\"\n",
+ "print\"11-10=01 >>> 3-2=1\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "11+01=10 >>> 3-1=2\n",
+ "11-10=01 >>> 3-2=1\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-9,Page NO:25"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"101-011=010 >>> 5-3=2\"\n",
+ "\n",
+ "print\"Let us examine exactly ehat was done to subtract the two binary numbers since a borrow is required. Begin with the Right column.\"\n",
+ "print\" consider number: 101\"\n",
+ "print\"Left Column:When a1 is borrowed, a O is left, so 0-0=0\"\n",
+ "print\"Middle Column: Borrow 1 from next column to the left, making a 10 inthis column, then 10-1=1.\"\n",
+ "print\"Right column:1-1=0\"\n",
+ "print\"Solution is:\"\n",
+ "print\" 101\"\n",
+ "print\" -011\"\n",
+ "print\"Solution=010\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "101-011=010 >>> 5-3=2\n",
+ "Let us examine exactly ehat was done to subtract the two binary numbers since a borrow is required. Begin with the Right column.\n",
+ " consider number: 101\n",
+ "Left Column:When a1 is borrowed, a O is left, so 0-0=0\n",
+ "Middle Column: Borrow 1 from next column to the left, making a 10 inthis column, then 10-1=1.\n",
+ "Right column:1-1=0\n",
+ "Solution is:\n",
+ " 101\n",
+ " -011\n",
+ "Solution=010\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Problem No:2-10, Page NO:26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\" 11 111\"\n",
+ "print\" *11 *101\"\n",
+ "print\" ____ ___\"\n",
+ "print\" 11 111\"\n",
+ "print\"+11 000\"\n",
+ "print\"_____ +111\"\n",
+ "print\"1001 _____\"\n",
+ "print\" 100011\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 11 111\n",
+ " *11 *101\n",
+ " ____ ___\n",
+ " 11 111\n",
+ "+11 000\n",
+ "_____ +111\n",
+ "1001 _____\n",
+ " 100011\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example:2-11, Page NO:26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"(a) 10 2 (b) 11 3\"\n",
+ "print\" ____ ___ ____ ___\"\n",
+ "print\" 11)110 3)6 10)110 2)6 \"\n",
+ "print\" 11 6 10 6 \"\n",
+ "print\" _____ ___ ____ ___\"\n",
+ "print\" 000 0 10 0 \"\n",
+ "print\" 10\"\n",
+ "print\" ____\"\n",
+ "print\" 00\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) 10 2 (b) 11 3\n",
+ " ____ ___ ____ ___\n",
+ " 11)110 3)6 10)110 2)6 \n",
+ " 11 6 10 6 \n",
+ " _____ ___ ____ ___\n",
+ " 000 0 10 0 \n",
+ " 10\n",
+ " ____\n",
+ " 00\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-12, Page NO:27"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\" 10110010 Binary Number\"\n",
+ "print\" 01001101 1's complement\"\n",
+ "print\"+ 1 Add 1\"\n",
+ "print\"_________\"\n",
+ "print\" 01001110 2's complement\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 10110010 Binary Number\n",
+ " 01001101 1's complement\n",
+ "+ 1 Add 1\n",
+ "_________\n",
+ " 01001110 2's complement\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-13, Page NO:28"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\" 10111000 Binary Number\"\n",
+ "print\" 1's Complement of original bits 01001000 2's Complement \""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 10111000 Binary Number\n",
+ " 1's Complement of original bits 01001000 2's Complement \n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-14, Page NO:30"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"8-bit number of +39 is\"\n",
+ "print\" 00100111\"\n",
+ "print\"In the sign magnitude form,-39 is produced by changing the sign bit to a 1 and leaving the magnitude bits as they are. The number is\"\n",
+ "print\" 10100111\"\n",
+ "print\"In the 1's complement form, -39 is produced by taking the 1's complement of +39(00100111).\"\n",
+ "print\" 11011000\"\n",
+ "print\"In the 2's complement form, -39 is produced by taking 2's complement of +39(00100111) as follows:\"\n",
+ "print\" 11011000 1's complement\"\n",
+ "print\" + 1\"\n",
+ "print\" ________\"\n",
+ "print\" 11011001 2's complement\" "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "8-bit number of +39 is\n",
+ " 00100111\n",
+ "In the sign magnitude form,-39 is produced by changing the sign bit to a 1 and leaving the magnitude bits as they are. The number is\n",
+ " 10100111\n",
+ "In the 1's complement form, -39 is produced by taking the 1's complement of +39(00100111).\n",
+ " 11011000\n",
+ "In the 2's complement form, -39 is produced by taking 2's complement of +39(00100111) as follows:\n",
+ " 11011000 1's complement\n",
+ " + 1\n",
+ " ________\n",
+ " 11011001 2's complement\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ " Example 2-15, Page NO:30"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"The Seven magnitude bits and their powers of two weights are follow:\"\n",
+ "print\" 2^6 2^5 2^4 2^3 2^2 2^1 2^0\"\n",
+ "print\" 0 0 1 0 1 0 1 \"\n",
+ "print\"Summing the weights where there are 1s,\"\n",
+ "print\" 16+4+1=21\"\n",
+ "print\"The sign bit is 1: therefore, the decimal number is -21.\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Seven magnitude bits and their powers of two weights are follow:\n",
+ " 2^6 2^5 2^4 2^3 2^2 2^1 2^0\n",
+ " 0 0 1 0 1 0 1 \n",
+ "Summing the weights where there are 1s,\n",
+ " 16+4+1=21\n",
+ "The sign bit is 1: therefore, the decimal number is -21.\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-16, Page NO:31"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"(a)The bits and their powers of two weights are follow:\"\n",
+ "print\" -2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0\"\n",
+ "print\" 0 0 0 1 0 1 1 1 \"\n",
+ "print\"Summing the weights where there are 1s,\"\n",
+ "print\" 16+4+2+1=23\"\n",
+ "print\"The sign bit is 1: therefore, the decimal number is +23.\"\n",
+ "\n",
+ "print\"(b)The bits and their powers of two weights are follow:\"\n",
+ "print\" -2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0\"\n",
+ "print\" 1 1 1 0 1 0 0 0 \"\n",
+ "print\"Summing the weights where there are 1s,\"\n",
+ "print\" -128+64+32+8=-24\"\n",
+ "print\"Adding 1 to the result, therefore, the decimal number is -24+1=23.\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a)The bits and their powers of two weights are follow:\n",
+ " -2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0\n",
+ " 0 0 0 1 0 1 1 1 \n",
+ "Summing the weights where there are 1s,\n",
+ " 16+4+2+1=23\n",
+ "The sign bit is 1: therefore, the decimal number is +23.\n",
+ "(b)The bits and their powers of two weights are follow:\n",
+ " -2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0\n",
+ " 1 1 1 0 1 0 0 0 \n",
+ "Summing the weights where there are 1s,\n",
+ " -128+64+32+8=-24\n",
+ "Adding 1 to the result, therefore, the decimal number is -24+1=23.\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-17, Page NO:31"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=int('01010110',2)\n",
+ "print\"01010110=\",a,\"\\n\"\n",
+ "\n",
+ "print\"(b)The bits and their powers of two weights are follow:\"\n",
+ "print\" -2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0\"\n",
+ "print\" 1 0 1 0 1 0 1 0 \"\n",
+ "print\"Summing the weights where there are 1s,\"\n",
+ "print\" -128+32+8+2=-86\"\n",
+ "print\"Summing the weights where there are 1s=-86\"\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "01010110= 86 \n",
+ "\n",
+ "(b)The bits and their powers of two weights are follow:\n",
+ " -2^7 2^6 2^5 2^4 2^3 2^2 2^1 2^0\n",
+ " 1 0 1 0 1 0 1 0 \n",
+ "Summing the weights where there are 1s,\n",
+ " -128+32+8+2=-86\n",
+ "Summing the weights where there are 1s=-86\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-18,Page NO:34"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"Binary of 3.284*10^4:\"\n",
+ "a=bin(32480)\n",
+ "print\"3.284*10^-4=\",a,\"\\n\"\n",
+ "\n",
+ "print\"The MSB will not occupy a bit position it is always a 1.Therefore, the mantissa is the fractional 23-bit binary number 111111011100000 and biased exponent is\"\n",
+ "print\"14+127=141=10001101(bin)\"\n",
+ "print\"The complete floating point number is:\"\n",
+ "print\"0 10001101 1111101110000000000000\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Binary of 3.284*10^4:\n",
+ "3.284*10^-4= 0b111111011100000 \n",
+ "\n",
+ "The MSB will not occupy a bit position it is always a 1.Therefore, the mantissa is the fractional 23-bit binary number 111111011100000 and biased exponent is\n",
+ "14+127=141=10001101(bin)\n",
+ "The complete floating point number is:\n",
+ "0 10001101 1111101110000000000000\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-19, Page NO:36"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"The equivalent decimal addition are\"\n",
+ "a='01000100'\n",
+ "b='00011011'\n",
+ "c='00001110'\n",
+ "d='00010010'\n",
+ "\n",
+ "e=bin(int(a,2)+int(b,2)+int(c,2)+int(d,2))\n",
+ "print\"01000100+00011011+00001110+00010010=\",e,"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The equivalent decimal addition are\n",
+ "01000100+00011011+00001110+00010010= 0b1111111\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a = '00001000'\n",
+ "b = '00000011'\n",
+ "\n",
+ "c = bin(int(a,2)-int(b,2))\n",
+ "print\"(a) 00001000-00000011=\",c,\"\\n\"\n",
+ "\n",
+ "print\"(b) 00001100-11110111 :\"\n",
+ "print\" 00001100 Minuend(+12)\"\n",
+ "print\" +00001001 2's complement of subtrahend(+9)\"\n",
+ "print\" Diffrence:00010101\",\"\\n\"\n",
+ "\n",
+ "\n",
+ "g = '11100111'\n",
+ "h = '00010011'\n",
+ "\n",
+ "i = bin(int(g,2)-int(h,2))\n",
+ "print\"(c) 11100111-00010011=\",i,\"\\n\"\n",
+ "\n",
+ "print\"(d) 10001000-11100010 :\"\n",
+ "print\" 10001000 Minuend(-120)\"\n",
+ "print\" +00011110 2's complement of subtrahend(+30)\"\n",
+ "print\" Diffrence:10100110\",\"\\n\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(a) 00001000-00000011= 0b101 \n",
+ "\n",
+ "(b) 00001100-11110111 :\n",
+ " 00001100 Minuend(+12)\n",
+ " +00001001 2's complement of subtrahend(+9)\n",
+ " Diffrence:00010101 \n",
+ "\n",
+ "(c) 11100111-00010011= 0b11010100 \n",
+ "\n",
+ "(d) 10001000-11100010 :\n",
+ " 10001000 Minuend(-120)\n",
+ " +00011110 2's complement of subtrahend(+30)\n",
+ " Diffrence:10100110 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-21, Page NO:38"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "g = '01001101'\n",
+ "h = '00000100'\n",
+ "\n",
+ "i = bin(int(g,2)*int(h,2))\n",
+ "print\"01001101*00000100=\",i,\"\\n\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "01001101*00000100= 0b100110100 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 28
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Example NO:2-22, Page NO:39"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=bin(0b01010011 * 0b11000101)\n",
+ "print\"01010011*11000101=\",a,"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "01010011*11000101= 0b11111111011111\n"
+ ]
+ }
+ ],
+ "prompt_number": 34
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exaple NO:2-23,Page NO:41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=bin(0b01100100 / 0b00011001)\n",
+ "print\"01100100/00011001=\",a,"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "01100100/00011001= 0b100\n"
+ ]
+ }
+ ],
+ "prompt_number": 36
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-24, Page NO:43"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=hex(0b1100101001010111)\n",
+ "print\"hexadecimal of 1100101001010111=\",a,\"\\n\"\n",
+ "\n",
+ "b=hex(0b111111000101101001)\n",
+ "print\"hexadecimal of 11111000101101001=\",b,"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "hexadecimal of 1100101001010111= 0xca57 \n",
+ "\n",
+ "hexadecimal of 11111000101101001= 0x3f169\n"
+ ]
+ }
+ ],
+ "prompt_number": 40
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-25, Page NO:43"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=bin(0x10A4)\n",
+ "print\"binary of 10A4=\",a,\"\\n\"\n",
+ "\n",
+ "b=bin(0xCF8E)\n",
+ "print\"binary of CF8E=\",b,\"\\n\"\n",
+ "\n",
+ "c=bin(0x9742)\n",
+ "print\"binary of 9742=\",c,"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "binary of 10A4= 0b1000010100100 \n",
+ "\n",
+ "binary of CF8E= 0b1100111110001110 \n",
+ "\n",
+ "binary of 9742= 0b1001011101000010\n"
+ ]
+ }
+ ],
+ "prompt_number": 43
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-26, Page No:44"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=int('1c',16)\n",
+ "print\"Decimal of 1c=\",a,\"\\n\"\n",
+ "\n",
+ "b=int('A85',16)\n",
+ "print\"Decimal of A85=\",b"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Decimal of 1c= 28 \n",
+ "\n",
+ "Decimal of A85= 2693\n"
+ ]
+ }
+ ],
+ "prompt_number": 46
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example No:2-27, Page NO:44"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=int('E5',16)\n",
+ "print\"Decimal of E5=\",a,\"\\n\"\n",
+ "\n",
+ "b=int('B2F8',16)\n",
+ "print\"Decimal of B2F8=\",b"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Decimal of E5= 229 \n",
+ "\n",
+ "Decimal of B2F8= 45816\n"
+ ]
+ }
+ ],
+ "prompt_number": 47
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exapmle NO:2-28, Page NO:45"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=hex(650)\n",
+ "print\"Hexadecimal of 650=\",a,"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Hexadecimal of 650= 0x28a\n"
+ ]
+ }
+ ],
+ "prompt_number": 49
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-29, Page NO:46"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a = '23'\n",
+ "b = '16'\n",
+ "\n",
+ "c = hex(int(a,16) + int(b,16))\n",
+ "print\"23+16=\",c,\"\\n\"\n",
+ "\n",
+ "d= '58'\n",
+ "e= '22'\n",
+ "f = hex(int(d,16) + int(e,16))\n",
+ "print\"58+22=\",f,\"\\n\"\n",
+ "\n",
+ "g = '2b'\n",
+ "h = '84'\n",
+ "i = hex(int(g,16) + int(h,16))\n",
+ "print\"2B+84=\",i,\"\\n\"\n",
+ "\n",
+ "j = 'df'\n",
+ "k = 'ac'\n",
+ "l = hex(int(j,16) + int(k,16))\n",
+ "print\"DF+AC=\",l,\"\\n\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "23+16= 0x39 \n",
+ "\n",
+ "58+22= 0x7a \n",
+ "\n",
+ "2B+84= 0xaf \n",
+ "\n",
+ "DF+AC= 0x18b \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 57
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-30, Page NO:47"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "g = '84'\n",
+ "h = '2a'\n",
+ "i = hex(int(g,16) - int(h,16))\n",
+ "print\"84-2a=\",i,\"\\n\"\n",
+ "\n",
+ "j = 'c3'\n",
+ "k = '0b'\n",
+ "l = hex(int(j,16) - int(k,16))\n",
+ "print\"c3+0b=\",l,\"\\n\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "84-2a= 0x5a \n",
+ "\n",
+ "c3+0b= 0xb8 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 59
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-31, Page NO:50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=bin(013)\n",
+ "print\"13=\",a,\"\\n\"\n",
+ "\n",
+ "b=bin(025)\n",
+ "print\"25=\",b,\"\\n\"\n",
+ "\n",
+ "c=bin(0140)\n",
+ "print\"140=\",c,\"\\n\"\n",
+ "\n",
+ "d=bin(07526)\n",
+ "print\"7526=\",d,"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "13= 0b1011 \n",
+ "\n",
+ "25= 0b10101 \n",
+ "\n",
+ "140= 0b1100000 \n",
+ "\n",
+ "7526= 0b111101010110\n"
+ ]
+ }
+ ],
+ "prompt_number": 62
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-32, Page No:50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=oct(0b110101)\n",
+ "print\"110101=\",a,\"\\n\"\n",
+ "\n",
+ "b=oct(0b101111001)\n",
+ "print\"101111001=\",b,\"\\n\"\n",
+ "\n",
+ "c=oct(0b100110011010)\n",
+ "print\"100110011010=\",c,\"\\n\"\n",
+ "\n",
+ "d=oct(0b011010000100)\n",
+ "print\"011010000100=\",d"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "110101= 065 \n",
+ "\n",
+ "101111001= 0571 \n",
+ "\n",
+ "100110011010= 04632 \n",
+ "\n",
+ "011010000100= 03204\n"
+ ]
+ }
+ ],
+ "prompt_number": 65
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-33, Page NO:51"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"BCD 35=00110101\\n\"\n",
+ "print\"BCD 98=10011000\\n\"\n",
+ "print\"BCD 170=000101110000\\n\"\n",
+ "print\"BCD 2469=0010010001101001\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "BCD 35=0011-0101\n",
+ "\n",
+ "BCD 98=1001-1000\n",
+ "\n",
+ "BCD 170=00001-0111-0000\n",
+ "\n",
+ "BCD 2469=0010-0100-0110-1001\n"
+ ]
+ }
+ ],
+ "prompt_number": 69
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-34, Page NO:52"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"10000110(BCD)=86(DECIMAL) \\n\"\n",
+ "print\"0011010100001=351\\n\"\n",
+ "print\"1001010001110000=9470 \\n\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "10000110(BCD)=86(DECIMAL) \n",
+ "\n",
+ "0011010100001=351\n",
+ "\n",
+ "1001010001110000=9470 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 70
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-35, Page NO:52"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"BCD Addition:\"\n",
+ "print\"0011+0100=0111\"\n",
+ "print\"00100011+00010101=00111000\"\n",
+ "print\"10000110+00010011=10011001\"\n",
+ "print\"010001010000+010000010111=100001100111\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "BCD Addition:\n",
+ "0011+0100=0111\n",
+ "00100011+00010101=00111000\n",
+ "10000110+00010011=10011001\n",
+ "010001010000+010000010111=100001100111\n"
+ ]
+ }
+ ],
+ "prompt_number": 71
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-36, Page NO:53"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"BCD Addition:\"\n",
+ "print\"1001+0100=00010011\"\n",
+ "print\"1001+1001=00011000\"\n",
+ "print\"00010110+00010101=00110001\"\n",
+ "print\"01100111+01010011=000100100000\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "BCD Addition:\n",
+ "1001+0100=00010011\n",
+ "1001+1001=00011000\n",
+ "00010110+00010101=00110001\n",
+ "01100111+01010011=000100100000\n"
+ ]
+ }
+ ],
+ "prompt_number": 72
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"Binary to Gray:\"\n",
+ "print\"11000110>>10100101\\n\"\n",
+ "\n",
+ "print\"Gray to binary Code\"\n",
+ "print\"10101111>>11001010\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Binary to Gray:\n",
+ "11000110>>10100101\n",
+ "\n",
+ "Gray to binary Code\n",
+ "10101111>>11001010\n"
+ ]
+ }
+ ],
+ "prompt_number": 74
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from IPython.display import HTML"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 90
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "s=\"\"\"<table>\n",
+ "<tr>\n",
+ "<th>Symbol</th>\n",
+ "<th>Binary</th>\n",
+ "<th>Hexadecimal</th>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>2</td>\n",
+ "<td>0110010</td>\n",
+ "<td>32</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>0</td>\n",
+ "<td>0110000</td>\n",
+ "<td>30</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>Space</td>\n",
+ "<td>0100000</td>\n",
+ "<td>20</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P</td>\n",
+ "<td>1010000</td>\n",
+ "<td>50</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>R</td>\n",
+ "<td>1010010</td>\n",
+ "<td>52</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>I</td>\n",
+ "<td>1001001</td>\n",
+ "<td>49</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>N</td>\n",
+ "<td>1001110</td>\n",
+ "<td>4E</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>T</td>\n",
+ "<td>1010100</td>\n",
+ "<td>54</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>Space</td>\n",
+ "<td>0100000</td>\n",
+ "<td>20</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>\"</td>\n",
+ "<td>0100010</td>\n",
+ "<td>22</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>A</td>\n",
+ "<td>1000001</td>\n",
+ "<td>41</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>=</td>\n",
+ "<td>0111101</td>\n",
+ "<td>3D</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>\"</td>\n",
+ "<td>0100010</td>\n",
+ "<td>22</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>;</td>\n",
+ "<td>0111011</td>\n",
+ "<td>3B</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>X</td>\n",
+ "<td>1011000</td>\n",
+ "<td>58</td>\n",
+ "</tr>\n",
+ "</table>\"\"\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 94
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "h = HTML(s); h "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "html": [
+ "<table>\n",
+ "<tr>\n",
+ "<th>Symbol</th>\n",
+ "<th>Binary</th>\n",
+ "<th>Hexadecimal</th>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>2</td>\n",
+ "<td>0110010</td>\n",
+ "<td>32</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>0</td>\n",
+ "<td>0110000</td>\n",
+ "<td>30</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>Space</td>\n",
+ "<td>0100000</td>\n",
+ "<td>20</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P</td>\n",
+ "<td>1010000</td>\n",
+ "<td>50</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>R</td>\n",
+ "<td>1010010</td>\n",
+ "<td>52</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>I</td>\n",
+ "<td>1001001</td>\n",
+ "<td>49</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>N</td>\n",
+ "<td>1001110</td>\n",
+ "<td>4E</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>T</td>\n",
+ "<td>1010100</td>\n",
+ "<td>54</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>Space</td>\n",
+ "<td>0100000</td>\n",
+ "<td>20</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>\"</td>\n",
+ "<td>0100010</td>\n",
+ "<td>22</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>A</td>\n",
+ "<td>1000001</td>\n",
+ "<td>41</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>=</td>\n",
+ "<td>0111101</td>\n",
+ "<td>3D</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>\"</td>\n",
+ "<td>0100010</td>\n",
+ "<td>22</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>;</td>\n",
+ "<td>0111011</td>\n",
+ "<td>3B</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>X</td>\n",
+ "<td>1011000</td>\n",
+ "<td>58</td>\n",
+ "</tr>\n",
+ "</table>"
+ ],
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 95,
+ "text": [
+ "<IPython.core.display.HTML at 0x8265748>"
+ ]
+ }
+ ],
+ "prompt_number": 95
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-39, Page NO:62"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"Make the pparity bit either 1 or 0 as neccesary to make the total number of 1s evem=n.The parity bit will be the left most bit(color).\"\n",
+ "print\"01010,1111000,0101101,0100011100101,1101101011111\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Make the pparity bit either 1 or 0 as neccesary to make the total number of 1s evem=n.The parity bit will be the left most bit(color).\n",
+ "01010,1111000,0101101,0100011100101,1101101011111\n"
+ ]
+ }
+ ],
+ "prompt_number": 97
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-40, Page NO:62"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"Since odd parity is required, any group with an even number of 1s incorrect. The following groups are in error: 110011 and 1100010101010.\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Since odd parity is required, any group with an even number of 1s incorrect. The following groups are in error: 110011 and 1100010101010.\n"
+ ]
+ }
+ ],
+ "prompt_number": 98
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-41, Page NO:65"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from IPython.display import HTML"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 100
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"(1) Let p=3 then 2^p=2^3=8\"\n",
+ "print\" The=ree parity bits are: 4+3=7\"\n",
+ "\n",
+ "print\"(2) Construct the position table, and enter the information bits.\"\n",
+ "print\"(3) Determine the parites:\"\n",
+ "print\"(4)the parity bits are entered below:\"\n",
+ "z=\"\"\"<table>\n",
+ "<tr>\n",
+ "<th>Bit Designation</th>\n",
+ "<th>Bit Position</th>\n",
+ "<th>Binary position Number</th>\n",
+ "<th>Information bits</th>\n",
+ "<th>Parity bits</th>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P1</td>\n",
+ "<td>1</td>\n",
+ "<td>001</td>\n",
+ "<td></td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P2</td>\n",
+ "<td>2</td>\n",
+ "<td>010</td>\n",
+ "<td></td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M1</td>\n",
+ "<td>3</td>\n",
+ "<td>011</td>\n",
+ "<td>1</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P3</td>\n",
+ "<td>4</td>\n",
+ "<td>100</td>\n",
+ "<td></td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M2</td>\n",
+ "<td>5</td>\n",
+ "<td>101</td>\n",
+ "<td>0</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M3</td>\n",
+ "<td>6</td>\n",
+ "<td>110</td>\n",
+ "<td>0</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M4</td>\n",
+ "<td>7</td>\n",
+ "<td>111</td>\n",
+ "<td>1</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "</table>\"\"\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(1) Let p=3 then 2^p=2^3=8\n",
+ " The=ree parity bits are: 4+3=7\n",
+ "(2) Construct the position table, and enter the information bits.\n",
+ "(3) Determine the parites:\n",
+ "(4)the parity bits are entered below:\n"
+ ]
+ }
+ ],
+ "prompt_number": 110
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "h = HTML(z); h "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "html": [
+ "<table>\n",
+ "<tr>\n",
+ "<th>Bit Designation</th>\n",
+ "<th>Bit Position</th>\n",
+ "<th>Binary position Number</th>\n",
+ "<th>Information bits</th>\n",
+ "<th>Parity bits</th>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P1</td>\n",
+ "<td>1</td>\n",
+ "<td>001</td>\n",
+ "<td></td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P2</td>\n",
+ "<td>2</td>\n",
+ "<td>010</td>\n",
+ "<td></td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M1</td>\n",
+ "<td>3</td>\n",
+ "<td>011</td>\n",
+ "<td>1</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P3</td>\n",
+ "<td>4</td>\n",
+ "<td>100</td>\n",
+ "<td></td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M2</td>\n",
+ "<td>5</td>\n",
+ "<td>101</td>\n",
+ "<td>0</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M3</td>\n",
+ "<td>6</td>\n",
+ "<td>110</td>\n",
+ "<td>0</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M4</td>\n",
+ "<td>7</td>\n",
+ "<td>111</td>\n",
+ "<td>1</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "</table>"
+ ],
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 111,
+ "text": [
+ "<IPython.core.display.HTML at 0x8265eb8>"
+ ]
+ }
+ ],
+ "prompt_number": 111
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example NO:2-42, Page NO:66"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"(1) Let p=4 then 2^p=2^4=16\"\n",
+ "print\" The=ree parity bits are: 5+4=9\"\n",
+ "\n",
+ "print\"(2) Construct the position table, and enter the information bits.\"\n",
+ "print\"(3) Determine the parites:\"\n",
+ "print\"(4)the parity bits are entered below:\"\n",
+ "x=\"\"\"<table>\n",
+ "<tr>\n",
+ "<th>Bit Designation</th>\n",
+ "<th>Bit Position</th>\n",
+ "<th>Binary position Number</th>\n",
+ "<th>Information bits</th>\n",
+ "<th>Parity bits</th>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P1</td>\n",
+ "<td>1</td>\n",
+ "<td>0001</td>\n",
+ "<td></td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P2</td>\n",
+ "<td>2</td>\n",
+ "<td>0010</td>\n",
+ "<td></td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M1</td>\n",
+ "<td>3</td>\n",
+ "<td>0011</td>\n",
+ "<td>1</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P3</td>\n",
+ "<td>4</td>\n",
+ "<td>0100</td>\n",
+ "<td></td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M2</td>\n",
+ "<td>5</td>\n",
+ "<td>0101</td>\n",
+ "<td>0</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M3</td>\n",
+ "<td>6</td>\n",
+ "<td>0110</td>\n",
+ "<td>1</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M4</td>\n",
+ "<td>7</td>\n",
+ "<td>0111</td>\n",
+ "<td>1</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P4</td>\n",
+ "<td>8</td>\n",
+ "<td>1000</td>\n",
+ "<td></td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M5</td>\n",
+ "<td>9</td>\n",
+ "<td>1001</td>\n",
+ "<td>0</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "</table>\"\"\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "(1) Let p=4 then 2^p=2^4=16\n",
+ " The=ree parity bits are: 5+4=9\n",
+ "(2) Construct the position table, and enter the information bits.\n",
+ "(3) Determine the parites:\n",
+ "(4)the parity bits are entered below:\n"
+ ]
+ }
+ ],
+ "prompt_number": 112
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "h= HTML(x);h"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "html": [
+ "<table>\n",
+ "<tr>\n",
+ "<th>Bit Designation</th>\n",
+ "<th>Bit Position</th>\n",
+ "<th>Binary position Number</th>\n",
+ "<th>Information bits</th>\n",
+ "<th>Parity bits</th>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P1</td>\n",
+ "<td>1</td>\n",
+ "<td>0001</td>\n",
+ "<td></td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P2</td>\n",
+ "<td>2</td>\n",
+ "<td>0010</td>\n",
+ "<td></td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M1</td>\n",
+ "<td>3</td>\n",
+ "<td>0011</td>\n",
+ "<td>1</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P3</td>\n",
+ "<td>4</td>\n",
+ "<td>0100</td>\n",
+ "<td></td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M2</td>\n",
+ "<td>5</td>\n",
+ "<td>0101</td>\n",
+ "<td>0</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M3</td>\n",
+ "<td>6</td>\n",
+ "<td>0110</td>\n",
+ "<td>1</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M4</td>\n",
+ "<td>7</td>\n",
+ "<td>0111</td>\n",
+ "<td>1</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P4</td>\n",
+ "<td>8</td>\n",
+ "<td>1000</td>\n",
+ "<td></td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M5</td>\n",
+ "<td>9</td>\n",
+ "<td>1001</td>\n",
+ "<td>0</td>\n",
+ "<td></td>\n",
+ "</tr>\n",
+ "</table>"
+ ],
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 113,
+ "text": [
+ "<IPython.core.display.HTML at 0x8265dd8>"
+ ]
+ }
+ ],
+ "prompt_number": 113
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "A=\"\"\"<table>\n",
+ "<tr>\n",
+ "<th>Bit Designation</th>\n",
+ "<th>Bit Position</th>\n",
+ "<th>Binary position Number</th>\n",
+ "<th>Received code</th>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P1</td>\n",
+ "<td>1</td>\n",
+ "<td>001</td>\n",
+ "<td>0</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P2</td>\n",
+ "<td>2</td>\n",
+ "<td>010</td>\n",
+ "<td>0</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M1</td>\n",
+ "<td>3</td>\n",
+ "<td>011</td>\n",
+ "<td>1</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P3</td>\n",
+ "<td>4</td>\n",
+ "<td>100</td>\n",
+ "<td>0</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M2</td>\n",
+ "<td>5</td>\n",
+ "<td>101</td>\n",
+ "<td>0</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M3</td>\n",
+ "<td>6</td>\n",
+ "<td>110</td>\n",
+ "<td>0</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M4</td>\n",
+ "<td>7</td>\n",
+ "<td>111</td>\n",
+ "<td>1</td>\n",
+ "\n",
+ "</tr>\n",
+ "</table>\"\"\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 116
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "h= HTML(A); h"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "html": [
+ "<table>\n",
+ "<tr>\n",
+ "<th>Bit Designation</th>\n",
+ "<th>Bit Position</th>\n",
+ "<th>Binary position Number</th>\n",
+ "<th>Received code</th>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P1</td>\n",
+ "<td>1</td>\n",
+ "<td>001</td>\n",
+ "<td>0</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P2</td>\n",
+ "<td>2</td>\n",
+ "<td>010</td>\n",
+ "<td>0</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M1</td>\n",
+ "<td>3</td>\n",
+ "<td>011</td>\n",
+ "<td>1</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P3</td>\n",
+ "<td>4</td>\n",
+ "<td>100</td>\n",
+ "<td>0</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M2</td>\n",
+ "<td>5</td>\n",
+ "<td>101</td>\n",
+ "<td>0</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M3</td>\n",
+ "<td>6</td>\n",
+ "<td>110</td>\n",
+ "<td>0</td>\n",
+ "\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M4</td>\n",
+ "<td>7</td>\n",
+ "<td>111</td>\n",
+ "<td>1</td>\n",
+ "\n",
+ "</tr>\n",
+ "</table>"
+ ],
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 117,
+ "text": [
+ "<IPython.core.display.HTML at 0x8265198>"
+ ]
+ }
+ ],
+ "prompt_number": 117
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\" Result: the error position code is 100(binary four).This says that the bit in position 4 is in error.It is a 0 and should be a 1. The corrected code is 0011001, which agrees with transmitte code.\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Result: the error position code is 100(binary four).This says that the bit in position 4 is in error.It is a 0 and should be a 1. The corrected code is 0011001, which agrees with transmitte code.\n"
+ ]
+ }
+ ],
+ "prompt_number": 118
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2-44, Page NO:68"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "Z=\"\"\"<table>\n",
+ "<tr>\n",
+ "<th>Bit Designation</th>\n",
+ "<th>Bit Position</th>\n",
+ "<th>Binary position Number</th>\n",
+ "<th>Received code</th>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P1</td>\n",
+ "<td>1</td>\n",
+ "<td>0001</td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P2</td>\n",
+ "<td>2</td>\n",
+ "<td>0010</td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M1</td>\n",
+ "<td>3</td>\n",
+ "<td>0011</td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P3</td>\n",
+ "<td>4</td>\n",
+ "<td>0100</td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M2</td>\n",
+ "<td>5</td>\n",
+ "<td>101</td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M3</td>\n",
+ "<td>6</td>\n",
+ "<td>0110</td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M4</td>\n",
+ "<td>7</td>\n",
+ "<td>0111</td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P4</td>\n",
+ "<td>8</td>\n",
+ "<td>1000</td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M5</td>\n",
+ "<td>9</td>\n",
+ "<td>1001</td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "</table>\"\"\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 122
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "h= HTML(Z); h"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "html": [
+ "<table>\n",
+ "<tr>\n",
+ "<th>Bit Designation</th>\n",
+ "<th>Bit Position</th>\n",
+ "<th>Binary position Number</th>\n",
+ "<th>Received code</th>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P1</td>\n",
+ "<td>1</td>\n",
+ "<td>0001</td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P2</td>\n",
+ "<td>2</td>\n",
+ "<td>0010</td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M1</td>\n",
+ "<td>3</td>\n",
+ "<td>0011</td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P3</td>\n",
+ "<td>4</td>\n",
+ "<td>0100</td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M2</td>\n",
+ "<td>5</td>\n",
+ "<td>101</td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M3</td>\n",
+ "<td>6</td>\n",
+ "<td>0110</td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M4</td>\n",
+ "<td>7</td>\n",
+ "<td>0111</td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>P4</td>\n",
+ "<td>8</td>\n",
+ "<td>1000</td>\n",
+ "<td>1</td>\n",
+ "</tr>\n",
+ "<tr>\n",
+ "<td>M5</td>\n",
+ "<td>9</td>\n",
+ "<td>1001</td>\n",
+ "<td>0</td>\n",
+ "</tr>\n",
+ "</table>"
+ ],
+ "metadata": {},
+ "output_type": "pyout",
+ "prompt_number": 123,
+ "text": [
+ "<IPython.core.display.HTML at 0x82652e8>"
+ ]
+ }
+ ],
+ "prompt_number": 123
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print\"Result: The error position code is 0111 (binary seven).This says that the bit in position 7 is in error. The corrected code is therefore 101101110.\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Result: The error position code is 0111 (binary seven).This says that the bit in position 7 is in error. The corrected code is therefore 101101110.\n"
+ ]
+ }
+ ],
+ "prompt_number": 124
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file