{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 17:DC Circuits"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.1:pg-866"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The number of electrons that pass through bulb is=\n",
      "9.375e+17\n",
      "electrons\n"
     ]
    }
   ],
   "source": [
    "#Example 17_1\n",
    " \n",
    "  \n",
    "#To find number of electrons flow through bulb\n",
    "current=0.15       #Units in C\n",
    "q=1.6*10**-19          #Units in C/electron\n",
    "noe=current/q       #Units in number of Electrons\n",
    "print \"The number of electrons that pass through bulb is=\"\n",
    "print noe\n",
    "print \"electrons\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.2:pg-867"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resistance in bulb is= 19.4  Ohms\n"
     ]
    }
   ],
   "source": [
    "#Example 17_2\n",
    " \n",
    "  \n",
    "#To find the resistance in bulb\n",
    "v=1.55    #Units in V\n",
    "i=0.08        #Units in A\n",
    "r=v/i   #Units in Ohms\n",
    "print \"The resistance in bulb is=\",round(r,1),\" Ohms\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.3:pg-867"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resistance in wire is= 0.205  Ohms\n"
     ]
    }
   ],
   "source": [
    "#Example 17_3\n",
    " \n",
    "  \n",
    "#To find the resistance in wire\n",
    "row=1.7*10**-8     #Units in Ohm meter\n",
    "l=40    #Units in meters\n",
    "a=0.0331*10**-4      #Units in meters**2\n",
    "r=(row*l)/a       #Units in Ohms\n",
    "print \"The resistance in wire is=\",round(r,3),\" Ohms\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.4:pg-868"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The appropriate resistance in wire is Ro= 26.6  Ohms\n"
     ]
    }
   ],
   "source": [
    "#Example 17_4\n",
    " \n",
    "  \n",
    "#To find the appropriate resistance of the wire\n",
    "alpha=0.0045       #Units in Centigrade**-1\n",
    "t=1780         #Units in Centigrade\n",
    "deltaR=240    #Units in Ohms\n",
    "ro=deltaR/(1+(alpha*t))    #Units in ohms\n",
    "print \"The appropriate resistance in wire is Ro=\",round(ro,1),\" Ohms\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.5:pg-868"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Heat generated in bulb is= 48000.0  J\n"
     ]
    }
   ],
   "source": [
    "#Example 17_5\n",
    " \n",
    "  \n",
    "#To find out the amount of heat developed in bulb\n",
    "t=20.0*60     #Units in sec\n",
    "pow=40.0  #Units in W\n",
    "heat=t*pow   #Units in J\n",
    "print \"Heat generated in bulb is=\",round(heat),\" J\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.6:pg-869"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cost needed to operate is= 0.035  Dollars\n"
     ]
    }
   ],
   "source": [
    "#Example 17_6\n",
    " \n",
    "  \n",
    "#To calculate the cost needed to operate\n",
    "power=0.7    #Units in KW\n",
    "time=0.5      #Units in h\n",
    "heat=power*time #Units in K Wh\n",
    "cost=0.10      #Units in Dollars\n",
    "tcost=cost*heat     #Units in Dollars\n",
    "print \"Cost needed to operate is=\",round(tcost,4),\" Dollars\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.7:pg-869"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The current in circuit is I= -0.82  A\n"
     ]
    }
   ],
   "source": [
    "#Example 17_7\n",
    " \n",
    "  \n",
    "#To find the current in circuit\n",
    "v1=3    #Units in V\n",
    "v2=12.0#Units in V\n",
    "r1=5.0   #Units in Ohms\n",
    "r2=6 #Units in Ohms\n",
    "i=(v1-v2)/(r1+r2)     #Units in A\n",
    "print \"The current in circuit is I=\",round(i,2),\" A\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.8:pg-870"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current in wire 1 is I1= 1.75  A\n",
      "Current in wire 2 is I2= -0.5  A\n",
      "Current in wire 3 is I3= 1.25  A\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#Example 17_8\n",
    " \n",
    "  \n",
    "#To find the current in all wires\n",
    "v=9 #Units in V\n",
    "r1=18.0   #Units in Ohms\n",
    "i2=-v/r1     #Units in A\n",
    "v1=6.0    #Units in V\n",
    "r2=12.0     #Units in Ohms\n",
    "i3=(v+v1)/r2          #Units in A\n",
    "i1=i3-i2     #Units in A\n",
    "print \"Current in wire 1 is I1=\",round(i1,2),\" A\\nCurrent in wire 2 is I2=\",round(i2,2),\" A\\nCurrent in wire 3 is I3=\",round(i3,2),\" A\\n\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.9:pg-871"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The current I= 2.0  A\n"
     ]
    }
   ],
   "source": [
    "#Example 17_9\n",
    " \n",
    "  \n",
    "#To find the current I in the battery\n",
    "r1=3 #Units in Ohms\n",
    "r2=6.0   #Units in Ohms\n",
    "rbc=(r1*r2)/(r1+r2)#Units in Ohms\n",
    "r3=4#Units in Ohms\n",
    "rac=r3+rbc        #Units in Ohms\n",
    "v=12.0    #Units in V\n",
    "i=v/rac        #Units in A\n",
    "print \"The current I=\",round(i),\" A\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.10:pg-872"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-10-e97062f38a8b>, line 17)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-10-e97062f38a8b>\"\u001b[1;36m, line \u001b[1;32m17\u001b[0m\n\u001b[1;33m    print \"The current in battery is I=\",round( ,2),\" A\",i)\u001b[0m\n\u001b[1;37m                                                ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "#Example 17_10\n",
    " \n",
    "  \n",
    "#To find the current in battery\n",
    "r1=3 #Units in Ohms\n",
    "r2=6   #Units in Ohms\n",
    "ra=(r1*r2)/(r1+r2)#Units in Ohms\n",
    "r3=2        #Units in Ohms\n",
    "r4=4    #Units in Ohms\n",
    "rb=r3+r4       #Units in Ohms\n",
    "r5=6          #Units in Ohms\n",
    "rc=(r5*rb)/(r5+rb)   #Units in Ohms\n",
    "r6=9           #Units in Ohms\n",
    "r=r6+rc          #Units in Ohms\n",
    "v=6              #Units in V\n",
    "i=v/r               #Units in Ohms\n",
    "print \"The current in battery is I=\",round( ,2),\" A\",i)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.11:pg-872"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current in wire 1 is I1= 1.2  A\n",
      "Current in wire 2 is I2= 0.6  A\n",
      "Current in wire 3 is I3= 0.6  A\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#Example 17_11\n",
    " \n",
    "  \n",
    "#To find the current in the wires\n",
    "v1=12.0          #Units in V\n",
    "r3=20.0       #Units in Ohms\n",
    "v2=6        #Units in V\n",
    "r2=10.0     #Units in Ohms\n",
    "r1=5    #Units in Ohms\n",
    "i3=((v1*r3)-(v2*r1))/((r2*r3)+(r1*r3)+(r1*r2))        #Units in A\n",
    "i2=((r2*i3)+v2)/r3           #Units in A\n",
    "i1=i3+i2        #Units in A\n",
    "print \"Current in wire 1 is I1=\",round(i1,1),\" A\\nCurrent in wire 2 is I2=\",round(i2,1),\" A\\nCurrent in wire 3 is I3=\",round(i3,1),\" A\\n\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.12:pg-873"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current in wire 1 is I1= 0.667  A\n",
      "Current in wire 2 is I2= 0.444  A\n",
      "Current in wire 3 is I3= -0.222  A\n",
      "\n"
     ]
    }
   ],
   "source": [
    "#Example 17_12\n",
    " \n",
    "  \n",
    "#To find I1, I2 and I3 in the circuit\n",
    "v1=40      #Units in V\n",
    "r1=10.0         #Units in Ohms\n",
    "r2=30.0         #Units in Ohms\n",
    "v2=60.0   #Units in V\n",
    "r3=15.0      #Units in Ohms\n",
    "v3=50      #Units in V\n",
    "i1=((-v1*r2)+(-r3*v1)+(60*r3)+(v3*r2))/((r1*r2)+(r2*r3)+(r3*r1))    #Units in A\n",
    "i=2         #Units in A\n",
    "i2=(i-i1)/3        #Units in A\n",
    "i3=i2-i1        #Units in A\n",
    "print \"Current in wire 1 is I1=\",round(i1,3),\" A\\nCurrent in wire 2 is I2=\",round(i2,3),\" A\\nCurrent in wire 3 is I3=\",round(i3,3),\" A\\n\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.13:pg-874"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " The current I= 2.5  A\n",
      " Resistance is R= 20.0  Ohms\n",
      " The value E is= 41.0  V\n"
     ]
    }
   ],
   "source": [
    "#Example 17_13\n",
    " \n",
    "  \n",
    "#To find the values of e, R and I\n",
    "i1=2      #Units in A\n",
    "i2=0.5        #Units in A\n",
    "i=i1+i2    #Units in A\n",
    "v1=6 #Units in V\n",
    "v2=16.0       #Units in V\n",
    "r=-(v1-v2)/0.5      #Units in Ohms\n",
    "v3=25.0    #Units in V\n",
    "e=v2+v3         #Units in V\n",
    "print \" The current I=\",round(i,1),\" A\\n Resistance is R=\",round(r),\" Ohms\\n The value E is=\",round(e),\" V\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.14:pg-874"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Current in wire 1 is I1= 2.0  A\n",
      "Current in wire 2 is I2= 4.0  A\n",
      "Current in wire 3 is I3= 2.0  A\n",
      "\n",
      "The charge on the capacitor is q= 1e-05  C\n"
     ]
    }
   ],
   "source": [
    "#Example 17_14\n",
    " \n",
    "  \n",
    "#To find the I1,I2,I3 values and charge on the capacitor\n",
    "v1=12.0     #Units in V\n",
    "r1=6.0     #Units in Ohms\n",
    "i1=v1/r1     #Units in A\n",
    "v2=4.0       #Units in V\n",
    "r2=8.0      #Units in Ohms\n",
    "i3=(v1+v2)/r2        #Units in A\n",
    "i2=i1+i3         #Units in A\n",
    "print \"Current in wire 1 is I1=\",round(i1),\" A\\nCurrent in wire 2 is I2=\",round(i2),\" A\\nCurrent in wire 3 is I3=\",round(i3),\" A\\n\"\n",
    "v3=10.0               #Units in V\n",
    "vfg=-v3+(r1*i1)         #Units in V\n",
    "c=5*10**-6               #Units in F\n",
    "q=c*vfg                 #Units in C\n",
    "print \"The charge on the capacitor is q=\",round(q,5),\" C\"   \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.15:pg-874"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Potential difference between d to c is= 23.8  V\n",
      "\n",
      "The potential difference between b to a is= 7.8  V\n"
     ]
    }
   ],
   "source": [
    "#Example 17_15\n",
    " \n",
    "  \n",
    "#To find the terminal potential of each battery\n",
    "v=18        #Units in V\n",
    "r=9          #Units in Ohms\n",
    "i=v/r      #Units in A\n",
    "r1=0.1    #Units in Ohms\n",
    "v1=-i*r1     #Units in V\n",
    "v2=24      #Units in V\n",
    "v11=v1+v2       #Units in V\n",
    "r2=0.9      #Units in Ohms\n",
    "v3=i*r2    #Units in V\n",
    "v4=6        #Units in V\n",
    "v22=v3+v4     #Units in V   \n",
    "print \"The Potential difference between d to c is=\",round(v11,1),\" V\"\n",
    "print \"\\nThe potential difference between b to a is=\",round(v22,1),\" V\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ex17.16:pg-875"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The resistance of the recording device is= 1000000.0  Ohms\n"
     ]
    }
   ],
   "source": [
    "#Example 17_16\n",
    " \n",
    "  \n",
    "#To findout how large a a resistance must the recording device must have\n",
    "r1=10000.0        #Units in Ohms\n",
    "percent=1.0          #Units in Percentage \n",
    "vo=1/(r1*(percent*100))      #Units In terms of Ro\n",
    "Ro=1/vo        #Units in Ohms\n",
    "print \"The resistance of the recording device is=\",round(Ro),\" Ohms\"\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}