{
 "metadata": {
  "name": "",
  "signature": "sha256:348e913cbcf303bd30e2a0fca661cdd75a027447d5cfac9117537a9c7cb2c1c0"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter4-Alternating voltage and current"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.1\n",
      "import math\n",
      "V_m=20.;##in volts\n",
      "f=50.;##in Hz\n",
      "t1=2.5*10**-3;\n",
      "t2=15.*10**-3;\n",
      "V1=V_m*math.sin(2.*math.pi*f*t1);\n",
      "V2=V_m*math.sin(2.*math.pi*f*t2);\n",
      "print'%s %.2f %s'%(\"Voltage at 2.5ms = \",V1,\" V\");\n",
      "print'%s %.2f %s'%(\"\\n Voltage at 15ms = \",V2,\" V\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Voltage at 2.5ms =  14.14  V\n",
        "\n",
        " Voltage at 15ms =  -20.00  V\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.2\n",
      "import math\n",
      "f=400.;##in Hz\n",
      "T=1./f;\n",
      "print'%s %.2f %s %.4f %s '%(\"Time period of \",f,\" Hz\" and \" waveform = \",T,\" sec\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time period of  400.00  waveform =  0.0025  sec \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.3\n",
      "import math\n",
      "T=40.*10**-3;##in Hz\n",
      "f=1./T;\n",
      "print'%s %.2f %s'%(\"Frequency of 40 ms waveform = \",f,\" Hz\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Frequency of 40 ms waveform =  25.00  Hz\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.4\n",
      "import math\n",
      "V_rms=240.;##in Volts\n",
      "V_pk=1.414*V_rms;\n",
      "print'%s %.2f %s %.2f %s' %(\"Peak voltage of \",V_rms,\" V RMS\" and \" voltage = \",V_pk,\" V\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Peak voltage of  240.00  voltage =  339.36  V\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex5-pg71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.5\n",
      "import math\n",
      "I_pk=50.*10**-3;##in Amps\n",
      "I_rms=0.353*I_pk;\n",
      "print'%s %.2f %s'%(\"RMS current of 50mA peak current = \",I_rms,\" A\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "RMS current of 50mA peak current =  0.02  A\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex6-pg72"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.6\n",
      "import math\n",
      "V=10.;##pk-pk voltage\n",
      "r=1000.;##ohms\n",
      "I_pk=V/r;##in Amps\n",
      "I_rms=0.353*I_pk*1000.;##milliamps\n",
      "print'%s %.2f %s'%(\"RMS current of 10V peak-peak voltage = \",I_rms,\" mA\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "RMS current of 10V peak-peak voltage =  3.53  mA\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex7-pg73"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.7\n",
      "import math\n",
      "c=1.*10**-6;\n",
      "f1=100.;\n",
      "f2=10000.;\n",
      "X_c1=1./(2.*math.pi*f1*c);\n",
      "X_c2=1./(2.*math.pi*f2*c);\n",
      "print'%s %.2f %s'%(\"Reactance at 100Hz = \",X_c1,\" mA\");\n",
      "print'%s %.2f %s'%(\"\\n Reactance at 10kHz = \",X_c2,\" mA\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reactance at 100Hz =  1591.55  mA\n",
        "\n",
        " Reactance at 10kHz =  15.92  mA\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex8-pg73"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.8\n",
      "import math\n",
      "V=240.;\n",
      "c=100.*10**-9;\n",
      "f=50.;\n",
      "X_c=1./(2.*math.pi*f*c);\n",
      "I_c=V/X_c;\n",
      "print'%s %.2f %s'%(\"Current flow = \",I_c,\" A\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current flow =  0.01  A\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex9-pg74"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.9\n",
      "import math\n",
      "L=1.*10**-3;\n",
      "f1=100.;\n",
      "f2=10000.;\n",
      "X_L1=(2.*math.pi*f1*L);\n",
      "X_L2=(2.*math.pi*f2*L);\n",
      "print'%s %.2f %s'%(\"Reactance at 100Hz = \",X_L1,\" ohm\");\n",
      "print'%s %.2f %s'%(\"\\nReactance at 10kHz = \",X_L2,\" ohm\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reactance at 100Hz =  0.63  ohm\n",
        "\n",
        "Reactance at 10kHz =  62.83  ohm\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex10-pg74"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.10\n",
      "import math\n",
      "L=1.*10**-3;\n",
      "f1=100.;\n",
      "f2=10000.;\n",
      "X_L1=(2.*math.pi*f1*L);\n",
      "X_L2=(2.*math.pi*f2*L);\n",
      "print'%s %.2f %s'%(\"Reactance at 100Hz = \",X_L1,\" ohm\");\n",
      "print'%s %.2f %s'%(\"\\nReactance at 10kHz = \",X_L2,\" ohm\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reactance at 100Hz =  0.63  ohm\n",
        "\n",
        "Reactance at 10kHz =  62.83  ohm\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex11-pg74"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.11\n",
      "import math\n",
      "C=2.*10**-6;\n",
      "f=400.;\n",
      "V=115.;\n",
      "X_C=1./(2.*math.pi*f*C);\n",
      "r=199.;\n",
      "z=math.sqrt(r**2+X_C**2);\n",
      "I_s=V/z;\n",
      "print'%s %.2f %s'%(\"Reactance = \",X_C,\" ohm\");\n",
      "print'%s %.2f %s'%(\"\\n Current = \",I_s,\" A\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reactance =  198.94  ohm\n",
        "\n",
        " Current =  0.41  A\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex12-pg75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.12\n",
      "import math\n",
      "L=150.*10**-3;\n",
      "f=400.;\n",
      "V=115.;\n",
      "X_L=(2.*math.pi*f*L);\n",
      "r=250.;\n",
      "z=math.sqrt(r**2+X_L**2);\n",
      "I_s=V/z;\n",
      "print'%s %.2f %s'%(\"Reactance = \",X_L,\" ohm\");\n",
      "print'%s %.2f %s'%(\"\\n Current = \",I_s,\" A\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reactance =  376.99  ohm\n",
        "\n",
        " Current =  0.25  A\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex13-pg78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.13\n",
      "import math\n",
      "L=100.*10**-3;\n",
      "f=400.;\n",
      "C=(1./(4.*math.pi*math.pi*f*f*L))*10**6;\n",
      "print'%s %.2f %s'%(\"Capacitance required = \",C,\" uF\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacitance required =  1.58  uF\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex14-pg78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.14\n",
      "import math\n",
      "L=20.*10**-3;\n",
      "f=2000.;\n",
      "V=1.5;\n",
      "r=100.;\n",
      "C=10.*10**-9;\n",
      "X_L=(2.*math.pi*f*L);\n",
      "X_C=1./(2.*math.pi*f*C);\n",
      "z=math.sqrt(r**2+(X_L-X_C)**2);\n",
      "i=V/z;\n",
      "v=i*r;\n",
      "print'%s %.4f %s'%(\"Current supplied = \",i,\" mA\");\n",
      "print'%s %.2f %s'%(\"\\nVoltage developed = \",v,\" V\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current supplied =  0.0002  mA\n",
        "\n",
        "Voltage developed =  0.02  V\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex15-pg81"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.15\n",
      "import math\n",
      "N_s=120.;\n",
      "V_p=220.;\n",
      "N_p=2000.;\n",
      "V_s=N_s*V_p/N_p;\n",
      "print'%s %.2f %s'%(\"Secondry voltage = \",V_s,\" V\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Secondry voltage =  13.20  V\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex16-pg81"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "##Ex:4.16\n",
      "import math\n",
      "V_p=200.;\n",
      "V_s=10.;\n",
      "N_p=1200.;\n",
      "N_s=N_p*V_s/V_p;\n",
      "i_s=2.5;\n",
      "i_p=N_s*i_s/N_p;\n",
      "print'%s %.2f %s'%(\"Secondry turns =  \",N_s,\"\");\n",
      "print'%s %.2f %s'%(\"\\nprimary current = \",i_p,\"A\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Secondry turns =   60.00 \n",
        "\n",
        "primary current =  0.12 A\n"
       ]
      }
     ],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}