{
 "metadata": {
  "name": "",
  "signature": "sha256:945006863c63304cbc544f24dfb80d480d54472bf41be8526d524f28a1051fc0"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 19 - Digital Electronics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E1 - Pg 957"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_1 Pg-957 \n",
      "#calculate decimal equivqlent of 101\n",
      "a=\"101\"\n",
      "b=int(a,base=2)\n",
      "print'%s %.f'%(\"The decimal equivqlent of 101 is\",b)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The decimal equivqlent of 101 is 5\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E2 - Pg 958"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_2 Pg-958\n",
      "#decimal equivqlent of 11101\n",
      "bina='11101'; #binary input\n",
      "dec=int(bina,base=2) #decimal output\n",
      "print(\"The decimal equivqlent of 11101 is\")\n",
      "print(dec)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The decimal equivqlent of 11101 is\n",
        "29\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E3 - Pg 958"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_3 Pg-958\n",
      "#decimal equivqlent of 0.101\n",
      "a=1\n",
      "b=0\n",
      "c=1\n",
      "dec=a*2**(-1)+b*2**(-2)+c*2**(-3) #decimal output\n",
      "print(\"The decimal equivqlent of 0.101 is\")\n",
      "print(dec)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The decimal equivqlent of 0.101 is\n",
        "0.625\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E4 - Pg 958"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_4 Pg-958\n",
      "#The decimal equivqlent of 0.1101\n",
      "a=1\n",
      "b=1\n",
      "c=0\n",
      "d=1\n",
      "dec=a*2**(-1)+b*2**(-2)+c*2**(-3)+d*2**(-4) #decimal output\n",
      "print(\"The decimal equivqlent of 0.1101 is\")\n",
      "print(dec)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The decimal equivqlent of 0.1101 is\n",
        "0.8125\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E5 - Pg 958"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_5 Pg-958 \n",
      "# decimal equivqlent of 10101.101\n",
      "#Integer part\n",
      "bina='10101'; #binary input\n",
      "dec_I=int(bina,base=2) #decimal output\n",
      "\n",
      "#Decimal part\n",
      "a=1\n",
      "b=0\n",
      "c=1\n",
      "dec_D=a*2**(-1)+b*2**(-2)+c*2**(-3)\n",
      "dec=dec_I+dec_D #decimal output\n",
      "print(\"The decimal equivqlent of 10101.101 is\")\n",
      "print(dec)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The decimal equivqlent of 10101.101 is\n",
        "21.625\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E6 - Pg 959"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_6 Pg-959\n",
      "#binary equivalent of 9\n",
      "dec=9 #decimal input\n",
      "bina=bin(dec) #binary output\n",
      "print(\"The binary equivalent of 9 is\")\n",
      "print(bina)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The binary equivalent of 9 is\n",
        "0b1001\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E7 - Pg 959"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_7 Pg-959 \n",
      "#binary equivalent of 31\n",
      "dec=31 #decimal input\n",
      "bina=bin(dec) #binary output\n",
      "print(\"The binary equivalent of 31 is\")\n",
      "print(bina)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The binary equivalent of 31 is\n",
        "0b11111\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E8 - Pg 959"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_8 Pg-959 \n",
      "#binary equivalent of 13\n",
      "dec=13 #decimal input\n",
      "bina=bin(dec) #binary output\n",
      "print(\"The binary equivalent of 13 is\")\n",
      "print(bina)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The binary equivalent of 13 is\n",
        "0b1101\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E9 - Pg 960"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_9 Pg-960\n",
      "#Conversion of decimal number 31.65 base to its binary equivalent\n",
      "import math\n",
      "print(\"Conversion of decimal number 31.65 base to its binary equivalent \")\n",
      "a=31.65;\n",
      "z=a%1\n",
      "x=math.floor(a);#separating the decimal from the integer part\n",
      "b=0;\n",
      "c=0;\n",
      "d=0;\n",
      "while(x>0):  #taking integer part into a matrix and convert to equivalent binary\n",
      "\ty=x%2;\n",
      "\tb=b+(10**c)*y;\n",
      "\tx=x/2.;\n",
      "\tx=math.floor(x);\n",
      "\tc=c+1;\n",
      "\n",
      "for i in range(1,10):#converting the values after the decimal point into binary\n",
      "    z=z*2;\n",
      "    q=math.floor(z);\n",
      "    d=d+q/(10**i);\n",
      "    if z>=1:\n",
      "    \tz=z-1;\n",
      "\n",
      "s=b+d;\n",
      "print s\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Conversion of decimal number 31.65 base to its binary equivalent \n",
        "11111.1010011\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E10 - Pg 961"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_10 Pg-961\n",
      "#Calculate the decimal equivqlent of 1111 and 1111111\n",
      "a1=\"1111\"\n",
      "b1=int(a1,base=2)\n",
      "print'%s %.f'%(\"(a)The decimal equivqlent of 1111 is\",b1)\n",
      "a2=\"1111111\"\n",
      "b2=int(a2,base=2)\n",
      "print'%s %.f'%(\"(b)The decimal equivqlent of 1111111 is\",b2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)The decimal equivqlent of 1111 is 15\n",
        "(b)The decimal equivqlent of 1111111 is 127\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E11 - Pg 962"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_11 Pg-962 \n",
      "#calculate The decimal equivqlent of 23\n",
      "a=\"23\"\n",
      "b=int(a,base=8)\n",
      "print'%s %.f'%(\"The decimal equivqlent of 23 is =\",b)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The decimal equivqlent of 23 is = 19\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E12 - Pg 962"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_12 Pg-962 \n",
      "#calculate The decimal equivqlent of 23\n",
      "a=\"257\"\n",
      "b=int(a,base=8)\n",
      "print'%s %.f'%(\"The decimal equivqlent of 257 is =\",b)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The decimal equivqlent of 257 is = 175\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E13 - Pg 962"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_13 Pg-962 \n",
      "#calculate The octal equivqlent of 257\n",
      "a=\"175\"\n",
      "b=oct(175)\n",
      "print b\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "0257\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E14 - Pg 963"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_14 Pg-963\n",
      "#calculate the octal equivalent of 0.85\n",
      "a=.85\n",
      "b=.5\n",
      "octal=int(a*8.) \n",
      "octal2=int(b*64.)\n",
      "print 'In octal representation it is .',octal,octal2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "In octal representation it is . 6 32\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E15 - Pg 963"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_15 Pg-963\n",
      "a='34' #octal input\n",
      "b=int(a,base=8) #decimal output\n",
      "print b"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "28\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E16 - Pg 963"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_16 Pg-963\n",
      "x='357'\n",
      "decimal=int(x,base=8) #to convert octal to decimal\n",
      "binary=bin(decimal) #to convert binary to decimal\n",
      "print 'In decimal=',decimal\n",
      "print'In binary = ',binary"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "In decimal= 239\n",
        "In binary =  0b11101111\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E17 - Pg 963"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_17 Pg-963\n",
      "#Integer part\n",
      "bina='1011'; #binary input\n",
      "dec_I=int(bina,base=2) #decimal output\n",
      "oct_I=oct(dec_I) #octal output\n",
      "\n",
      "#Decimal part\n",
      "bina2='11010'; #binary input\n",
      "dec_D=int(bina2,base=2) #decimal output\n",
      "oct_D=oct(dec_D) #octal output\n",
      "octa=oct_I + oct_D #final octal output\n",
      "b = ([oct_I, oct_D ]) # combining intger and decimal part\n",
      "print(\"The octal equivqlent of 1011.01101 is\")\n",
      "print(b)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The octal equivqlent of 1011.01101 is\n",
        "['013', '032']\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E18 - Pg 965"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_18 Pg-965\n",
      "hexa='9AF' #hexadecimal input\n",
      "dec=int(hexa,base=16) #decimal output\n",
      "bina=bin(dec) #binary output\n",
      "print(\"The binary equivalent of 9AF is\")\n",
      "print(bina)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The binary equivalent of 9AF is\n",
        "0b100110101111\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E19 - Pg 965"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_19 Pg-965\n",
      "hexa='C5E2' #hexadecimal input\n",
      "dec=int(hexa,base=16) #decimal output\n",
      "bina=bin(dec) #binary output\n",
      "print(\"The binary equivalent of C5E2 is\")\n",
      "print(bina)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The binary equivalent of C5E2 is\n",
        "0b1100010111100010\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E20 - Pg 957"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_20 Pg-957 \n",
      "bina='10001100'; #binary input\n",
      "dec=int(bina,base=2) #decimal output\n",
      "hexa=hex(dec) #hexadecimal output\n",
      "print(\"The hexadecimal equivqlent of 10001100 is\")\n",
      "print(hexa)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The hexadecimal equivqlent of 10001100 is\n",
        "0x8c\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E21 - Pg 965"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_21 Pg-965\n",
      "#Integer part\n",
      "hexa='F8E6'; #binary input\n",
      "dec_I=int(hexa,base=16) #decimal output\n",
      "\n",
      "#Decimal part\n",
      "a=3 \n",
      "b=9\n",
      "dec=dec_I+a*16**(-1)+b*16**(-2) #decimal output \n",
      "print(\"The decimal equivalent of F8E6.39 is\")\n",
      "print(dec)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The decimal equivalent of F8E6.39 is\n",
        "63718.2226562\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E22 - Pg 996"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_22 Pg-966\n",
      "dec=2479 #decimal input\n",
      "hexa=hex(dec) #hexadecimal output\n",
      "print(\"The Hexadecimal equivalent of 2479 is\")\n",
      "print(hex)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Hexadecimal equivalent of 2479 is\n",
        "<built-in function hex>\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E23 - Pg 966"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_23 Pg-966\n",
      "dec=65535 #decimal input\n",
      "hexa=hex(dec) #hexadecimal output\n",
      "print(\"The Hexadecimal equivalent of 65535 is\")\n",
      "print(hexa)\n",
      "\n",
      "bina=bin(dec) #binary output\n",
      "print(\"The Binary equivalent of 65535 is \")\n",
      "print(bina)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Hexadecimal equivalent of 65535 is\n",
        "0xffff\n",
        "The Binary equivalent of 65535 is \n",
        "0b1111111111111111\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E24 - Pg 969"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_24 Pg-969\n",
      "x=int('11100',2) #1st input\n",
      "y=int('11010',2) #2nd input\n",
      "z=x+y #binary addition\n",
      "add=bin(z)\n",
      "print(\" 11100 + 11010 = \")\n",
      "print(add)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " 11100 + 11010 = \n",
        "0b110110\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E25 - Pg 970"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_25 Pg-970\n",
      "x=int('1101',2) #1st input\n",
      "y=int('1010',2) #2nd input\n",
      "z=x-y #subtraction\n",
      "sub=bin(z)\n",
      "print(\"1101-1010 =\")\n",
      "print(sub)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1101-1010 =\n",
        "0b11\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E26 - Pg 970"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_26 Pg-970\n",
      "x=200 #1st input\n",
      "y=125 #2nd input\n",
      "z=x-y #subtraction\n",
      "print(\"For decimal system 200 - 125 = \")\n",
      "print(z)\n",
      "\n",
      "a=hex(z) #hexadeciaml output of 200-125\n",
      "print(\"For hexadecimal system C8 - 7D is\")\n",
      "print(a)\n",
      "\n",
      "b=bin(z) #binary output of 200-125\n",
      "print(\"For binary system 11001000 - 01111101 is\")\n",
      "print(b)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For decimal system 200 - 125 = \n",
        "75\n",
        "For hexadecimal system C8 - 7D is\n",
        "0x4b\n",
        "For binary system 11001000 - 01111101 is\n",
        "0b1001011\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E27 - Pg 997"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_27 Pg-997\n",
      "print(\"(A+B)(A+C) = AA + AC + AB + BC \")\n",
      "#by distributive law\n",
      "print(\"           = A + AC + AB +BC\")\n",
      "#by theorem(6)\n",
      "print(\"           = A(1 + C) + AB + BC\")\n",
      "#by distributive law\n",
      "print(\"           = A.1 + AB + BC \")\n",
      "#by theorem(3)\n",
      "print(\"           = A(B + 1) + BC\")\n",
      "#by distributive law\n",
      "print(\"           = A + BC\")\n",
      "print(\"Therefore (A+B)(A+C) = A + BC\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(A+B)(A+C) = AA + AC + AB + BC \n",
        "           = A + AC + AB +BC\n",
        "           = A(1 + C) + AB + BC\n",
        "           = A.1 + AB + BC \n",
        "           = A(B + 1) + BC\n",
        "           = A + BC\n",
        "Therefore (A+B)(A+C) = A + BC\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E28 - Pg 998"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_28 Pg-998\n",
      "print(\"AB + A(B + C) + B(B + C)  = AB + AB + AC + BB + BC\")\n",
      "#using distributive law\n",
      "print(\"                          = AB + AC + B +BC      \")\n",
      "#using law 6\n",
      "print(\"                          = AB + AC + B(1 + C)  \")\n",
      "#taking common B from B + BC \n",
      "print(\"                          = AB + AC + B\")\n",
      "#using law 7 \n",
      "print(\"                          = B(A + 1) + AC\")\n",
      "#taking common B from AB + B\n",
      "print(\"                          = B + AC\")\n",
      "#using law 7\n",
      "print(\"Therefore AB + A(B + C) + B(B + C) = B + AC\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "AB + A(B + C) + B(B + C)  = AB + AB + AC + BB + BC\n",
        "                          = AB + AC + B +BC      \n",
        "                          = AB + AC + B(1 + C)  \n",
        "                          = AB + AC + B\n",
        "                          = B(A + 1) + AC\n",
        "                          = B + AC\n",
        "Therefore AB + A(B + C) + B(B + C) = B + AC\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E30 - Pg 998"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_30 Pg-998\n",
      "# question in the textbook is wrong7 \n",
      "print(\"LHS : (A + B + C)(A + B + C) \")\n",
      "print(\"        = AA + AB + AC + BA + BB +BC + CA + CB + CC\")\n",
      "#using distributive law\n",
      "print(\"        = A + AB + AC + BA + B +BC + CA + CB + C\")\n",
      "#using law 6\n",
      "print(\"        = A + AB + AC +BC + CB + C\")\n",
      "#using law 5\n",
      "print(\"        = A(B + 1) + AC + B + C(B + 1)\")\n",
      "#taking A common from A+AB and C from CB+C\n",
      "print(\"        = A + AC + B + C\")\n",
      "#using law 3\n",
      "print(\"        = A + B + C(A + 1)\")\n",
      "#taking common C from AC+C\n",
      "print(\"        = A + B + C\")\n",
      "#using law 3\n",
      "print(\"Therefore (A'' + B + C)(A'' + B'' + C) = A'' + C\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "LHS : (A + B + C)(A + B + C) \n",
        "        = AA + AB + AC + BA + BB +BC + CA + CB + CC\n",
        "        = A + AB + AC + BA + B +BC + CA + CB + C\n",
        "        = A + AB + AC +BC + CB + C\n",
        "        = A(B + 1) + AC + B + C(B + 1)\n",
        "        = A + AC + B + C\n",
        "        = A + B + C(A + 1)\n",
        "        = A + B + C\n",
        "Therefore (A'' + B + C)(A'' + B'' + C) = A'' + C\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E31 - Pg 999"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Ex19_31 Pg-999\n",
      "print(\"LHS : (A+ C)(A'' + B) \")\n",
      "print(\"         = AA'' + AB + CA'' + BC\") #using distributive law\n",
      "print(\"         = 0 + AB + CA'' + BC\") #using law 8\n",
      "print(\"         = AB + (A + A'')BC + CA''\") #using law 7\n",
      "print(\"         = AB + ABC + A''BC + CA''\") \n",
      "#using distributive law\n",
      "print(\"         = AB + ABC + A''C(B + 1)\") \n",
      "#taking common A'C from A'BC + CA'\n",
      "print(\"         = AB + ABC + A''C\") #using law 3\n",
      "print(\"         = AB(C + 1)+ A''C\") \n",
      "#taking common AB from AB + ABC\n",
      "print(\"         = AB + A''C\") #using law 3\n",
      "print(\"Therefore (A+ C)(A'' + B) = AB + A''C\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "LHS : (A+ C)(A'' + B) \n",
        "         = AA'' + AB + CA'' + BC\n",
        "         = 0 + AB + CA'' + BC\n",
        "         = AB + (A + A'')BC + CA''\n",
        "         = AB + ABC + A''BC + CA''\n",
        "         = AB + ABC + A''C(B + 1)\n",
        "         = AB + ABC + A''C\n",
        "         = AB(C + 1)+ A''C\n",
        "         = AB + A''C\n",
        "Therefore (A+ C)(A'' + B) = AB + A''C\n"
       ]
      }
     ],
     "prompt_number": 32
    }
   ],
   "metadata": {}
  }
 ]
}