diff options
author | Thomas Stephen Lee | 2015-08-28 16:53:23 +0530 |
---|---|---|
committer | Thomas Stephen Lee | 2015-08-28 16:53:23 +0530 |
commit | 4a1f703f1c1808d390ebf80e80659fe161f69fab (patch) | |
tree | 31b43ae8895599f2d13cf19395d84164463615d9 /sample_notebooks/SurajAhir | |
parent | 9d260e6fae7328d816a514130b691fbd0e9ef81d (diff) | |
download | Python-Textbook-Companions-4a1f703f1c1808d390ebf80e80659fe161f69fab.tar.gz Python-Textbook-Companions-4a1f703f1c1808d390ebf80e80659fe161f69fab.tar.bz2 Python-Textbook-Companions-4a1f703f1c1808d390ebf80e80659fe161f69fab.zip |
add books
Diffstat (limited to 'sample_notebooks/SurajAhir')
-rw-r--r-- | sample_notebooks/SurajAhir/ch1.ipynb | 641 |
1 files changed, 641 insertions, 0 deletions
diff --git a/sample_notebooks/SurajAhir/ch1.ipynb b/sample_notebooks/SurajAhir/ch1.ipynb new file mode 100644 index 00000000..dd3dc8fd --- /dev/null +++ b/sample_notebooks/SurajAhir/ch1.ipynb @@ -0,0 +1,641 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:ff1f8d37d08a8211fcc46eff9f443b7ece70ebe22359cada1bbdfcde008d38d6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1 : DC Circuits" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1 Page No : 1.5" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables\n", + "R = 3.;\t\t\t\t#kohm\n", + "V = 220;\t\t\t\t#V\n", + "\n", + "# Calculations and Results\n", + "#First Case\n", + "I = V/R;\t\t\t\t#mA\n", + "print \"1st case : Current in the circuit(mA) : %.f\"%I\n", + "\n", + "#Second Case\n", + "Req = R+R;\t\t\t\t#ohm(Equivalent Resistance)\n", + "I = V/Req;\t\t\t\t#mA\n", + "print \"2nd case : Current in the circuit(mA) : %.f\"%I\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1st case : Current in the circuit(mA) : 73\n", + "2nd case : Current in the circuit(mA) : 37\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.2 Page No : 1.6" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables\n", + "I = 1.5;\t\t\t\t#A\n", + "R1 = 2;\t\t\t\t#ohm\n", + "R2 = 3;\t\t\t\t#ohm\n", + "R3 = 8;\t\t\t\t#ohm\n", + "\n", + "# Calculations and Results\n", + "V1 = I*R1;\t\t\t\t#V\n", + "V2 = I*R2;\t\t\t\t#V\n", + "V3 = I*R3;\t\t\t\t#V\n", + "print \"Voltage across R1(V) : %.2f\"%V1\n", + "print \"Voltage across R2(V) : %.2f\"%V2\n", + "print \"Voltage across R3(V) : %.2f\"%V3\n", + "\n", + "V = V1+V2+V3;\t\t\t\t#V(Supply voltage)\n", + "print \"Supply Voltage(V) : %.2f\"%V\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Voltage across R1(V) : 3.00\n", + "Voltage across R2(V) : 4.50\n", + "Voltage across R3(V) : 12.00\n", + "Supply Voltage(V) : 19.50\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.3 Page No : 1.6" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "Vs = 100.;\t\t\t\t#V(Supply voltage)\n", + "R1 = 40.;\t\t\t\t#ohm\n", + "R2 = 50.;\t\t\t\t#ohm\n", + "R3 = 70.;\t\t\t\t#ohm\n", + "\n", + "# Calculations\n", + "R = R1+R2+R3;\t\t\t\t#ohm(Equivalent Resistance)\n", + "I = Vs/R;\t\t\t\t#A(Current in the circuit)\n", + "\n", + "# Results\n", + "print \"Circuit current(A) : %.2f\"%I\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Circuit current(A) : 0.62\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4 Page No : 1.7" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables\n", + "Vo = 10.;\t\t\t\t#V(Output voltage)\n", + "Vin = 30;\t\t\t\t#V(Input voltage)\n", + "R2 = 100;\t\t\t\t#ohm\n", + "\n", + "# Calculations\n", + "#V2/V = R2/(R1+R2)\t\t\t\t#Voltage divider rule\n", + "R1 = (Vin*R2-Vo*R2)/Vo;\t\t\t\t#ohm\n", + "\n", + "# Results\n", + "print \"Resistance of R1(ohm) : %.2f\"%R1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resistance of R1(ohm) : 200.00\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.5 Page No : 1.11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables\n", + "V = 110.;\t\t\t\t#V\n", + "R1 = 22.;\t\t\t\t#ohm\n", + "R2 = 44.;\t\t\t\t#ohm\n", + "\n", + "# Calculations\n", + "I1 = V/R1;\t\t\t\t#A\n", + "I2 = V/R2;\t\t\t\t#A\n", + "I = I1+I2;\t\t\t\t#A\n", + "\n", + "# Results\n", + "print \"Supply current(A) : %.2f\"%I\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Supply current(A) : 7.50\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.6 Page No : 1.11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables\n", + "V = 12.;\t\t\t\t#V\n", + "R1 = 6.8;\t\t\t\t#ohm\n", + "R2 = 4.7;\t\t\t\t#ohm\n", + "R3 = 2.2;\t\t\t\t#ohm\n", + "\n", + "# Calculations\n", + "R = 1./(1/R1+1/R2+1/R3);\t\t\t\t#ohm(Effective Resistance)\n", + "I = V/R;\t\t\t\t#A(Supply current)\n", + "\n", + "# Results\n", + "print \"Effective Resistance(ohm) : %.2f\"%R\n", + "print \"Supply current(A) : %.2f\"%I\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Effective Resistance(ohm) : 1.23\n", + "Supply current(A) : 9.77\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7 Page No : 1.12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables\n", + "I = 8.;\t\t\t\t#A\n", + "R2 = 2.;\t\t\t\t#ohm\n", + "\n", + "# Calculations and Results\n", + "# Part (a) \n", + "R1 = 2.;\t\t\t\t#ohm\n", + "I2 = I*R1/(R1+R2);\t\t\t\t#A\n", + "print \"(a) Current in 2 ohm Resistance(A) : %.2f\"%I2\n", + "\n", + "# Part (b) \n", + "R1 = 4.;\t\t\t\t#ohm\n", + "I2 = I*R1/(R1+R2);\t\t\t\t#A\n", + "print \"(b) Current in 2 ohm Resistance(A) : %.2f\"%I2\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) Current in 2 ohm Resistance(A) : 4.00\n", + "(b) Current in 2 ohm Resistance(A) : 5.33\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.8 Page No : 1.14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables\n", + "I1 = 3;\t\t\t\t#A\n", + "I2 = -4;\t\t\t\t#A\n", + "I4 = 2;\t\t\t\t#A\n", + "\n", + "# Calculations\n", + "#I1-I2+I3-I4 = 0\t\t\t\t#from KCL\n", + "I3 = -I1+I2+I4;\t\t\t\t#A\n", + "\n", + "# Results\n", + "print \"Current I3(A) : %.2f\"%I3\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Current I3(A) : -5.00\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9 Page No : 1.15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "G1 = 20.;\t\t\t\t#dB\n", + "G2 = 30.;\t\t\t\t#dB\n", + "G3 = 40.;\t\t\t\t#dB\n", + "\n", + "# Calculations and Results\n", + "Ap1 = 10**(G1/10);\t\t\t\t#Power Gain\n", + "print \"Power gain for 20 dB : %.2f\"%Ap1\n", + "Av1 = 10**(G1/20);\t\t\t\t#Voltage Gain\n", + "print \"Voltage gain for 20 dB : %.2f\"%Av1\n", + "Ap2 = 10**(G2/10);\t\t\t\t#Power Gain\n", + "print \"Power gain for 30 dB : %.2f\"%Ap2\n", + "Av2 = 10**(G2/20);\t\t\t\t#Voltage Gain\n", + "print \"Voltage gain for 30 dB : %.2f\"%Av2\n", + "Ap3 = 10**(G3/10);\t\t\t\t#Power Gain\n", + "print \"Power gain for 40 dB : %.2f\"%Ap3\n", + "Av3 = 10**(G3/20);\t\t\t\t#Voltage Gain\n", + "print \"Voltage gain for 40 dB : %.2f\"%Av3\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Power gain for 20 dB : 100.00\n", + "Voltage gain for 20 dB : 10.00\n", + "Power gain for 30 dB : 1000.00\n", + "Voltage gain for 30 dB : 31.62\n", + "Power gain for 40 dB : 10000.00\n", + "Voltage gain for 40 dB : 100.00\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.10 Page No : 1.15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "I1 = 2.5;\t\t\t\t#A\n", + "I2 = -1.5;\t\t\t\t#A\n", + "\n", + "# Calculations\n", + "#I1+I2+I3 = 0\t\t\t\t#from KCL\n", + "I3 = -I1-I2;\t\t\t\t#A\n", + "\n", + "# Results\n", + "print \"Current I3(A) : %.2f\"%I3" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Current I3(A) : -1.00\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.11 Page No : 1.16" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "I1 = 3;\t\t\t\t#A\n", + "I3 = 1;\t\t\t\t#A\n", + "I6 = 1;\t\t\t\t#A\n", + "\n", + "# Calculations\n", + "#I1-I2-I3 = 0\t\t\t\t#from KCL at point a\n", + "I2 = I1-I3;\t\t\t\t#A\n", + "#I2+I4-I6 = 0\t\t\t\t#from KCL at point b\n", + "I4 = I6-I2;\t\t\t\t#A\n", + "#I3-I4-I5 = 0\t\t\t\t#from KCL at point c\n", + "I5 = I3-I4;\t\t\t\t#A\n", + "\n", + "# Results\n", + "print \"Current I2(A) : %.2f\"%I2\n", + "print \"Current I4(A) : %.2f\"%I4\n", + "print \"Current I5(A) : %.2f\"%I5\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Current I2(A) : 2.00\n", + "Current I4(A) : -1.00\n", + "Current I5(A) : 2.00\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.12 Page No : 1.17" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables\n", + "R1 = 30;\t\t\t\t#ohm\n", + "R2 = 60.;\t\t\t\t#ohm\n", + "R3 = 30;\t\t\t\t#ohm\n", + "I3 = 1;\t\t\t\t#A\n", + "\n", + "# Calculations\n", + "I1 = I3*(R2+R3)/R2;\t\t\t\t#A\n", + "I2 = I1-I3;\t\t\t\t#A\n", + "\n", + "# Results\n", + "print \"Current I1(A) : %.2f\"%I1\n", + "print \"Current I2(A) : %.2f\"%I2\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Current I1(A) : 1.50\n", + "Current I2(A) : 0.50\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.13 Page No : 1.18" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variables\n", + "E = 12;\t\t\t\t#V\n", + "V2 = 8;\t\t\t\t#V\n", + "V4 = 2;\t\t\t\t#V\n", + "\n", + "# Calculations\n", + "V1 = E-V2;\t\t\t\t#V\n", + "#-V2+V3+V4 = 0;\t\t\t\t#for Loop B\n", + "V3 = V2-V4;\t\t\t\t#V\n", + "\n", + "# Results\n", + "print \"Voltage V1(V) : %.2f\"%V1\n", + "print \"Voltage V3(V) : %.2f\"%V3\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Voltage V1(V) : 4.00\n", + "Voltage V3(V) : 6.00\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.14 Page No : 1.19" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables\n", + "V = 20.;\t\t\t\t#V\n", + "R1 = 25;\t\t\t\t#ohm\n", + "R2 = 40;\t\t\t\t#ohm\n", + "R3 = 15;\t\t\t\t#ohm\n", + "R4 = 10;\t\t\t\t#ohm\n", + "\n", + "# Calculations\n", + "VAC = R3*V/(R1+R3);\t\t\t\t#V\n", + "VBC = R4*V/(R2+R4);\t\t\t\t#V\n", + "#0 = VAB+VBC-VAC;\t\t\t\t#/from KVL\n", + "VAB = -VBC+VAC;\t\t\t\t#V\n", + "\n", + "# Results\n", + "print \"Voltage VAB(V) : %.2f\"%VAB\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Voltage VAB(V) : 3.50\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.15 Page No : 1.20\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Variables\n", + "E1 = 10;\t\t\t\t#V\n", + "V2 = 6;\t\t\t\t#V\n", + "V3 = 8;\t\t\t\t#V\n", + "\n", + "# Calculations\n", + "#E1 = V1+V2;\t\t\t\t#KCL for left loop\n", + "V1 = E1-V2;\t\t\t\t#V\n", + "#-E2 = -V2-V3;\t\t\t\t#KCL for right loop\n", + "E2 = V2+V3;\t\t\t\t#Vc\n", + "\n", + "# Results\n", + "print \"Voltage V1(V) : %.2f\"%V1\n", + "print \"Voltage E2(V) : %.2f\"%E2\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Voltage V1(V) : 4.00\n", + "Voltage E2(V) : 14.00\n" + ] + } + ], + "prompt_number": 13 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file |