{
 "metadata": {
  "name": "",
  "signature": "sha256:d510303f7e7e2853fb2cf56867915796aa62fb3bbb679ce357903afade2bd69c"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 1: Fundamentals"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.1, Page 3"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "I =.000018;    # Electric current, A\n",
      "V = 15000;    # Electric potential, V\n",
      "P = 250000000    # Electric Power, W\n",
      "\n",
      "#Calculations&Results\n",
      "# Display standard form \n",
      "print \"Standard form:\"\n",
      "print \"==============\"\n",
      "print \"%f A = %3.1e A\"%(I, I)\n",
      "print \"%5.0f V = %3.1e V\"%(V, V)\n",
      "print \"%9.0f W = %3.1e W\"%(P, P)\n",
      "# Display scientific notation \n",
      "print \"\\n\\nScientific form:\"\n",
      "print \"================\"\n",
      "print \"%f A = %2d micro-ampere\"%(I, I/1e-06)\n",
      "print \"%5.0f V = %2d kilo-volt\"%(V, V/1e+03)\n",
      "print \"%9.0f W = %3d mega-watt\"%(P, P/1e+06)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Standard form:\n",
        "==============\n",
        "0.000018 A = 1.8e-05 A\n",
        "15000 V = 1.5e+04 V\n",
        "250000000 W = 2.5e+08 W\n",
        "\n",
        "\n",
        "Scientific form:\n",
        "================\n",
        "0.000018 A = 18 micro-ampere\n",
        "15000 V = 15 kilo-volt\n",
        "250000000 W = 250 mega-watt\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.2, Page 3"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "I = 25e-05;    # Electric Current,A\n",
      "P = 3e-04;    # Electric Power, W\n",
      "W = 850000.;    # Work done, J\n",
      "V = 0.0016;    # Electric Potential, V\n",
      "\n",
      "#Calculations&Results\n",
      "print \"Scientific (Engineering) notation:\";\n",
      "print \"===================================\";\n",
      "print \"%2e A = %3d micro-ampere = %3.2f mA\"%(I, I/1e-06, I/1e-03);\n",
      "print \"%1.0e W = %.e milli-watt\"%(P, P/1e-03);\n",
      "print \"%6d J = %3d kJ = %3.2f MJ\"%(W, W/1e+03, W/1e+06);\n",
      "print \"%5.4f V = %3.1f milli-volt\"%(V, V/1e-03)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Scientific (Engineering) notation:\n",
        "===================================\n",
        "2.500000e-04 A = 250 micro-ampere = 0.25 mA\n",
        "3e-04 W = 3e-01 milli-watt\n",
        "850000 J = 850 kJ = 0.85 MJ\n",
        "0.0016 V = 1.6 milli-volt\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3, Page 5"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "m = 750/1e+03;    # Mass of the body, kg\n",
      "F = 2;    # Force acting on the mass, N\n",
      "\n",
      "#Calculations\n",
      "# Since F = m * a, (Newton's Second Law of motion), solving for a\n",
      "a = F/m;    # Acceleration produced in the body, metre per second square\n",
      "\n",
      "# Result\n",
      "print \"The acceleration produced in the body = %5.3f metre per second square\"%a\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The acceleration produced in the body = 2.667 metre per second square\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.4, Page 9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Q = 35e-03;    # Electric charge, C\n",
      "t = 20e-03;    # Time for transference of charge between two points, s\n",
      "\n",
      "#Calculations\n",
      "# Since Q = I * t, solving for I\n",
      "I = Q/t;    # Electric current flowing between the two points, A\n",
      "\n",
      "# Result\n",
      "print \"The value of electric current flowing = %4.2f A\"%I\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of electric current flowing = 1.75 A\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5, Page 9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "I = 120e-06;    # Electric current, A\n",
      "t = 15;    # Time for transference of charge between two points, s\n",
      "\n",
      "#Calculations\n",
      "# Since I = Q/t, solving for Q\n",
      "Q = I*t;    # Electric charge transferred, C\n",
      "\n",
      "# Result\n",
      "print \"The value of electric charge transferred = %3.1f mC\"%(Q/1e-03)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of electric charge transferred = 1.8 mC\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.6, Page 10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Q = 80;     # Electric charge, C\n",
      "I = 0.5;     # Electric current, A\n",
      "\n",
      "#Calculations\n",
      "# Since Q = I*t, solving for t\n",
      "t = Q/I;     # Time for transference of charge between two points, s\n",
      "\n",
      "# Result\n",
      "print \"The duration of time for which the current flowed = %3d s\"%t\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The duration of time for which the current flowed = 160 s\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.7, Page 13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "I = 5.5e-03;        # Electric current, A\n",
      "R = 33000;          # Resistance, ohms\n",
      "\n",
      "#Calculations\n",
      "# From Ohm's law, V = I*R\n",
      "V = I*R;            # Potential difference across resistor, V\n",
      "\n",
      "# Result\n",
      "print \"The potential difference developed across resistor = %5.1f V\"%V\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The potential difference developed across resistor = 181.5 V\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.8, Page 14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "V = 24.;            # Potential difference,V\n",
      "R = 15;             # Resistance, ohms\n",
      "\n",
      "#Calculations\n",
      "# From Ohm's law, V = I*R, then solving for I\n",
      "I = V/R;             # Electric current, A\n",
      "\n",
      "# Result\n",
      "print \"The current flowing through the resistor = %3.1f A\"%I\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The current flowing through the resistor = 1.6 A\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.9, Page 16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "E = 6;           # E.m.f of battery, V\n",
      "r = 0.15;        # Internal resistance of battery, ohm\n",
      "I_1 = .5;        # Electric current, A\n",
      "I_2 = 2;          # Electric current, A\n",
      "I_3 = 10;          # Electric current, A\n",
      "\n",
      "#Calculations\n",
      "# Using relation V = E - I*R and substituting the values of I_1, I_2 and I_3 one by one in it\n",
      "V_1 = E - I_1*r;     # Terminal potential difference, V\n",
      "V_2 = E - I_2*r;      # Terminal potential difference, V\n",
      "V_3 = E - I_3*r;       # Terminal potential difference, V\n",
      "\n",
      "# Results\n",
      "print \"The terminal potential difference developed across resistor for a current of %3.1f A = %5.3f V\"%(I_1,V_1)\n",
      "print \"The terminal potential difference developed across resistor for a current of %1d A = %3.1f V\"%(I_2,V_2)\n",
      "print \"The terminal potential difference developed across resistor for a current of %2d A = %3.1f V\"%(I_3,V_3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The terminal potential difference developed across resistor for a current of 0.5 A = 5.925 V\n",
        "The terminal potential difference developed across resistor for a current of 2 A = 5.7 V\n",
        "The terminal potential difference developed across resistor for a current of 10 A = 4.5 V\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.10, Page 16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "E = 12;        # E.m.f, V\n",
      "I = 5;         # Electric current, A\n",
      "V = 11.5;       # Terminal potential difference, V\n",
      "\n",
      "#Calculations\n",
      "# Using relation V = E - I*r, solving for r\n",
      "r = ( E - V )/I;     # Internal resistance of battery, ohm\n",
      "# From Ohm's law, V = I*R, then solving for R\n",
      "R = V/I;              # Resistance, ohms\n",
      "\n",
      "# Results\n",
      "print \"The internal resistance of battery = %3.1f ohm\"%r\n",
      "print \"The resistance of external circuit = %3.1f ohm\"%R\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The internal resistance of battery = 0.1 ohm\n",
        "The resistance of external circuit = 2.3 ohm\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.11, Page 17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "I = 200e-03;       # Electric current, A\n",
      "t = 300;            # Time for which current flows, s\n",
      "R = 750;            # Resistance, ohms\n",
      "\n",
      "#Calculations\n",
      "# Using Ohm's law, V = I*R\n",
      "V = I*R;            # Electric potential difference, V\n",
      "W = I**2*R*t;         # Energy dissipated, joule\n",
      "\n",
      "# Result\n",
      "print \"The potential difference developed across the resistor = %3d V\\nThe energy dissipated across the resistor = %4.0f J or %1d kJ\"%(V, W, W*1e-03)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The potential difference developed across the resistor = 150 V\n",
        "The energy dissipated across the resistor = 9000 J or 9 kJ\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.12, Page 18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "R = 680;          # Resistance, ohms\n",
      "P = 85e-03;           # Electric power, W\n",
      "\n",
      "#Calculations\n",
      "# Using P = V**2/R, solving for V\n",
      "V = math.sqrt( P*R );       # Potential difference, V\n",
      "# Using P = I**2*R, solving for I\n",
      "I = math.sqrt( P/R );        # Electric current, A\n",
      "\n",
      "# Result\n",
      "print \"The potential difference developed across the resistance = %3.1f V\\nThe current flowing through the resistor = %5.2f mA\"%(V, I/1e-03)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The potential difference developed across the resistance = 7.6 V\n",
        "The current flowing through the resistor = 11.18 mA\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.13, Page 19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "I = 1.4;           # Electric current, A\n",
      "t = 900;           # Time for which current flows, s\n",
      "W = 200000;        # Energy dissipated, J\n",
      "\n",
      "#Calculations\n",
      "# Using relation W = V*I*t, solving for V\n",
      "V = W/( I*t );       # Potential difference, V\n",
      "# Using relation P = V*I\n",
      "P = V*I;             # Electric power, W\n",
      "# From Ohm's law, V = I*R, solving for R\n",
      "R = V/I;              # Resistance, ohm\n",
      "\n",
      "# Result\n",
      "print \"The potential difference developed = %5.1f V\\nThe power dissipated = %5.1f W\\nThe resistance of the circuit = %5.1f ohm\"%(V, P, R)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The potential difference developed = 158.7 V\n",
        "The power dissipated = 222.2 W\n",
        "The resistance of the circuit = 113.4 ohm\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14, Page 20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "P = 12.5;    # Power of the machine, kW\n",
      "t = 8.5;    # Time for which the machine is operated, h\n",
      "\n",
      "#Calculations\n",
      "W = P*t;         # Electric energy, kWh\n",
      "# Cost per unit = 7.902 p, therefore calculating the cost of 106.25 units\n",
      "cost = ( W*7.902 );       # Cost for operating machine, p\n",
      "\n",
      "# Result\n",
      "print \"The cost of operating the machine = %4.2f pounds\"%(cost*1e-02)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The cost of operating the machine = 8.40 pounds\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15, Page 20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Total_bill = 78.75;      # pounds\n",
      "Standing_charge = 15.00;     # pounds\n",
      "Units_used = 750;            # kWh\n",
      "\n",
      "#Calculations\n",
      "Cost_per_unit = ( Total_bill - Standing_charge )/Units_used;      # p\n",
      "Cost_of_energy_used = 67.50;         # pounds\n",
      "Total_bill = Cost_of_energy_used + Standing_charge;      # pounds\n",
      "\n",
      "# Result\n",
      "print \"The cost per unit = %5.3f pounds or %3.1f p\\nTotal bill = %5.2f pounds\"%(Cost_per_unit,Cost_per_unit/1e-02,Total_bill)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The cost per unit = 0.085 pounds or 8.5 p\n",
        "Total bill = 82.50 pounds\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.16, Page 22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "l = 200;          # Length of Cu wire, metre\n",
      "rho = 2e-08;       # Resistivity of Cu, ohm-metre\n",
      "A = 8e-07;          # Cross sectional area of Cu wire, metre square\n",
      "\n",
      "#Calculations\n",
      "# Using relation R = ( rho*l )/A\n",
      "R = ( rho*l )/A;          # Resistance, ohm\n",
      "\n",
      "# Result\n",
      "print \"The resistance of the coil = %1d ohm\"%R\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance of the coil = 5 ohm\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.17, Page 22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "l = 250;          # Length of Cu wire, metre\n",
      "d = 5e-04;         # Diameter of Cu wire, metre\n",
      "rho = 1.8e-08;       # Resistivity of Cu wire, ohm-metre\n",
      "\n",
      "#Calculations\n",
      "A = (math.pi*d**2 )/4;          # Cross sectional area of Cu wire, metre square\n",
      "# Using relation R = rho*l/A\n",
      "R = rho*l/A;          # Resistance, ohm\n",
      "\n",
      "# Result\n",
      "print \"The resistance of the coil = %5.2f ohm\"%R\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance of the coil = 22.92 ohm\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.18, Page 23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "R_1 = 250;           # Resistance of field coil, ohm\n",
      "Theta_1 = 15;        # Initial temperature of motor, degree celcius \n",
      "Theta_2 = 45;        # Final temperature of motor, degree celcius\n",
      "Alpha = 4.28e-03;     # Temperature coefficient of resistance, per degree celcius\n",
      "\n",
      "#Calculations\n",
      "# Using relation, R_1/R_2 = ( 1 + Alpha*Theta_1 )/( 1 + Alpha*Theta_2 ), solving for R_2\n",
      "R_2 = R_1 * (( 1 + Alpha*Theta_2 )/( 1 + Alpha*Theta_1 ));      # Resistance, ohms\n",
      "\n",
      "# Result\n",
      "print \"The resistance of field coil at %2d degree celcius = %5.1f ohm\"%(Theta_2, R_2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance of field coil at 45 degree celcius = 280.2 ohm\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.19, Page 24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "R_0 = 350;           # Resistance, ohms\n",
      "Theta_1 = 60;        # Temperature, degree celcius \n",
      "Alpha = 4.26e-03;     # Temperature coefficient, per degree celcius\n",
      "\n",
      "#Calculations\n",
      "# Using relation R_1 = R_0 * ( 1 + Alpha*Theta_1 )\n",
      "R_1 = R_0 * ( 1 + Alpha*Theta_1 );      # Resistance, ohms\n",
      "\n",
      "# Result\n",
      "print \"The resistance of the wire at %2d degree celcius = %5.1f ohm\"%(Theta_1, R_1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance of the wire at 60 degree celcius = 439.5 ohm\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.20, Page 24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "R_1 = 120;           # Resistance, ohms\n",
      "Theta_1 = 16;        # Temperature, degree celcius \n",
      "Theta_2 = 32;        # Temperature, degree celcius\n",
      "Alpha = -4.8e-04;     # Temperature coefficient, per degree celcius\n",
      "\n",
      "#Calculations\n",
      "# Using relation, R_1/R_2 = ( 1 + Alpha*Theta_1 )/( 1 + Alpha*Theta_2 ), solving for R_2\n",
      "R_2 = R_1 * (( 1 + Alpha*Theta_2 )/( 1 + Alpha*Theta_1 ));      # Resistance, ohm\n",
      "\n",
      "# Result\n",
      "print \"The resistance of carbon resistor at %2d degree celcius = %5.1f ohm\"%(Theta_2, R_2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The resistance of carbon resistor at 32 degree celcius = 119.1 ohm\n"
       ]
      }
     ],
     "prompt_number": 20
    }
   ],
   "metadata": {}
  }
 ]
}