diff options
author | Hardik Ghaghada | 2014-06-21 14:25:56 +0530 |
---|---|---|
committer | Hardik Ghaghada | 2014-06-21 14:25:56 +0530 |
commit | 299711403e92ffa94a643fbd960c6f879639302c (patch) | |
tree | 009cb02ec85f4a75ac7b64239751f15361df2bfe | |
parent | e1e59ca3a50d9f93e8b7bc0693b8081d5db77771 (diff) | |
parent | 7c756fcc12d21693818e58f6936cab5b7c112868 (diff) | |
download | Python-Textbook-Companions-299711403e92ffa94a643fbd960c6f879639302c.tar.gz Python-Textbook-Companions-299711403e92ffa94a643fbd960c6f879639302c.tar.bz2 Python-Textbook-Companions-299711403e92ffa94a643fbd960c6f879639302c.zip |
Merge pull request #2 from debashisdeb/master
Removed Problem Statements Completely
101 files changed, 11696 insertions, 11586 deletions
diff --git a/Basic_Electronics_and_Linear_Circuits/ch2.ipynb b/Basic_Electronics_and_Linear_Circuits/ch2.ipynb index d56fd44b..56897172 100644 --- a/Basic_Electronics_and_Linear_Circuits/ch2.ipynb +++ b/Basic_Electronics_and_Linear_Circuits/ch2.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:b1613f8489042ca15914370b3e63d5de12449c98b57f7da2c4754a1532abe03b" + "signature": "sha256:d04dc734c5bc464767e0da96b38331e03b832b88f0bd8644b242b3682feeb9d9" }, "nbformat": 3, "nbformat_minor": 0, @@ -117,8 +117,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#Input Side\n", + " \n", "Vs=0.01 #V ,dc voltage\n", "Rs=1000 # ohm, resistance\n", "#Output Side resistance\n", diff --git a/Basic_Mechanical_Engineering/bme1.ipynb b/Basic_Mechanical_Engineering/bme1.ipynb index f265eb09..c8832e7f 100644 --- a/Basic_Mechanical_Engineering/bme1.ipynb +++ b/Basic_Mechanical_Engineering/bme1.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:1c2bde816df4a48f4bf4b466f0c4a777a3dcae429d1891036e825820f9cb6fc1" + "signature": "sha256:24b9eaeeeddeacc3199362b9156ae9de4a4fc79ba4c35797142cfcc4a54f627a" }, "nbformat": 3, "nbformat_minor": 0, @@ -29,8 +29,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "p=700\t\t #pressure of fluid in kN/m**2\n", "v1=0.28\t\t#Initial volume of fluid in m**3\n", "v2=1.68\t\t#Final volume of fluid in m**3\n", @@ -67,8 +65,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "p1=138.0\t\t#Initial pressure of gas in kN/m**2\n", "p2=690.0\t\t#Final pressure of gas in kN/m**2\n", "v1=0.112\t\t#Initial volume in m**3\n", @@ -106,8 +102,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "p1=2070\t\t#Initial pressure of gas in kN/m**2\n", "p2=207\t\t#Final pressure of gas in kN/m**2\n", "v1=0.014\t\t#Initial volume of gas in m**3\n", @@ -149,8 +143,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "v1=0.056\t\t#Initial volume of gas in m**3\n", "v2=0.007\t\t#Final volume of gas in m**3\n", "p1=100\t\t#Initial perssure compressed Isothermally in kN/m**2\n", @@ -190,8 +182,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "v1=1.0\t\t#Initial volume in m**3\n", "v2=3.0\t\t#Final volume in m**3\n", "\n", @@ -228,8 +218,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "v1=0.2\t#Initial volume in m**3\n", "v2=0.5\t#Final volume in m**3\n", "\n", @@ -265,8 +253,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "v1=1.5\t\t#Initial volume in m**3\n", "v2=2\t\t#Final volume in m**3\n", "w1=2\t\t#Work receiving in Nm\n", @@ -305,8 +291,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "d=13596\t\t#Density of Hg in kg/m**3\n", "g=9.806\t\t#gravity in m/sec**2\n", "z=760.0\t\t#Barometer pressure in mm of Hg\n", @@ -357,8 +341,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data \n", "z=750\t\t#Barometric pressure in mm of Hg\n", "g=9.81\t\t#Gravity in m/sec**2\n", "Pa=101.325\t#one atm pressure in kN/m**2\n", @@ -410,8 +392,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "Zw=50\t\t#Manometer reading of water in cm\n", "Zo=763\t\t#Atmospheric pressure in mm of Hg\n", "d=13.6*10**3\t#Density of Hg in kg/m**3\n", @@ -452,8 +432,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "Z=70\t\t\t#Vaccum gauge reading in cm of Hg\n", "Pa=101.325\t\t#Atmospheric pressure in kPa\n", "d=13.6*10**3\t\t#Density of Hg in kg/m**3\n", @@ -492,8 +470,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "Pv=30\t\t#Vaccum pressure in kPa\n", "Z=755\t\t#Barometer reading in mm of Hg\n", "d=13590\t\t#Density of Hg in kg/m**3\n", @@ -532,8 +508,6 @@ "collapsed": false, "input": [ " \n", - "\n", - "#Input data\n", "Z=0.562\t\t#Level of open limb in m\n", "Z1=0.761\t\t#Barometer reading in m of Hg\n", "g=9.79\t\t#Gravity in m/sec**2\n", @@ -573,8 +547,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data \n", "d=13.596*10**3\t#Density of Hg in kg/m**3\n", "dl=800\t\t#Density of liquid in kg/m**3\n", "Z=30\t\t#Level of the liquid in the arm in cm\n", @@ -617,8 +589,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "Z1=0.17\t\t#Level of liquid in m\n", "Z=0.76\t\t#Barometer readings in m\n", "d=13596\t\t#Density of Hg in kg/m**3\n", @@ -661,8 +631,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "g=9.806\t\t#Gravity in m/sec**2\n", "d=13596\t\t#Density of Hg in kg/m**3\n", "Z=9.75\t\t#Level of Hg in cm\n", @@ -709,8 +677,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "g=9.7\t\t #Gravity in m/sec**2\n", "d=13.69*10**3\t#Density of Hg in kg/m**3\n", "dw=1000\t\t #Density of water in kg/m**3\n", @@ -753,8 +719,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "Z=0.76\t\t#Actual height of mercury coloumn in m\n", "g=9.806\t\t#Gravity in m/sec**2\n", "d=13596\t\t#Density of Hg in kg/m**3\n", @@ -797,8 +761,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "dk=800\t\t#Density of kerosene in kg/m**3\n", "g=9.81\t\t#gravity in m/sec**2\n", "Zk=0.051\t\t#Kerosene vapour on Hg coloumn in m\n", @@ -841,8 +803,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "d=13596\t\t#Density of Hg in kg/m**3\n", "g=9.806\t\t#Gravity in m/sec**2\n", "df=0.8*1000\t#Density of fluid in kg/m**3\n", @@ -886,8 +846,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "Pa=1\t\t#Atmospheric pressure in bar\n", "g=9.81\t\t#Gravity in m/sec**2\n", "do=0.8*1000\t#Density of oil in kg/m**3\n", @@ -938,7 +896,6 @@ "collapsed": false, "input": [ "\n", - "#Input data\n", "Z=0.76\t\t#Barometer reading in m\n", "g=9.81\t\t#Gravity in m/sec**2\n", "d=13.6*10**3\t#Density of Hg in kg/m**3\n", @@ -1030,8 +987,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "dw=1000\t\t#Density of water in kg/m**3\n", "dh=13590\t\t#Density of Hg in kg/m**3\n", "Pa=400\t\t#Pressure at A in kPa\n", @@ -1075,8 +1030,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "do=0.902*10**3\t#Density of oil in kg/m**3\n", "Pg=2*10**5\t #Gauge pressure in N/m**2\n", "g=9.81\t\t #Gravity in m/sec**2\n", @@ -1117,9 +1070,7 @@ "cell_type": "code", "collapsed": false, "input": [ - " \n", "\n", - "#Input data\n", "m=21\t\t#Mass of piston in kg\n", "P1=600\t\t#Pressure in the pipe 1 in kPa\n", "P2=170\t\t#Pressure in the pipe 2 in kPa\n", @@ -1163,8 +1114,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "P1=0.755\t\t#Barometric reading at the bottom of the building in m\n", "P2=0.73\t\t#Barometric reading at the top of the building in m\n", "da=1.18\t\t#Density of air in kg/m**3\n", @@ -1203,7 +1152,6 @@ "collapsed": false, "input": [ "\n", - "#Given\n", "PA=200\t\t#Gauge pressure reading for A in kPa\n", "PB=120\t\t#Gauge pressure reading for B in kPa\n", "hb=750\t\t#Barometer reading in mm of Hg\n", @@ -1246,8 +1194,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "C1=40\t\t #Temperature 1 in degree centigrade\n", "C2=-20\t\t#Temperature 2 in degree centigrade \n", "\n", @@ -1317,8 +1263,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "P1=1.5\t\t#Thermometric properties at ice point\n", "P2=7.5\t\t#Thermometric properties at steam point\n", "P3=3.5\t\t#Thermometric property\n", @@ -1361,7 +1305,6 @@ "collapsed": false, "input": [ "\n", - "#Input data\n", "T1=100\n", "T2=300 #Temperature of ice and steam point in the scale\n", "P1=1.86\t\t #Values of thermometric properties at ice point nad steam point respectively\n", @@ -1406,8 +1349,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "p1=32.0\t\t #Pressure in mm of Hg at triple point of water\n", "p2=76.0\t\t #Pressure in mm of Hg above atmospheric pressure\n", "p3=752.0\t\t#Barometric pressure in mm of Hg\n", @@ -1448,7 +1389,6 @@ "collapsed": false, "input": [ "\n", - "#Input data\n", "T1=32\t\t#Temperatures of ice point and steam point respectively\n", "T2=212\n", "P1=1.86\t\t #P values at ice point and steam point respectively\n", diff --git a/Basic_Mechanical_Engineering/bme2.ipynb b/Basic_Mechanical_Engineering/bme2.ipynb index d16be4dc..07d17afc 100644 --- a/Basic_Mechanical_Engineering/bme2.ipynb +++ b/Basic_Mechanical_Engineering/bme2.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:eb480946d569a90f950fa22c2b37d79f68cd522d201043a9e36d8370900550dc" + "signature": "sha256:be9b81ec82ea0e8e81e59b4d7c97d91bf099bd45d69eea5f3a2ed8e0bbebe433" }, "nbformat": 3, "nbformat_minor": 0, @@ -29,8 +29,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "h1=60\t\t#The heat transfer in the process in kJ\n", "h2=-8\t\t#The heat transfer in the process in kJ\n", "h3=-34\t\t#The heat transfer in the process in kJ\n", @@ -68,8 +66,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "Q=-300\t\t#Heat transfer in the system consisting of the gas in kJ\n", "u=0\t\t#Internal energy is constant\n", "\n", @@ -142,8 +138,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "h1=35\t\t#Enthalpy of water entering the boiler in kJ/kg\n", "h2=705\t\t#Enthalpy of steam leaving the boiler in kJ/kg\n", "C=0\t\t#Change in kinetic energy is neglected\n", @@ -181,8 +175,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "Q=-170\t\t#Sum of all heat transfers per cycle in kJ\n", "N=100\t\t#Total number of cycles per min in cycles/min\n", "Q1=0\t\t#Heat developed in a-b process in kJ/min\n", @@ -244,8 +236,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "Q1=50\t\t#Heat developed in the 1-2 process in kJ/kg\n", "U1=20\t\t#Change in energy in the 1-2 process in kJ/kg\n", "Q2=-30\t\t#Heat developed in the 2-3 process in kJ/kg\n", @@ -302,8 +292,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "m=3.0\t\t#Mass of substance in the system in kg\n", "P1=500.0\t\t#Initial pressure of the system in kPa\n", "P2=100.0\t\t#Final pressure of the system in kPa\n", @@ -398,8 +386,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "p1=170\t\t#Initial pressure of the fluid in kPa\n", "p2=400\t\t#Final pressure of the fluid in kPa\n", "v1=0.03\t\t#Initial volume in m**3\n", @@ -446,8 +432,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "E1=4000\t\t#Enthalpy at entrance in kJ/Kg\n", "E2=4100\t\t#Enthalpy at exit in kJ/kg\n", "V1=50\t\t#Velocity at entrance in m/s\n", @@ -488,8 +472,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "W=135\t\t#Work done by the system in kJ/kg\n", "V1=0.37\t\t#Specific volume of fluid at inlet in m**3/kg\n", "V2=0.62\t\t#Specific volume of fluid at outlet in m**3/kg\n", @@ -534,8 +516,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "m=5\t\t#Rate of fluid flow in the system in kg/s\n", "P1=620\t\t#Pressure at the entrance in kPa\n", "P2=130\t\t#Pressure at the exit in kPa\n", @@ -584,8 +564,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input Data\n", "P1=100\t\t#Pressure at Inlet in kPa\n", "P2=500\t\t#Pressure at Exit in kPa\n", "V1=0.6\t\t#Specific volume at Inlet in m**3/kg\n", @@ -631,7 +609,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "#Input data\n", + "\n", "m1=5000\t\t#Steam flow rate in kg/hr\n", "Q1=-250\t\t#Heat loss from the turbine insulation to surroundings in kj/min\n", "C1=40\t \t#Velocity of steam at entrance in m/s\n", @@ -674,9 +652,7 @@ "cell_type": "code", "collapsed": false, "input": [ - " \n", "\n", - "#Input data \n", "c1=16\t\t#Velocity of steam at entrance in m/s\n", "c2=37\t\t#Velocity of steam at exit in m/s\n", "h1=2990\t\t#Specific enthalpy of steam at entrance in kJ/kg\n", @@ -720,7 +696,6 @@ "collapsed": false, "input": [ "\n", - "#Input data\n", "p1=720\t\t#Pressure at the entrance in kPa\n", "t1=850\t\t#Temperature at the entrance in degree centigrade \n", "c1=160\t\t#Velocity of the gas at entrance in m/s\n", @@ -763,8 +738,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "p=5000\t\t#Power output of an adiabatic steam turbine in kW\n", "p1=2000\t\t#Pressure at the inlet in kPa\n", "p2=0.15\t\t#Pressure at the exit in bar\n", @@ -815,8 +788,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input Data\n", "p1=1000.0\t\t#Pressure at the inlet in kPa\n", "t1=750.0\t\t#Temperature at the inlet in K\n", "c1=200.0\t\t#Velocity at the inlet in m/s\n", @@ -866,8 +837,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Input data\n", "c1=7\t\t #Velocity of air at entrance in m/s\n", "c2=5\t\t #Velocity of air at exit in m/s\n", "p1=100\t\t #Pressure at the entrance in kPa\n", @@ -915,9 +884,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#Input data\n", "h1=3000\t\t#Enthalpy of the fluid passing at inlet in kJ/kg\n", "h2=2757\t\t#Enthalpy of the fluid at the discharge in kJ/kg\n", "c1=60\t\t#Velocity of the fluid at inlet in m/s\n", @@ -966,7 +932,6 @@ "collapsed": false, "input": [ "\n", - "#Input data\n", "h1=3000\t\t#Specific enthalpy of steam at inlet in kJ/kg\n", "h2=2762\t\t#Specific enthalpy of steam at the outlet in kJ/kg\n", "v1=0.187\t\t#Specific volume of steam at inlet in m**3/kg\n", diff --git a/Basic_Principles_And_Calculations_In_Chemical_Engineering/ch1.ipynb b/Basic_Principles_And_Calculations_In_Chemical_Engineering/ch1.ipynb index 0948f57e..c32c32f6 100644 --- a/Basic_Principles_And_Calculations_In_Chemical_Engineering/ch1.ipynb +++ b/Basic_Principles_And_Calculations_In_Chemical_Engineering/ch1.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:ad7d15642ee4e9d7fd8a276d1246f62e3d28aa177d39ecd9ac2c125ea04f5d33" + "signature": "sha256:24494f10d2186cdcb9bb7efdf5bb782c5e073da13a9c9e6466d2071310209ca3" }, "nbformat": 3, "nbformat_minor": 0, @@ -31,7 +31,7 @@ "\n", "#variables\n", "m_total=100.0; #lbm\n", - "#70% by wt of mud is sand(SiO2)and remaining is water\n", + " \n", "m_sand=0.7*m_total; #lbm\n", "m_water=0.3*m_total; #lbm\n", "rho_sand=165.0; #lbm/ft^3\n", diff --git a/Beginning_C_By_Ivon_Horton/chapter8.ipynb b/Beginning_C_By_Ivon_Horton/chapter8.ipynb index 2b0cdc0b..54da74de 100644 --- a/Beginning_C_By_Ivon_Horton/chapter8.ipynb +++ b/Beginning_C_By_Ivon_Horton/chapter8.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:3fbbd33189f83aa6d0187f308c759f69619a009cb3b8fae3f4a0ad98df7c2c47" + "signature": "sha256:9c1a031463da8a03e6f56a08f572c87969b01883476b123f1b468e43c2cd2b66" }, "nbformat": 3, "nbformat_minor": 0, @@ -71,11 +71,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "More scope in this example\n", - "note: the way it is given in textbook is not possible in Python\n", - "\"\"\"\n", - "\n", + " \n", "\n", "count = 0\n", "while(count<=5):\n", diff --git a/C++_from_the_Ground/Chapter_10(1).ipynb b/C++_from_the_Ground/Chapter_10(1).ipynb index 77fa05ce..b19c3a4c 100644 --- a/C++_from_the_Ground/Chapter_10(1).ipynb +++ b/C++_from_the_Ground/Chapter_10(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:369d1716e7a65538ad06381f5a1cdafc97ddfbad9ccd970d060ca5c894a6593b" + "signature": "sha256:73c04e2c14bfab695e4acf07dc7752334b6372d624570a4e051fd91aeeb761f7" }, "nbformat": 3, "nbformat_minor": 0, @@ -329,7 +329,6 @@ " a=None\n", " b=None\n", "\n", - "#Recieve and return by reference\n", "def f(var):\n", " var[0].a=var[0].a*var[0].a\n", " var[0].b=var[0].b/var[0].b\n", diff --git a/C++_from_the_Ground/Chapter_12(1).ipynb b/C++_from_the_Ground/Chapter_12(1).ipynb index f92ff06c..a29c9b4d 100644 --- a/C++_from_the_Ground/Chapter_12(1).ipynb +++ b/C++_from_the_Ground/Chapter_12(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:16b30eb675083837fc31b76aa8f3c6bd5549baef25d739f4f8bead7d865cbcbf" + "signature": "sha256:0b4a52abc3f3246965d1e59241352e867e78e448510ae25e91b7d38dc4dcc202" }, "nbformat": 3, "nbformat_minor": 0, @@ -555,8 +555,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''Passing objects by reference'''\n", - "\n", + " \n", "from ctypes import *\n", "class myclass:\n", " def __init__(self,i):\n", @@ -653,7 +652,7 @@ "collapsed": false, "input": [ "\n", - "#\n", + "\n", "class sample:\n", " __s=None\n", " def __init__(self):\n", diff --git a/C++_from_the_Ground/Chapter_16(1).ipynb b/C++_from_the_Ground/Chapter_16(1).ipynb index 941febba..98e3dc8a 100644 --- a/C++_from_the_Ground/Chapter_16(1).ipynb +++ b/C++_from_the_Ground/Chapter_16(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:bbf24dca4298d6f4bb5217612c0027ad0473157ec0c530ae82f2e0944bb06ddf" + "signature": "sha256:60d976a21b55caeaa47bb2c8586e986eed54234a29f15a816e7270f74ad2660e" }, "nbformat": 3, "nbformat_minor": 0, @@ -215,8 +215,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#Display data specified number of times.\n", + " \n", "def repeat(data,times):\n", " while times:\n", " print data\n", @@ -415,8 +414,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#Defining constant\n", + " \n", "def SIZE():\n", " return 10\n", "\n", diff --git a/C++_from_the_Ground/Chapter_18(1).ipynb b/C++_from_the_Ground/Chapter_18(1).ipynb index e2cae07f..df4cabc2 100644 --- a/C++_from_the_Ground/Chapter_18(1).ipynb +++ b/C++_from_the_Ground/Chapter_18(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:3dbb4b61b32533eb72607c7c790e9f8f91b9c2e123ddbd5190ffe13a1b2b7647" + "signature": "sha256:85eae8322c208f1f26e859bb0f4dac6f86b35c3ac105ed98ac2d0fbf05287f0e" }, "nbformat": 3, "nbformat_minor": 0, @@ -410,11 +410,10 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#Open a file, creating one if it does not already exist\n", + " \n", "out=open(\"test\",'w')\n", "\n", - "#In case file cannot open\n", + "\n", "if(not(out)):\n", " print \"Cannot open file.\"\n", "else:\n", @@ -441,10 +440,9 @@ "collapsed": false, "input": [ "\n", - "#Open a file, creating one if it does not already exist\n", + " \n", "In=open(\"test\",'r')\n", - "\n", - "#In case file cannot open\n", + " \n", "if(not(In)):\n", " print \"Cannot open file.\"\n", "else:\n", @@ -668,27 +666,24 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#creating test1\n", + " \n", "out=open(\"test1\",'w')\n", "out.write(\"Hello\")\n", "out.close()\n", - "\n", - "#creating test2\n", + " \n", "out=open(\"test2\",'w')\n", "out.write(\"There\")\n", "out.close()\n", "\n", - "\n", - "#Open test1\n", + " \n", "f1=open(\"test1\",'r')\n", - "#In case file cannot open\n", + " \n", "if(not(In)):\n", " print \"Cannot open file.\"\n", "\n", - "#Open test2\n", + " \n", "f2=open(\"test2\",'r')\n", - "#In case file cannot open\n", + " \n", "if(not(In)):\n", " print \"Cannot open file.\"\n", " \n", @@ -703,7 +698,7 @@ " f1.close()\n", " f2.close()\n", "else:\n", - " #compare contents of buffers\n", + " \n", " flag=1\n", " for i in range(len(buf1)):\n", " if not(buf1[i]==buf2[i]):\n", @@ -745,8 +740,7 @@ "input": [ "\n", "print \"Enter your name:\"\n", - "\n", - "#User imput\n", + " \n", "str=\"hello world\"\n", "\n", "print str" @@ -776,13 +770,10 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#Open test\n", - "out=open(\"test\",'r+b')\n", + " out=open(\"test\",'r+b')\n", "out.write(\"Hello\")\n", "\n", - "\n", - "#In case file cannot open\n", + " \n", "if(not(out)):\n", " print \"Cannot open file.\"\n", "else:\n", @@ -808,13 +799,13 @@ "collapsed": false, "input": [ "\n", - "#Open test\n", + " \n", "out=open(\"test\",'r+b')\n", "out.write(\"Hello\")\n", "out.close()\n", "\n", "In=open(\"test\",'r')\n", - "#In case file cannot open\n", + " \n", "if(not(In)):\n", " print \"Cannot open file.\"\n", "else:\n", @@ -857,14 +848,13 @@ " c=(\"%d\"%self.__x)+\", \"+(\"%d\"%self.__y)+\", \"+(\"%d\"%self.__z)+\"\\n\"\n", " return c \n", "\n", - "#Variable declaration\n", + " \n", "a=three_d(1,2,3)\n", "b=three_d(3,4,5)\n", "c=three_d(5,6,7)\n", - "\n", - "#Open threed\n", + " \n", "out=open(\"threed\",'w')\n", - "#In case file cannot open\n", + " \n", "if(not(out)):\n", " print \"Cannot open file.\"\n", "else:\n", diff --git a/C++_from_the_Ground/Chapter_19(1).ipynb b/C++_from_the_Ground/Chapter_19(1).ipynb index 3c9ecd17..7f04b7ea 100644 --- a/C++_from_the_Ground/Chapter_19(1).ipynb +++ b/C++_from_the_Ground/Chapter_19(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:d2c5aefc81786f6e7a83b5f07eeb250789c73d2ab2ad23662758aa0cdec50617" + "signature": "sha256:20d38d92a3a25bc02f8bf5fb1b35ef1503e1987dff61d43c4881deab4561fe2c" }, "nbformat": 3, "nbformat_minor": 0, @@ -273,8 +273,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#Template class\n", + " \n", "class myclass:\n", " def __init__(self,i):\n", " self.__a=i\n", diff --git a/C++_from_the_Ground/Chapter_2(1).ipynb b/C++_from_the_Ground/Chapter_2(1).ipynb index 603f2bab..b3976867 100644 --- a/C++_from_the_Ground/Chapter_2(1).ipynb +++ b/C++_from_the_Ground/Chapter_2(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:2822ffa73df44943f6be3bedb4cf89d60d9228e7b719790e40dca7bc4236f0b9" + "signature": "sha256:05876b24f412fcea817693bad944dc90f3dae4fb5142aeb7d9c2c98569067083" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,7 +27,6 @@ "collapsed": false, "input": [ "\n", - "#Result\n", "print \"This is my first C++ program.\"" ], "language": "python", @@ -54,10 +53,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'\n", - "\n", - "\n", - "#Variable Declaration\n", + " \n", "x=None \n", "\n", "x=1023 #this assigns 1023 to x\n", @@ -160,10 +156,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "\n", - "#myfunc's definition\n", + " \n", "def myfunc():\n", " print \"Inside myfunc() \"\n", " \n", @@ -197,10 +190,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "\n", - "#Result\n", + " \n", "print abs(-10)" ], "language": "python", @@ -227,9 +217,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#mul's definition\n", + " \n", "def mul(x,y):\n", " print x*y,\n", "\n", @@ -262,9 +250,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#mul()'s definition; this function returns a value\n", + " \n", "def mul(x,y):\n", " return x*y #return product of x and y\n", "\n", @@ -330,8 +316,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''This program illustrates the if statement'''\n", - "\n", + " \n", "#Variable declaration\n", "a=10 #user input for two numbers\n", "b=20\n", @@ -393,8 +378,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#Variable declaration\n", + " \n", "a=10 #User input for two numbers\n", "b=20\n", "\n", diff --git a/C++_from_the_Ground/Chapter_20(2).ipynb b/C++_from_the_Ground/Chapter_20(2).ipynb index e56ad6fd..8771c6cd 100644 --- a/C++_from_the_Ground/Chapter_20(2).ipynb +++ b/C++_from_the_Ground/Chapter_20(2).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:c2dea3221dd29327bd680c1c48d2d9bcb943c373644635507698dc8145b7a0c6" + "signature": "sha256:aed4cbb1750b5cf45152f9d0ded2a9f36978f3177285c38b159fb79a8b0d35e4" }, "nbformat": 3, "nbformat_minor": 0, @@ -104,7 +104,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'\n", + " \n", "class CounterNameSpace:\n", " upperbound=None\n", " lowerbound=None\n", @@ -290,8 +290,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#functions\n", + " \n", "def vline(i):\n", " for j in xrange(i,0,-1):\n", " print \"|\"\n", diff --git a/C++_from_the_Ground/Chapter_21(1).ipynb b/C++_from_the_Ground/Chapter_21(1).ipynb index 023fd126..76345922 100644 --- a/C++_from_the_Ground/Chapter_21(1).ipynb +++ b/C++_from_the_Ground/Chapter_21(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:0975c16101ec7adc0b19a0a24a31504acce776790d976f2710d7048c660d7882" + "signature": "sha256:1f6065242a1ea235eb4712b9ec147fb29625df8861301b52ad6c880a94467811" }, "nbformat": 3, "nbformat_minor": 0, @@ -26,16 +26,11 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#Variable declaratio\n", + " \n", "v=[] #Create a zero length vector\n", - "\n", - "#display original size of v\n", + " \n", "print \"Size =\",len(v)\n", - "\n", - "#put values onto end of vector\n", - "#vector will grow as needed\n", + " \n", "\n", "for i in range(10):\n", " v.append(i)\n", @@ -304,9 +299,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - " \n", - "#Variable declaration\n", + " \n", "v=[]\n", "v2=[]\n", "\n", @@ -699,8 +692,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#define the function find\n", + " \n", "def find(x,ch):\n", " for p in x:\n", " if p[0].get()==ch.get():\n", @@ -766,9 +758,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#This is a unary precdate that determines if character is a vowel\n", "def isvowel(ch):\n", " ch=ch.lower()\n", " if (ch=='a' or ch=='e'or ch=='i' or ch=='o' or ch=='u'):\n", @@ -886,9 +875,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#Variable declaration\n", + " \n", "v=[]\n", "\n", "for i in range(10):\n", @@ -933,9 +920,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#A simple transformaton function\n", + " \n", "def xform(i):\n", " return i*i #square original value\n", "\n", @@ -1147,8 +1132,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#define the function find\n", + " \n", "def find(x,ch):\n", " for p in x:\n", " if p[0]==ch:\n", diff --git a/C++_from_the_Ground/Chapter_22(1).ipynb b/C++_from_the_Ground/Chapter_22(1).ipynb index 8c26974a..39b8cb88 100644 --- a/C++_from_the_Ground/Chapter_22(1).ipynb +++ b/C++_from_the_Ground/Chapter_22(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:53f00d75f5adfa37af0d8067426691c881e1b4ea1e38045c3a67a88230ca00f5" + "signature": "sha256:2d1838d005f866ea4e20c93ff6de54ebfd0d0c26c2e3055fc05467a06502c1dc" }, "nbformat": 3, "nbformat_minor": 0, @@ -248,8 +248,7 @@ "input": [ "\n", "import inspect\n", - "\n", - "#Returns the current line number in our program.\n", + " \n", "def lineno():\n", " return inspect.currentframe().f_back.f_lineno\n", " \n", diff --git a/C++_from_the_Ground/Chapter_3(1).ipynb b/C++_from_the_Ground/Chapter_3(1).ipynb index 19f2cea0..9d0cf326 100644 --- a/C++_from_the_Ground/Chapter_3(1).ipynb +++ b/C++_from_the_Ground/Chapter_3(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:a048620e2c0a121c8dd48d68bd57c4172e8820ecd9345c7b4ca01d8f4f4621a3" + "signature": "sha256:13095677f4efa0909d9aeb25aa7b8b57bea864fd1d9a0a797f9e06000e52dc18" }, "nbformat": 3, "nbformat_minor": 0, @@ -179,9 +179,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#prints a newline, a backslash and a backspace\n", + " \n", "print \"\\n\\\\\\b\"\n" ], "language": "python", @@ -300,8 +298,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#the xor function\n", + " \n", "def xor(a,b):\n", " return (a or b)and(not(a and b))\n", "\n", diff --git a/C++_from_the_Ground/Chapter_4(1).ipynb b/C++_from_the_Ground/Chapter_4(1).ipynb index ebd72abc..ca8e76db 100644 --- a/C++_from_the_Ground/Chapter_4(1).ipynb +++ b/C++_from_the_Ground/Chapter_4(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:7a7e07f5e71ec203dfa93cc13b4ce9de80c80af3b59f8d7d6bebe41c247db83e" + "signature": "sha256:f944500666c92742656b5a25638e93a82042acafb19b205aac684e2d9ac2df51" }, "nbformat": 3, "nbformat_minor": 0, @@ -425,9 +425,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#Displaying the menu\n", + " \n", "print \"Help on:\"\n", "print \"1. for\"\n", "print \"2. if\"\n", @@ -517,9 +515,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "'''Displays all printable characters.'''\n", - "\n", + " \n", "#Variable decleration\n", "ch = 32\n", "\n", diff --git a/C++_from_the_Ground/Chapter_5(1).ipynb b/C++_from_the_Ground/Chapter_5(1).ipynb index adbe1235..13085f5e 100644 --- a/C++_from_the_Ground/Chapter_5(1).ipynb +++ b/C++_from_the_Ground/Chapter_5(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:daa9c054e3b743c745cfe62599d80f03d625b2ef5131489390410210f502a5cb" + "signature": "sha256:f41d93d043c68dcb6af847a40af38d47fc3a3d45c60675afb574707e38d804d9" }, "nbformat": 3, "nbformat_minor": 0, @@ -206,7 +206,7 @@ "\n", "print \"Enter a string: \"\n", "\n", - "#user input\n", + " \n", "str = \"Hello\"\n", "\n", "#Result\n", diff --git a/C++_from_the_Ground/Chapter_7(1).ipynb b/C++_from_the_Ground/Chapter_7(1).ipynb index 28829c6d..027b30f5 100644 --- a/C++_from_the_Ground/Chapter_7(1).ipynb +++ b/C++_from_the_Ground/Chapter_7(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:9a6978851f88c0c91bde88465299d72777f3dae7854964b1cadad7b80092df72" + "signature": "sha256:ab47bb393809bc88589e7e92320813b90077813594dc417229af49780e24b53b" }, "nbformat": 3, "nbformat_minor": 0, @@ -254,8 +254,7 @@ "input": [ "\n", "from ctypes import *\n", - "\n", - "#Function to change the reference value\n", + " \n", "def f(j):\n", " j[0]=100 #j is assigned 100\n", "\n", @@ -295,7 +294,7 @@ "\n", "from ctypes import *\n", "\n", - "#Function to change the reference value\n", + " \n", "def f(j):\n", " j[0]=100 #j is assigned 100\n", "\n", @@ -332,8 +331,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#function to print some nos.\n", + " \n", "def display(num):\n", " for i in range(10):\n", " print num[i],\n", @@ -370,9 +368,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#Print some nos.\n", + " \n", "def display(num):\n", " print num,\n", "\n", @@ -410,9 +406,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#Function to convert into cubes\n", + " \n", "def cube(n,num):\n", " num-=1\n", " while num:\n", @@ -502,8 +496,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#Function to fond length\n", + " \n", "def mystrlen(str):\n", " l=len(str)\n", " return l\n", @@ -572,7 +565,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''The program prints all command line arguments '''\n", "import sys\n", "\n", "#Result\n", @@ -721,9 +713,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#Return index of substring or -1 if not found.\n", + " \n", "def find_substr(sub,str):\n", " l=str.find(sub)\n", " return l\n", @@ -794,8 +784,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#Return position of substring\n", + " \n", "def find_substr(sub,str):\n", " return str.find(sub)\n", "\n", @@ -831,9 +820,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#Recursive version\n", + " \n", "def factr(n):\n", " if n==1:\n", " return 1\n", @@ -880,9 +867,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#Reversing a string\n", + " \n", "def reverse(s):\n", " r = \"\"\n", " for c in s:\n", diff --git a/C++_from_the_Ground/Chapter_8(1).ipynb b/C++_from_the_Ground/Chapter_8(1).ipynb index 3092696e..4684861e 100644 --- a/C++_from_the_Ground/Chapter_8(1).ipynb +++ b/C++_from_the_Ground/Chapter_8(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:cea79a35a095750f932030d193b34f2136c703d7c2c54113f8e7917863a4322a" + "signature": "sha256:cb32b4e80623f372b375323b458cf1a594dc5626da9cbe9346e1ec33417221d4" }, "nbformat": 3, "nbformat_minor": 0, @@ -427,8 +427,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#myabs() in three ways\n", + " \n", "def myabs(i):\n", " if isinstance(i,int): #first instance\n", " print \"Using integer myabs(): \",\n", diff --git a/C++_from_the_Ground/Chapter_9(1).ipynb b/C++_from_the_Ground/Chapter_9(1).ipynb index 9e6e1729..0f30e9a8 100644 --- a/C++_from_the_Ground/Chapter_9(1).ipynb +++ b/C++_from_the_Ground/Chapter_9(1).ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:9ff1f12edc348acd1b1c3b16cc9a9556459332fb35a1337252165631b4cd82af" + "signature": "sha256:441f69a4dc3d0bee097a6151c42e10920892966ba4b3b82086ec3feb521e7da7" }, "nbformat": 3, "nbformat_minor": 0, @@ -257,8 +257,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "#Array of strings that correspond to the enumeration\n", + " \n", "name=[\"Jonathan\",\"Golden Delicious\",\"Red Delicious\",\"Winesap\",\n", " \"Cortland\",\"McIntosh\"]\n", "\n", @@ -300,9 +299,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#Variable declaration\n", + " \n", "ch='j' #User input\n", "while True:\n", " #This statement turns off the 6th but.\n", @@ -391,9 +388,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#function to display the bits\n", + " \n", "def disp_binary(u):\n", " t=128\n", " while t:\n", @@ -438,9 +433,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#unction to display the bits within a byte\n", + " \n", "def disp_binary(u):\n", " t=128\n", " while t:\n", diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch1.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch1.ipynb index 37aa04ae..834bacf2 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch1.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch1.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:c628e15db0bd7c4697d070eda00c000c028cdbc1d271898882fdd16c63c0f120" + "signature": "sha256:2af50dca95bb8940069ca1eefad39c58f8f97bbf13a194cd9fff16b4f6521b4f" }, "nbformat": 3, "nbformat_minor": 0, @@ -127,7 +127,6 @@ "input": [ "\n", "\n", - "# typename to mark a qualified name as a type name.\n", "def check_assign(a,i,t):\n", " if (i < len(a)):\n", " a[i] = t;" diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch10.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch10.ipynb index 2951ba7c..52781089 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch10.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch10.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:605cfaa74a14889610adf1b63bc80cf152287815885aa99d6c7f0c182f62cc6b" + "signature": "sha256:70f9ab632bffbd9fecc3bdcee575cac266cb09d4df74fddec4e595d028f134df" }, "nbformat": 3, "nbformat_minor": 0, @@ -59,7 +59,7 @@ "input": [ "\n", "s = \"Hello\"\n", - "#s[0] = 'h'\n", + "\n", "s = s.lower()\n", "print s" ], @@ -90,7 +90,7 @@ "\n", "\n", "class EmcCollection:\n", - " # insert one element\n", + " \n", " def insert(self,t):\n", " pass\n", " \n", @@ -180,8 +180,7 @@ "cell_type": "code", "collapsed": true, "input": [ - "ting object\n", - "'''\n", + "\n", "class EmcCollection:\n", " def __del__(self):\n", " pass\n", @@ -399,12 +398,8 @@ "collapsed": true, "input": [ "\n", - "\n", - "# insertObject() works for any class with\n", - "# EmcCollection<T> as public base class.\n", "def insertObject(c,element):\n", - " # throw (bad_alloc)\n", - " # return false if insertion fails, true otherwise\n", + " \n", " if (not c.isFull()):\n", " c.insert(element)\n", " return True\n", @@ -448,12 +443,6 @@ "input": [ "\n", "\n", - "# T must be: DefaultConstructible\n", - "# copyConstructible\n", - "# Assignable\n", - "# Destructible\n", - "# EqualityComparable\n", - "\n", "class EmcCollection:\n", " pass" ], @@ -479,11 +468,11 @@ " pass\n", "\n", " def templateRequirements(self):\n", - " # T must be:\n", + " \n", " t1 = T1()\n", - " # DefaultContructible\n", + " \n", " t2 =t1\n", - " # CopyConstructible\n", + "\n", " t2 = t1;\n", " # Assignable\n", " b = (t2 == t1); # EqualityComparable" diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch11.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch11.ipynb index a7fe619a..9dc6882e 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch11.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch11.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:8fd9f65c8a3cbb619fe291dbff540345e03b3be12cb5c6908ed137d152dc018d" + "signature": "sha256:2e265a79f479b0afc28156201c75dda9d71f161b6acb07438df53ecda65f24e0" }, "nbformat": 3, "nbformat_minor": 0, @@ -48,7 +48,6 @@ "collapsed": true, "input": [ "\n", - "# Checked version\n", "class EmcString:\n", " def at(self,index):\n", " if (index >= self.lengthM):\n", diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch12.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch12.ipynb index d96329cd..a4d7907e 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch12.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch12.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:de2e0bed7b67eb2329c8c600e57f29ce4e5a2c157d6a6ad64246d09e0189ed52" + "signature": "sha256:3fda869111a137bc83ae4b79f3c57ac84f247031c3e08ac7d6dfb9bb168b3105" }, "nbformat": 3, "nbformat_minor": 0, @@ -174,8 +174,7 @@ " ip = 1\n", " g(ip)\n", "\n", - "# Not recommended\n", - "# create int with new\n", + "\n", "def g(i):\n", " raise Exception(i)" ], @@ -201,8 +200,6 @@ " ip = 1\n", " g(ip)\n", "\n", - "# Not recommended\n", - "# create int with new\n", "def g(i):\n", " raise Exception(i)" ], @@ -287,8 +284,7 @@ "class EmcException:\n", " def __init__(self,m):\n", " pass\n", - " # EmcException objects can be printed\n", - "\n", + " \n", " def operator(self,o,EmcException):\n", " pass\n", "\n", diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch13.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch13.ipynb index 126df2ad..a23bdf0e 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch13.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch13.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:bbeb97ae5d957eb9274ccf64bc1e7f46b7b45c306736856a8df6cdc589631d7d" + "signature": "sha256:121cbe714f8e854e8d9ce1fe8dcdc370535cc7140b2f83bdae09063602e644f9" }, "nbformat": 3, "nbformat_minor": 0, @@ -125,7 +125,7 @@ "collapsed": false, "input": [ "\n", - "#define SIZE 1024\n", + "\n", "SIZE = 1024;\n", "print SIZE" ], @@ -201,7 +201,6 @@ "collapsed": false, "input": [ "\n", - "# Not recommended to have function-like macro\n", "def SQUARE(x):\n", " return x*x\n", "\n", @@ -329,9 +328,7 @@ "input": [ "\n", "\n", - "# Fruit is a base class\n", "def printFruits(fruits,size):\n", - " # Not recommended to pass arrays to functions\n", " for i in range(size):\n", " print fruits[i] " ], diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch15.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch15.ipynb index 9ba32dd4..32ad5666 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch15.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch15.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:7951193995e49370edf3fafb6d685d317214f33d43101f294ebf8961471bb078" + "signature": "sha256:24f5f3b754e3fd6e8afab7bcb99e41e817ec5bce9faae498ba9fb75dd53f93ff" }, "nbformat": 3, "nbformat_minor": 0, @@ -193,8 +193,7 @@ "input": [ "\n", "\n", - "import math\n", - "# import Math # does not work" + "import math\n" ], "language": "python", "metadata": {}, @@ -594,9 +593,7 @@ "i = 0\n", "a[i] = i;\n", "i += 1\n", - "print i \n", - "# NO: i may be incremented before or\n", - "# after its value is used on" + "print i \n" ], "language": "python", "metadata": {}, diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch2.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch2.ipynb index faabf783..8660012f 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch2.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch2.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:47670c105df749836e80ebb95394825725c9958056aa9467a60adf31201b90cb" + "signature": "sha256:025b4c65298f5bb6d48b99d717b6d0fce940f5a97ad7eb75ea5897c4c9595891" }, "nbformat": 3, "nbformat_minor": 0, @@ -60,9 +60,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", - "#import A \n", + " \n", "\n", "class X :\n", " def __init__(self):\n", diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch3.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch3.ipynb index dab765f1..ce027b4e 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch3.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch3.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:ea79adc8d9da30a7f64270d4281f6f246d2c16fc489ed1f94a45b5b3b8be3491" + "signature": "sha256:dbc95d125151940c8402c8ffda427c3e959c7eb724b40434b79a3b03a164fff8" }, "nbformat": 3, "nbformat_minor": 0, @@ -94,13 +94,40 @@ { "metadata": {}, "output_type": "pyout", - "prompt_number": 4, + "prompt_number": 2, "text": [ "' No: this nesting of C-style comments will not work !!!\\nchar* cpM;\\nint lenM;\\n# A pointer to the characters\\n# The length of the character array \\n'" ] } ], - "prompt_number": 4 + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 }, { "cell_type": "code", diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch5.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch5.ipynb index c0f0e5a6..4e630070 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch5.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch5.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:f452e228ccf497c46b256d665e9e2f574a49ac9ecca7f62127c2ea4d07013e6d" + "signature": "sha256:862ed788d417ee363a92882e2a970648b380a2f974a44d4fd4e62dfc3b0fcdf2" }, "nbformat": 3, "nbformat_minor": 0, @@ -51,8 +51,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# Not recommended\n", "string1 = \"hello\";\n", "string2 = \"hello\"; \n", "print string1, string2" @@ -142,9 +140,7 @@ "collapsed": false, "input": [ "\n", - "# Literal in definition of const,\n", "charMapSize = 256;\n", - "# but not to specify array size!\n", "for i in range(charMapSize):\n", " pass" ], diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch6.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch6.ipynb index a35d9ee7..3f83e4d0 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch6.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch6.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:02be36ad85c7df4dace913f54f3ea199522926d07ecd14544c2024f6326359fd" + "signature": "sha256:7e4ca4515204ca5f28b7ad14f25998ad16f2910d212e32a1071b57e6d0d7e56b" }, "nbformat": 3, "nbformat_minor": 0, @@ -127,16 +127,15 @@ " pass\n", " \n", "def dynamicCast(b):\n", - " # Must use dynamic_cast when base class is virtual.\n", + " \n", " return D(b)\n", "\n", "def constCast(d1):\n", - " # Should use const_cast when casting away const.\n", + " \n", " return D(d1)\n", "\n", "def reinterpretCast(d):\n", - " # Should use reinterpret_cast when casting pointer\n", - " # to pointer of unrelated type.\n", + " \n", " return E(d)" ], "language": "python", @@ -184,12 +183,11 @@ "collapsed": false, "input": [ "\n", - "\n", - "# ci may be in write-protected memory\n", + " \n", "ci = 22;\n", "pi = ci # NO: Const cast away\n", "i = pi; # OK\n", - "# writing into write-protected memory?\n", + " \n", "pi = 7 \n", "print ci, pi, i " ], diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch7.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch7.ipynb index 753ae756..f8b112a8 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch7.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch7.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:bef0a5b42b24e0648e81ec34d8c7331f906450b7163d1ed429e0503042ac5057" + "signature": "sha256:fbefe45753ab0203894f5afad5e792e20da756faab0edd14dfdedec2c8be513a" }, "nbformat": 3, "nbformat_minor": 0, @@ -677,8 +677,7 @@ "def f(x,y = 2):\n", " print x\n", " print y\n", - "#void f(int x = 1, int y); // NOT RECOMMENDED\n", - "\n", + " \n", "f(1)\n", "f(2,3)" ], diff --git a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch8.ipynb b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch8.ipynb index 1449db62..657c42ba 100644 --- a/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch8.ipynb +++ b/C++_in_Action_-_Industrial-Strength_Programming_Techniques/ch8.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:90db160243231bb1b3699a6dc0bde758daa5bf22473aeb4fd74b345857a46432" + "signature": "sha256:9aeef576f29f7c783f96768a664cb437cbd4922734a99612921a48bd58c127b5" }, "nbformat": 3, "nbformat_minor": 0, @@ -124,7 +124,7 @@ "\n", "maxSize = 100; # get storage for object\n", "storage = [] # call placement new to create object\n", - "#ap1 = A(); # A() class is not defined here." + " " ], "language": "python", "metadata": {}, diff --git a/Electronic_Devices_/Chapter10.ipynb b/Electronic_Devices_/Chapter10.ipynb index 696f96b2..ad380243 100644 --- a/Electronic_Devices_/Chapter10.ipynb +++ b/Electronic_Devices_/Chapter10.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:f003b1f1cd26176eb417b448a8cfca349700fbb49c6916dd3657fc77d5dd4cf3" + "signature": "sha256:46b495ee163997b315e5d2a4308b2429d2950dd9bb4f2a5562e7098cc144cbec" }, "nbformat": 3, "nbformat_minor": 0, @@ -28,7 +28,7 @@ "input": [ "\n", "import math\n", - "#Pout/P in=250;\n", + "\n", "A_p=250.0\n", "A_p_dB=10*math.log10(A_p)\n", "print('Power gain(dB) when power gain is 250 = %d'% math.ceil(A_p_dB));\n", diff --git a/Electronic_Devices_/Chapter17.ipynb b/Electronic_Devices_/Chapter17.ipynb index 6e48c896..a95b29db 100644 --- a/Electronic_Devices_/Chapter17.ipynb +++ b/Electronic_Devices_/Chapter17.ipynb @@ -1,313 +1,336 @@ { "metadata": { - "name": "Chapter_17" - }, - "nbformat": 2, + "name": "", + "signature": "sha256:dca2eb0dc5462992ceade27e53e297f6073a62b5b813c53a51758356342ce482" + }, + "nbformat": 3, + "nbformat_minor": 0, "worksheets": [ { "cells": [ { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h1>Chapter 17: Voltage Regulators<h1>" ] - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 17.1, Page Number:552 <h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ "%pylab inline" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ - "", - "Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].", + "\n", + "Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].\n", "For more information, type 'help(pylab)'." ] } - ], + ], "prompt_number": 1 - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "#variable declaration", - "Del_V_out=0.25;", - "V_out=15;", - "Del_V_in=5; #All voltages in Volts", - "", - "#Calculations", - "line_regulation=((Del_V_out/V_out)/Del_V_in)*100;", - "", - "#Result", + "\n", + "#variable declaration\n", + "Del_V_out=0.25;\n", + "V_out=15;\n", + "Del_V_in=5; #All voltages in Volts\n", + "\n", + "#Calculations\n", + "line_regulation=((Del_V_out/V_out)/Del_V_in)*100;\n", + "\n", + "#Result\n", "print('line regulation in %%V is %f' %line_regulation)" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "line regulation in %V is 0.333333" ] } - ], + ], "prompt_number": 2 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 17.2, Page Number: 553<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "# Variable Declaration", - "V_NL=12.0; #No load output voltage in Volts", - "V_FL=11.9; #Full load output voltage in Volts", - "I_F=10.0; #Full load current in milli-Amperes", - "", - "#Calculations", - "load_regulation=((V_NL-V_FL)/V_FL)*100;", - "load_reg=load_regulation/I_F;", - "", - "#Result", - "print('load regulation as percentage change from no load to full load = %f'%load_regulation)", + "\n", + "# Variable Declaration\n", + "V_NL=12.0; #No load output voltage in Volts\n", + "V_FL=11.9; #Full load output voltage in Volts\n", + "I_F=10.0; #Full load current in milli-Amperes\n", + "\n", + "#Calculations\n", + "load_regulation=((V_NL-V_FL)/V_FL)*100;\n", + "load_reg=load_regulation/I_F;\n", + "\n", + "#Result\n", + "print('load regulation as percentage change from no load to full load = %f'%load_regulation)\n", "print('\\nload regulation as percentage change per milliampere = %f' %load_reg)" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ - "load regulation as percentage change from no load to full load = 0.840336", - "", + "load regulation as percentage change from no load to full load = 0.840336\n", + "\n", "load regulation as percentage change per milliampere = 0.084034" ] } - ], + ], "prompt_number": 3 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 17.3, Page Number: 556<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "", - "V_REF=5.1 #Zener voltage in volts", - "R2=10*10**3;", - "R3=10*10**3; #resistances in ohm", - "V_out=(1+(R2/R3))*V_REF;", + "\n", + "\n", + "V_REF=5.1 #Zener voltage in volts\n", + "R2=10*10**3;\n", + "R3=10*10**3; #resistances in ohm\n", + "V_out=(1+(R2/R3))*V_REF;\n", "print('output voltage in volts = %.1f'%V_out)" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "output voltage in volts = 10.2" ] } - ], + ], "prompt_number": 4 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 17.4, Page Number: 557<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "R4=1; #Resistance in Ohms", - "I_L_max=0.7/R4;", + "\n", + "R4=1; #Resistance in Ohms\n", + "I_L_max=0.7/R4;\n", "print('maximum current provided to load(in amperes) = %.1f'%I_L_max)" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "maximum current provided to load(in amperes) = 0.7" ] } - ], + ], "prompt_number": 5 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 17.5, Page Number: 560<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "V_IN=12.5; #maximum input voltage in volts", - "R1=22; #In Ohms", - "#Worst case of power dissipation is when V_OUT=0V", - "V_OUT=0;", - "V_R1=V_IN-V_OUT; #Voltage across R1", - "P_R1=(V_R1*V_R1)/R1; #maximum power dissipated by R1", + "\n", + "V_IN=12.5; #maximum input voltage in volts\n", + "R1=22; #In Ohms\n", + "\n", + "V_OUT=0;\n", + "V_R1=V_IN-V_OUT; #Voltage across R1\n", + "P_R1=(V_R1*V_R1)/R1; #maximum power dissipated by R1\n", "print('maximum power dissipated by R1 in WATTS = %f'%P_R1)" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "maximum power dissipated by R1 in WATTS = 7.102273" ] } - ], + ], "prompt_number": 6 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 17.6, Page Number: 569<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", + "\n", "print('SAME AS EX-2.8 in CHAPTER-2')" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "SAME AS EX-2.8 in CHAPTER-2" ] } - ], + ], "prompt_number": 7 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 17.7, Page Number: 572<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "I_max=700*10**-3; #in Amperes", - "R_ext=0.7/I_max;", + "\n", + "I_max=700*10**-3; #in Amperes\n", + "R_ext=0.7/I_max;\n", "print('value of resistor in Ohms for which max current is 700mA = %f'%R_ext)" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "value of resistor in Ohms for which max current is 700mA = 1.000000" ] } - ], + ], "prompt_number": 8 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 17.8, Page Number: 572<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "V_OUT=24.0; #Output voltage in Volts", - "R_L=10.0; #Load resistance in Ohms", - "V_IN=30.0; #Input voltage in Volts", - "I_max=700.0*10**-3; #maximum interal current in Amperes", - "I_L=V_OUT/R_L; #load current in amperes", - "I_ext=I_L-I_max; #current through the external pass transistor in Amperes", - "P_ext_Qext=I_ext*(V_IN-V_OUT); #power dissipated", - "print('power dissiated(in WATTS) by the external pass transistor = %.1f'%P_ext_Qext)", + "\n", + "V_OUT=24.0; #Output voltage in Volts\n", + "R_L=10.0; #Load resistance in Ohms\n", + "V_IN=30.0; #Input voltage in Volts\n", + "I_max=700.0*10**-3; #maximum interal current in Amperes\n", + "I_L=V_OUT/R_L; #load current in amperes\n", + "I_ext=I_L-I_max; #current through the external pass transistor in Amperes\n", + "P_ext_Qext=I_ext*(V_IN-V_OUT); #power dissipated\n", + "print('power dissiated(in WATTS) by the external pass transistor = %.1f'%P_ext_Qext)\n", "print('\\nFor safety purpose, we choose a power transistor with rating more than this, say 15W')" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ - "power dissiated(in WATTS) by the external pass transistor = 10.2", - "", + "power dissiated(in WATTS) by the external pass transistor = 10.2\n", + "\n", "For safety purpose, we choose a power transistor with rating more than this, say 15W" ] } - ], + ], "prompt_number": 9 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 17.9, Page Number: 574<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "V_out=5.0; #7805 gives output voltage of 5V", - "I_L=1.0; #constant current of 1A", - "R1=V_out/I_L;", + "\n", + "V_out=5.0; #7805 gives output voltage of 5V\n", + "I_L=1.0; #constant current of 1A\n", + "R1=V_out/I_L;\n", "print('The value of current-setting resistor in ohms = %d'%R1)" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "The value of current-setting resistor in ohms = 5" ] } - ], + ], "prompt_number": 10 } - ] + ], + "metadata": {} } ] }
\ No newline at end of file diff --git a/Electronic_Devices_/Chapter2.ipynb b/Electronic_Devices_/Chapter2.ipynb index ac5794a8..3934869f 100644 --- a/Electronic_Devices_/Chapter2.ipynb +++ b/Electronic_Devices_/Chapter2.ipynb @@ -1,594 +1,629 @@ { "metadata": { - "name": "Chapter_2" - }, - "nbformat": 2, + "name": "", + "signature": "sha256:d0aa9e80db4a8882af89cf646425004e4e19d2bf8cf22acae2943bf211cb0ab1" + }, + "nbformat": 3, + "nbformat_minor": 0, "worksheets": [ { "cells": [ { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h1>Chapter 2: Diode Application<h1>" ] - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.1, Page Number: 46<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ "%pylab inline" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ - "", - "Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].", + "\n", + "Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].\n", "For more information, type 'help(pylab)'." ] } - ], + ], "prompt_number": 1 - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "import math", - "", - "# variable declaration", - "V_p=50; #Peak value is 50V", - "", - "#calculation", - "V_avg=V_p/math.pi;", - "", - "#result", + "\n", + "import math\n", + "\n", + "# variable declaration\n", + "V_p=50; #Peak value is 50V\n", + "\n", + "#calculation\n", + "V_avg=V_p/math.pi;\n", + "\n", + "#result\n", "print \"average value of half wave rectifier = %.2f volts\" %V_avg" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "average value of half wave rectifier = 15.92 volts" ] } - ], + ], "prompt_number": 2 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.2(a), Page Number: 46<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "import math", - "", - "# variable declaration", - "#let V_in=5*sin(2*%pi*f.*t) be input wave ,hence frequency=1Hz", - "f=1; #frequency", - "V_p_in=5; #peak input", - "", - "#calculation", - "V_pout=V_p_in-0.7; #output voltage", - "t_d=(math.asin(0.7/V_p_in))/(2*math.pi*f);", - "", - "#result", + "\n", + "import math\n", + "\n", + "\n", + "f=1; #frequency\n", + "V_p_in=5; #peak input\n", + "\n", + "#calculation\n", + "V_pout=V_p_in-0.7; #output voltage\n", + "t_d=(math.asin(0.7/V_p_in))/(2*math.pi*f);\n", + "\n", + "#result\n", "print \"half wave rectifier output = %.2f volts\" %V_pout;" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "half wave rectifier output = 4.30 volts" ] } - ], + ], "prompt_number": 3 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.2(b), Page Number: 46<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "import math", - "", - "# variable declaration", - "#let V_in=100*sin(2*%pi*f.*t) be input wave ,hence frequency=1Hz", - "f=1; #frequency", - "T=1/f; #time period", - "V_p_in=100; #peak input voltage", - "", - "#calculation", - "V_pout=(V_p_in-0.7); #peak output ", - "t_d=(math.asin(0.7/V_p_in))/(2*math.pi*f) ", - "", - "#result", + "\n", + "import math\n", + "\n", + "\n", + "f=1; #frequency\n", + "T=1/f; #time period\n", + "V_p_in=100; #peak input voltage\n", + "\n", + "#calculation\n", + "V_pout=(V_p_in-0.7); #peak output \n", + "t_d=(math.asin(0.7/V_p_in))/(2*math.pi*f) \n", + "\n", + "#result\n", "print \"output of half wave rectifier = %.2f volts\" %V_pout" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "output of half wave rectifier = 99.30 volts" ] } - ], + ], "prompt_number": 4 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.3, Page Number: 48<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "import math", - "", - "# variable declaration", - "V_p_in=156; #Peak input voltage", - "V_p_pri=156; #Peak voltage of primary of transformer", - "n=0.5; #Turn ratio is 2:1", - "", - "#calculation", - "V_p_sec=n*V_p_pri;", - "V_p_out=(V_p_sec-0.7); #Peak output voltage", - "", - "#result", + "\n", + "import math\n", + "\n", + "# variable declaration\n", + "V_p_in=156; #Peak input voltage\n", + "V_p_pri=156; #Peak voltage of primary of transformer\n", + "n=0.5; #Turn ratio is 2:1\n", + "\n", + "#calculation\n", + "V_p_sec=n*V_p_pri;\n", + "V_p_out=(V_p_sec-0.7); #Peak output voltage\n", + "\n", + "#result\n", "print \"peak output voltage of half wave rectifier = %.1f volts\" %V_p_out" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "peak output voltage of half wave rectifier = 77.3 volts" ] } - ], + ], "prompt_number": 5 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.4, Page Number: 49<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "import math", - "", - "# variable declaration", - "V_p=15; #Peak voltage in volt", - "", - "#calculation", - "V_avg=(2*V_p)/math.pi;", - "", - "#result", + "\n", + "import math\n", + "\n", + "# variable declaration\n", + "V_p=15; #Peak voltage in volt\n", + "\n", + "#calculation\n", + "V_avg=(2*V_p)/math.pi;\n", + "\n", + "#result\n", "print \"Average value of output of full wave rectifier = %.2f volts\" %V_avg" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "Average value of output of full wave rectifier = 9.55 volts" ] } - ], + ], "prompt_number": 6 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.5, Page Number: 52<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "V_p_pri=100.0; #Peak voltage across primary winding", - "n=1.0/2; #tun ratio is 2:1", - "V_p_sec=n*V_p_pri;", - "V_sec=V_p_sec/2; #voltage across each secondary is half the total voltage", - "V_pout=V_sec-0.7;", - "", - "print('full wave rectifier output voltage = %f V'%V_pout)", - "PIV=2*V_pout+0.7;", + "\n", + "V_p_pri=100.0; #Peak voltage across primary winding\n", + "n=1.0/2; #tun ratio is 2:1\n", + "V_p_sec=n*V_p_pri;\n", + "V_sec=V_p_sec/2; #voltage across each secondary is half the total voltage\n", + "V_pout=V_sec-0.7;\n", + "\n", + "print('full wave rectifier output voltage = %f V'%V_pout)\n", + "PIV=2*V_pout+0.7;\n", "print('PIV = %fV'%PIV)" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ - "full wave rectifier output voltage = 24.300000 V", + "full wave rectifier output voltage = 24.300000 V\n", "PIV = 49.300000V" ] } - ], + ], "prompt_number": 7 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.6, Page Number: 54<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "import math", - "", - "# variable declaration", - "V_rms=12.0; #rms secondary voltage", - "", - "#calculation", - "V_p_sec=math.sqrt(2)*V_rms; #peak secondary voltage", - "V_th=0.7; #knee voltage of diode", - "V_p_out=V_p_sec-2*V_th; #in one cycle, 2 diodes conduct", - "PIV=V_p_out+V_th; #applying KVL", - "", - "#result", - "print \"Peak output voltage = %.2f volt\" %V_p_out", + "\n", + "import math\n", + "\n", + "# variable declaration\n", + "V_rms=12.0; #rms secondary voltage\n", + "\n", + "#calculation\n", + "V_p_sec=math.sqrt(2)*V_rms; #peak secondary voltage\n", + "V_th=0.7; #knee voltage of diode\n", + "V_p_out=V_p_sec-2*V_th; #in one cycle, 2 diodes conduct\n", + "PIV=V_p_out+V_th; #applying KVL\n", + "\n", + "#result\n", + "print \"Peak output voltage = %.2f volt\" %V_p_out\n", "print \"PIV across each diode = %.2f volt\" %PIV" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ - "Peak output voltage = 15.57 volt", + "Peak output voltage = 15.57 volt\n", "PIV across each diode = 16.27 volt" ] } - ], + ], "prompt_number": 8 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.7, Page Number: 58<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "import math", - "", - "# variable declaration", - "R_l=2200; #load resistance in Ohm", - "C=50*10**-6; #capacitance in Farad", - "V_rms=115; #rms of primary", - "", - "#calculation", - "V_p_pri=math.sqrt(2)*V_rms; #peak voltage across primary", - "n=0.1; #turn ratio is 10:1", - "V_p_sec=n*V_p_pri; #primary voltage across secondary", - "V_p_rect=V_p_sec-1.4 #unfiltered peak rectified voltage", - "#we subtract 1.4 because in each cycle 2 diodes conduct & 2 do not", - "f=120; #frequency of full wave rectified voltage", - "V_r_pp=(1/(f*R_l*C))*V_p_rect; #peak to peak ripple voltage", - "V_DC=(1-(1/(2*f*R_l*C)))*V_p_rect;", - "r=V_r_pp/V_DC;", - "", - "#result", + "\n", + "import math\n", + "\n", + "# variable declaration\n", + "R_l=2200; #load resistance in Ohm\n", + "C=50*10**-6; #capacitance in Farad\n", + "V_rms=115; #rms of primary\n", + "\n", + "#calculation\n", + "V_p_pri=math.sqrt(2)*V_rms; #peak voltage across primary\n", + "n=0.1; #turn ratio is 10:1\n", + "V_p_sec=n*V_p_pri; #primary voltage across secondary\n", + "V_p_rect=V_p_sec-1.4 #unfiltered peak rectified voltage\n", + "#we subtract 1.4 because in each cycle 2 diodes conduct & 2 do not\n", + "f=120; #frequency of full wave rectified voltage\n", + "V_r_pp=(1/(f*R_l*C))*V_p_rect; #peak to peak ripple voltage\n", + "V_DC=(1-(1/(2*f*R_l*C)))*V_p_rect;\n", + "r=V_r_pp/V_DC;\n", + "\n", + "#result\n", "print \"Ripple factor = %.3f \" %r" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "Ripple factor = 0.079 " ] } - ], + ], "prompt_number": 9 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.8, Page Number: 62<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "import math", - "", - "# variable declaration", - "V_REF=1.25; #in volts", - "V_R1=V_REF; #voltage in volt", - "R1=220.0; #in ohms", - "I_ADJ=50*10**-6 #in amperes", - "", - "#calculation", - "# MAX VALUE OF R2=5000 Ohms", - "R2_min=0.0; #min resistance", - "V_out_min=V_REF*(1+(R2_min/R1))+I_ADJ*R2_min;", - "R2_max=5000.0; #max value of resistance", - "V_out_max=V_REF*(1+(R2_max/R1))+I_ADJ*R2_max;", - "", - "#result", - "print \"minimum output voltage = %.2f volt\" %V_out_min", + "\n", + "import math\n", + "\n", + "# variable declaration\n", + "V_REF=1.25; #in volts\n", + "V_R1=V_REF; #voltage in volt\n", + "R1=220.0; #in ohms\n", + "I_ADJ=50*10**-6 #in amperes\n", + "\n", + "#calculation\n", + "# MAX VALUE OF R2=5000 Ohms\n", + "R2_min=0.0; #min resistance\n", + "V_out_min=V_REF*(1+(R2_min/R1))+I_ADJ*R2_min;\n", + "R2_max=5000.0; #max value of resistance\n", + "V_out_max=V_REF*(1+(R2_max/R1))+I_ADJ*R2_max;\n", + "\n", + "#result\n", + "print \"minimum output voltage = %.2f volt\" %V_out_min\n", "print \"maximum output voltage = %.2f volt\" %V_out_max" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ - "minimum output voltage = 1.25 volt", + "minimum output voltage = 1.25 volt\n", "maximum output voltage = 29.91 volt" ] } - ], + ], "prompt_number": 10 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.9,Page Number: 64<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "V_NL=5.18 #No load output voltage", - "V_FL=5.15 #Full load output voltage", - "load_reg=((V_NL-V_FL)/V_FL)*100 #In percentage", + "\n", + "V_NL=5.18 #No load output voltage\n", + "V_FL=5.15 #Full load output voltage\n", + "load_reg=((V_NL-V_FL)/V_FL)*100 #In percentage\n", "print('load regulation percent = %.2f%% '%load_reg)" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "load regulation percent = 0.58% " ] } - ], + ], "prompt_number": 11 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.10, Page Number: 66<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "import pylab as py", - "import numpy as np", - "", - "#let input wave be V_in=V_p_in*sin(2*%pi*f*t) ", - "f=1.0; #Frequency is 1Hz", - "T=1/f;", - "R_1=100.0; #Resistances in ohms", - "R_L=1000.0; #Load", - "V_p_in=10.0; #Peak input voltage", - "V_th=0.7; #knee voltage of diode", - "", - "V_p_out=V_p_in*(R_L/(R_L+R_1)); #peak output voltage", - "print('peak output voltage = %.2f V'%V_p_out)", - "", - "t = np.arange(0, 3.5 , 0.0005)", - "z=V_p_in*np.sin(2*np.pi*f*t)*(R_L/(R_L+R_1))", - "", - "subplot(211)", - "plot(t,z)", - "ylim(-9.09,9.09)", - "title('Input Voltage Waveform')", - "", - "subplot(212)", - "plot(t,z)", - "ylim(-0.07,9.09)", + "\n", + "import pylab as py\n", + "import numpy as np\n", + "\n", + "#let input wave be V_in=V_p_in*sin(2*%pi*f*t) \n", + "f=1.0; #Frequency is 1Hz\n", + "T=1/f;\n", + "R_1=100.0; #Resistances in ohms\n", + "R_L=1000.0; #Load\n", + "V_p_in=10.0; #Peak input voltage\n", + "V_th=0.7; #knee voltage of diode\n", + "\n", + "V_p_out=V_p_in*(R_L/(R_L+R_1)); #peak output voltage\n", + "print('peak output voltage = %.2f V'%V_p_out)\n", + "\n", + "t = np.arange(0, 3.5 , 0.0005)\n", + "z=V_p_in*np.sin(2*np.pi*f*t)*(R_L/(R_L+R_1))\n", + "\n", + "subplot(211)\n", + "plot(t,z)\n", + "ylim(-9.09,9.09)\n", + "title('Input Voltage Waveform')\n", + "\n", + "subplot(212)\n", + "plot(t,z)\n", + "ylim(-0.07,9.09)\n", "title('Output Voltage Waveform')" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "peak output voltage = 9.09 V" ] - }, + }, { - "output_type": "pyout", - "prompt_number": 12, + "metadata": {}, + "output_type": "pyout", + "prompt_number": 12, "text": [ "<matplotlib.text.Text at 0xa3bf44c>" ] - }, + }, { - "output_type": "display_data", + "metadata": {}, + "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAXUAAAEICAYAAACgQWTXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXl4TNcbx78TiSWWiC1kIYgtliSEoEJCa21SlFoqYqvu\npTtKaavtT1vVhaou9tpVaZFaakpjJ4RErImEBIkQ2cgy5/fHa0YSk2Qy9965986cz/N4Hpm5c86b\nd06+973vOec9GsYYA4fD4XCsAju5DeBwOByOeHBR53A4HCuCizqHw+FYEVzUORwOx4rgos7hcDhW\nBBd1DofDsSK4qHMUj1arhYeHh9xmKIbc3FyEhISgdu3aGDFihNzmcBQGF3Urx9PTE3v37pW8nzlz\n5iAsLKzU9/v374/Zs2c/9vrWrVvRqFEj6HQ6k/vy9PTEP//8Y5adQli7di28vb2LvfbUU08ZfW3e\nvHmS2bFp0ybcunUL6enpWL9+vWT9cNQJF3UrR6PRQKPRyG0Gxo0bh9WrVz/2+qpVqzBmzBjY2Zk+\nFDUaDeTYM9ezZ0/ExcXh9u3bAICCggKcPn0a9+/fR1pamuG1w4cPo1evXpLZcfXqVbRs2bJCPtNT\nUFAggUUcRcE4Vo2npyfbu3cvY4yxZcuWsSeeeIK98847zNnZmTVt2pTt3LnTcG2vXr3YtGnTWJcu\nXVitWrXYM888w9LT0xljjO3bt4+5u7sXa7tJkyZsz549bOfOnaxy5crMwcGB1ahRg/n6+j5mR05O\nDnNycmL79+83vJaens6qVq3KoqOj2f3799mUKVOYq6src3V1ZVOnTmUPHjx4rO8xY8YwOzs7Vq1a\n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AQEBBR7XQ3fQWm2K93/Op0Ovr6+cHFxQXBw\nMLy9vYu9r3Tfl2e/Of43e/VL0U5NoeTdRikbk0yxo2PHjkhKSoKjoyN27tyJwYMH44KKzltTqu9N\nQS2+z8rKwrBhw/Dtt9+ihpEC6kr+DsqyXen+t7Ozw6lTp5CRkYF+/fpBq9U+tmtdyb4vz35z/C84\nUjdlE1LJa65duwY3NzehXYuCKfbXrFnT8Jg0YMAA5OfnI10lRWGU7HtTUIPv8/Pz8eyzz2LMmDEY\nPHjwY+8r+Tsoz3Y1+B8AnJycMGjQIBw/frzY60r2fVFKs98c/wsWdVM2IYWGhmLlypUAgMOHD6N2\n7dpwcXER2rUomGL/zZs3DXf7o0ePgjFmNPelRJTse1NQuu8ZY5g4cSK8vb0xdepUo9co9TswxXYl\n+z8tLQ13794FAOTm5mL37t3w8/Mrdo1SfQ+YZr85/hecfiltE9KSJUsAAC+++CIGDhyIHTt2wMvL\nC9WrV8eyZcuEdisapti/adMmLF68GPb29nB0dMS6detktvoRo0aNwr///ou0tDR4eHjgo48+Qv7D\nE7OV7nugfPuV7HsAiIyMxOrVq9GhQwfDH+Rnn32GxMREAMr+DkyxXcn+T0lJQXh4OHQ6HXQ6HcLC\nwtCnTx/VaI8p9pvjf775iMPhcKwIyY+z43A4HI7l4KLO4XA4VgQXdQ6Hw7EiuKhzOByOFcFFncPh\ncKwILuocDodjRfwfUaYhEUjyJ+wAAAAASUVORK5CYII=\n" } - ], + ], "prompt_number": 12 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.11, Page Number: 67<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "#from pylab import figure, show", - "#from numpy import arange, sin, pi,bool", - "#import numpy as np", - "import pylab as py", - "import numpy as np", - "#let input wave be V_in=V_p_in*sin(2*%pi*f*t) ", - "f=1.0; #Frequency is 1Hz", - "T=1/f;", - "V_p_in=10; #Peak input voltage", - "V_th=0.7; #knee voltage of diode", - "print('max output voltage is 5.7V')", - "print('min output voltage is -5.7V')", - "", - "###############GRAPH Plotting#################################", - "t = arange(0.0,4.5,0.0005)", - "V_in=V_p_in*sin(2*pi*f*t);", - "", - "Vout=V_in;", - "#fig = figure(2)", - "subplot(211)", - "plot(t,V_in)", - "#ax2.grid(True)", - "ylim( (-10,10) )", - "title('Input to the +ve and -ve diode limiter ')", - "subplot(212)", - "plot(t,V_in)", - "#ax1.grid(True)", - "ylim( (-5.7,5.7) )", - "title('Output of +ve and -ve diode limiter')", + "\n", + "#from pylab import figure, show\n", + "#from numpy import arange, sin, pi,bool\n", + "#import numpy as np\n", + "import pylab as py\n", + "import numpy as np\n", + "#let input wave be V_in=V_p_in*sin(2*%pi*f*t) \n", + "f=1.0; #Frequency is 1Hz\n", + "T=1/f;\n", + "V_p_in=10; #Peak input voltage\n", + "V_th=0.7; #knee voltage of diode\n", + "print('max output voltage is 5.7V')\n", + "print('min output voltage is -5.7V')\n", + "\n", + "###############GRAPH Plotting#################################\n", + "t = arange(0.0,4.5,0.0005)\n", + "V_in=V_p_in*sin(2*pi*f*t);\n", + "\n", + "Vout=V_in;\n", + "#fig = figure(2)\n", + "subplot(211)\n", + "plot(t,V_in)\n", + "#ax2.grid(True)\n", + "ylim( (-10,10) )\n", + "title('Input to the +ve and -ve diode limiter ')\n", + "subplot(212)\n", + "plot(t,V_in)\n", + "#ax1.grid(True)\n", + "ylim( (-5.7,5.7) )\n", + "title('Output of +ve and -ve diode limiter')\n", " " - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ - "max output voltage is 5.7V", + "max output voltage is 5.7V\n", "min output voltage is -5.7V" ] - }, + }, { - "output_type": "pyout", - "prompt_number": 13, + "metadata": {}, + "output_type": "pyout", + "prompt_number": 13, "text": [ "<matplotlib.text.Text at 0xa6c976c>" ] - }, + }, { - "output_type": "display_data", + "metadata": {}, + "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAXsAAAEICAYAAAC+iFRkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsnXlYldX2x7+HQQFBZJBZZlBBRcxEUxI0BxxKsxRNzbK5\nvJm3uln5E7uledUGs8G6XdHMuUFTwhGcUKkky1lGmcUEZZLhnP37Y3eODOfAyznvsN/j+3keHuWc\n9+y9zmLt9a537b3XVhFCCBQUFBQUzBoLqQVQUFBQUBAexdkrKCgo3AUozl5BQUHhLkBx9goKCgp3\nAYqzV1BQULgLUJy9goKCwl2A4uwVOJOamooePXpILQYTzJkzB4sWLZJaDMTExODrr78GAHz77bcY\nM2aMUe0kJCRg1qxZRn3W398fhw4dAgAsXboUTz/9tFHtmCK/Qvsozp5n/P39cfDgQcH74TI4mw5C\nY7CwsEB2drbRnzdnVCoVVCqV1GI0k+Oxxx7D3r17jW7HFBm0vPnmm/jqq6+Maqel/Ir98Yvi7HmG\nFScAUFlM3TMn1p47Cwv5maKyH1F4jNVxY2Mjz5LIH/mNMBmRmJiIYcOG4bXXXoOzszMCAwORnJys\nez8mJgYLFy5EVFQUHB0dMWnSJJSXlwPQnzLRPjUkJydj2bJl2Lp1KxwcHBAZGdmq71mzZuHq1auY\nOHEiHBwcsHLlSgDArl27EB4eDicnJ8TGxuLixYt6Zb///vsBABEREXBwcMD27dt1733wwQdwd3eH\nl5cXEhMTda/X1dXh1VdfhZ+fHzw8PPD888/j9u3bxinv7/a6deuGc+fO6V4rKyuDnZ0drl+/DgDY\nvXs3+vfvDycnJwwdOhR//vmnwfZefvll+Pr6wtHREQMHDsSxY8d07yUkJGDq1Kl4/PHH0bVrV/Tp\n0we//fab7v2MjAwMGDAAXbt2RXx8POfvxfd32L9/P3r16oVu3bph3rx5zZxhYmIioqOjdb+npaXh\n3nvvRbdu3TBo0CCcOHFC915OTg6GDx+Orl27YvTo0TpZtJw8eRL33Xcfn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Bjy2sKCgrg7e0tqUwODg66x824uDg0NDTgxo0bgsnUHmLr\niCtS6amhoQFTpkzBzJkz9Rq5FPpqTyYpbcrR0RHjx4/Hr7/+2ux1Ke3KkExi6yktLQ27du1CQEAA\npk+fjkOHDmH27NnNrhFbT1xkMkpPxk8ftE9DQwMJDAwkOTk5pK6urt0J2hMnTgg++cFFppKSEqLR\naAghhJw6dYr4+fkJKhMhhOTk5HCaoBVDR1zlkkJPGo2GzJo1i8yfP9/gNWLri4tMYuuqrKyMlJeX\nE0IIqampIdHR0eTAgQPNrhFbT1xkksKmtKSmppIJEya0el3K8WdIJmP0JGi5BCsrK6xZswZjxoyB\nWq3G3Llz0bt3b6xduxYA8Oyzz2LcuHFISkpCcHAwunTpgnXr1gkpEieZduzYgc8//xxWVlaws7PD\nli1bBJVp+vTpOHz4MK5fv44ePXpgyZIlaGho0Mkjto64yiW2ngDg+PHj2LhxI/r164fIyEgAwNKl\nS3H16lWdXGLri4tMYuuquLgYj/9/O3dsAkAMQgHU3ZwjZP8l5KqDlOGKs/C9CUSSXwi6d1RVVFWs\ntSIzW//eTU0db+r0jmc6+3RT05c+tRxCA+BfNmgBBhD2AAMIe4ABhD3AAMIeYABhDzDAAwJBIdo4\nx/PeAAAAAElFTkSuQmCC\n" } - ], + ], "prompt_number": 13 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.12, Page Number: 76<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "#variable declaration", - "V_p_in=18.0; #peak input voltage is 18V", - "V_supply=12.0;", - "R2=100.0;", - "R3=220.0; #resistances in ohms", - "#calculation", - "V_bias=V_supply*(R3/(R2+R3));", - "", - "#result", + "\n", + "#variable declaration\n", + "V_p_in=18.0; #peak input voltage is 18V\n", + "V_supply=12.0;\n", + "R2=100.0;\n", + "R3=220.0; #resistances in ohms\n", + "#calculation\n", + "V_bias=V_supply*(R3/(R2+R3));\n", + "\n", + "#result\n", "print('diode limiting the voltage at this voltage =%fV'%V_bias)" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "diode limiting the voltage at this voltage =8.250000V" ] } - ], + ], "prompt_number": 14 - }, + }, { - "cell_type": "markdown", + "cell_type": "markdown", + "metadata": {}, "source": [ "<h3>Example 2.13, Page Number: 78<h3>" ] - }, + }, { - "cell_type": "code", - "collapsed": false, + "cell_type": "code", + "collapsed": false, "input": [ - "", - "V_p_in=24.0;", - "V_DC=-(V_p_in-0.7); #DC level added to output", + "\n", + "V_p_in=24.0;\n", + "V_DC=-(V_p_in-0.7); #DC level added to output\n", "print('V_DC = %.1fV'%V_DC)" - ], - "language": "python", + ], + "language": "python", + "metadata": {}, "outputs": [ { - "output_type": "stream", - "stream": "stdout", + "output_type": "stream", + "stream": "stdout", "text": [ "V_DC = -23.3V" ] } - ], + ], "prompt_number": 15 } - ] + ], + "metadata": {} } ] }
\ No newline at end of file diff --git a/Engineering_Physics_Marikani/Chapter_6.ipynb b/Engineering_Physics_Marikani/Chapter_6.ipynb index 637c4652..f66bf1b2 100644 --- a/Engineering_Physics_Marikani/Chapter_6.ipynb +++ b/Engineering_Physics_Marikani/Chapter_6.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:97390494eb98d975fe0c29b984e91803cff6529592b1c9d0fc798d125a0d2ea9" + "signature": "sha256:be1bff093c78fabbeb6fefe6e4abb0ea03e38b876fbc4829ed2c2e8b1df1e947" }, "nbformat": 3, "nbformat_minor": 0, @@ -602,19 +602,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Calculation\n", - "#in simple cubic unit cell, corner atom is the nearest neighbour to another corner atom. \n", - "#Hence nearest neighbour distance is a.\n", - "#in BCC the body centered atom is the nearest neighbour to a corner atom.\n", - "#the distance between body centered atom and corner atom is 2r\n", - "#but r=sqrt(3)*a/4\n", - "#distance = 2*sqrt(3)*a/4 = sqrt(3)*a/2\n", - "#in FCC the face centered atom is the nearest neighbour to a corner atom.\n", - "#the distance between face centered atom and corner atom is 2r\n", - "#but r = a/sqrt(8)\n", - "#distance = 2*a/sqrt(8) = a/sqrt(2)\n", - "\n", "#Result\n", "print(\"in simple cubic unit cell nearest neighbour distance is a\");\n", "print(\"in body centered cubic unit cell nearest neighbour distance is sqrt(3)*a/2\");\n", diff --git a/Fundamental_of_Electronics_Devices/Ch4.ipynb b/Fundamental_of_Electronics_Devices/Ch4.ipynb index aaf0f2e5..47f532e6 100644 --- a/Fundamental_of_Electronics_Devices/Ch4.ipynb +++ b/Fundamental_of_Electronics_Devices/Ch4.ipynb @@ -1,957 +1,1026 @@ -{
- "metadata": {
- "name": ""
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 4: Junction Properties"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.1 page No. 146"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "T=300\t\t\t #in Kelvin\n",
- "ND=5*10**13\t\t #in cm**-3\n",
- "NA=0\t\t\t #in cm**-3\n",
- "ni=2.4*10**13\t\t#in cm**-3\n",
- "\n",
- "no=ND/2.0+math.sqrt((ND/2.0)**2+ni**2)\t#in cm**-3\n",
- "po=ni**2/no\t\t#in cm**-3\n",
- "\n",
- "print\"Majority carrier electron concentration is \",round(no,-11),\"cm**-3\"\n",
- "print\"Minority carrier hole concentration is \",round(po,-11),\" cm**-3\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Majority carrier electron concentration is 5.97e+13 cm**-3\n",
- "Minority carrier hole concentration is 9.7e+12 cm**-3\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.2 Page No.146"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "T=300\t\t\t#in Kelvin\n",
- "ND=10**16\t\t#in cm**-3\n",
- "NA=0\t\t\t #in cm**-3\n",
- "ni=1.5*10**10\t\t#in cm**-3\n",
- "\n",
- "no=ND/2.0+math.sqrt((ND/2.0)**2+ni**2)\t#in cm**-3\n",
- "po=ni**2/no\t\t#in cm**-3\n",
- "\n",
- "print\"Majority carrier electron concentration is \",no,\"cm**-3\"\n",
- "print\"Minority carrier hole concentration is \",round(po,0),\" cm**-3\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Majority carrier electron concentration is 1e+16 cm**-3\n",
- "Minority carrier hole concentration is 22500.0 cm**-3\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.3 Page No. 147"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "T=300\t\t\t#in Kelvin\n",
- "ND=3*10**15\t\t#in cm**-3\n",
- "NA=10**16\t\t#in cm**-3\n",
- "ni=1.6*10**10\t\t#in cm**-3\n",
- "\n",
- "po=(NA-ND)/2+math.sqrt(((NA-ND)/2.0)**2+ni**2.0)\t#in cm**-3\n",
- "no=ni**2/po\t\t#in cm**-3\n",
- "\n",
- "print\"Majority carrier hole concentration is\",round(po,-8),\" cm**-3\"\n",
- "print\"Minority carrier electron concentration is \",round(no,0),\" cm**-3\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Majority carrier hole concentration is 7e+15 cm**-3\n",
- "Minority carrier electron concentration is 36571.0 cm**-3\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.4 Page No. 147"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "ND=3*10**15\t\t#in cm**-3\n",
- "Eg=1.12 #eV\n",
- "k=8.62*10**-5 #eV/k\n",
- "Nc=2.8*10**19\n",
- "Nv=1.04*10**19\n",
- "\n",
- "import math\n",
- "No=1.05*ND\n",
- "ni=math.sqrt((No-ND/2.0)**2-0.25*ND**2)\n",
- "T=Eg/(-math.log(ni**2/(Nc*Nv))*k)\n",
- "\n",
- "print \"The maximum Temprature is \",round(T,1),\"K\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The maximum Temprature is 642.0 K\n"
- ]
- }
- ],
- "prompt_number": 45
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.5 Page No. 151"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "T=300\t\t#in Kelvin\n",
- "ND=10**15\t#in cm**-3\n",
- "NA=10**18\t#in cm**-3\n",
- "ni=1.5*10**10\t#in cm**-3\n",
- "VT=T/11600.0\t#in Volts\n",
- "\n",
- "Vbi=VT*math.log(NA*ND/ni**2)\t#in Volts\n",
- "\n",
- "print\"Built in potential barrier is\",round(Vbi,4),\"V\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Built in potential barrier is 0.7532 V\n"
- ]
- }
- ],
- "prompt_number": 47
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.6 Page No.151"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "T=300\t\t #in Kelvin\n",
- "ND=10**21\t #in m**-3\n",
- "NA=10**21\t #in m**-3\n",
- "ni=1.5*10**16 #in m**-3\n",
- "VT=T/11600.0\t#in Volts\n",
- "\n",
- "import math\n",
- "Vo=VT*math.log(NA*ND/ni**2)\t#in Volts\n",
- "\n",
- "print\"Contact potential is\",round(Vo,4),\"V\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Contact potential is 0.5745 V\n"
- ]
- }
- ],
- "prompt_number": 52
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.7 Page No. 154"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "T=300\t\t\t#in Kelvin\n",
- "ND=10**15\t\t#in cm**-3\n",
- "NA=10**16\t\t#in cm**-3\n",
- "ni=1.5*10**10\t\t#in cm**-3\n",
- "VT=T/11600.0\t\t#in Volts\n",
- "e=1.6*10**-19\t #in Coulamb\n",
- "\n",
- "epsilon=11.7*8.854*10**-14\t #constant\n",
- "Vbi=VT*math.log(NA*ND/ni**2)\t\t#in Volts\n",
- "SCW=math.sqrt((2*epsilon*Vbi/e)*(NA+ND)/(NA*ND))#in cm\n",
- "SCW=SCW*10**4 #in uMeter\n",
- "xn=0.864\t\t#in uM\n",
- "xp=0.086\t\t#in uM\n",
- "Emax=-e*ND*xn/epsilon\t#in V/cm\n",
- "\n",
- "print\"Space charge width is\",round(SCW,2),\"micro meter\"\n",
- "print\"At metallurgical junction, i.e for x=0 the electric field is \",round(Emax/10000,0),\"V\"#Note : Ans in the book is wrong"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Space charge width is 0.95 micro meter\n",
- "At metallurgical junction, i.e for x=0 the electric field is -13345.0 V\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.8 Page No.160"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "Ecf=0.3 #in Volts\n",
- "T=27.0+273.0 #in Kelvin\n",
- "delT=55 #in degree centigrade\n",
- "\n",
- "y=Ecf/T #assumed\n",
- "Tnew=273+55 #in Kelvin\n",
- "EcfNEW=y*Tnew #in Volts\n",
- "\n",
- "print\"New position of fermi level is \",round(EcfNEW,4),\"V\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "New position of fermi level is 0.328 V\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.9 Page No. 161"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "T=300\t\t\t#in Kelvin\n",
- "ND=8*10**14\t\t#in cm**-3\n",
- "NA=8*10**14\t\t#in cm**-3\n",
- "ni=2*10**13\t\t#in cm**-3\n",
- "k=8.61*10**-5\t\t#in eV/K\n",
- "\n",
- "Vo=k*T*math.log(NA*ND/ni**2)\t#in Volts\n",
- "\n",
- "print\"Contact potential is \",round(Vo,2),\"V\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Contact potential is 0.19 V\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.10 page No.161"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "ND=2*10**16 #in cm**-3\n",
- "NA=5*10**15 #in cm**-3\n",
- "Ao=4.83*10**21 \t#constant\n",
- "T=300.0\t\t\t #in Kelvin\n",
- "EG=1.1\t \t \t #in eV\n",
- "kT=0.026 \t\t#in eV\n",
- "\n",
- "ni=Ao*T**(1.5)*math.exp(-EG/(2*kT))\t\t#in m**-3\n",
- "p=(ni/10**6)**2/ND\t\t\t#in cm**-3\n",
- "n=((ni/10**6)**2)/NA\t\t\t#in cm**-3\n",
- "\n",
- "\n",
- "print\"Hole concentration in cm**-3 : %.1e\"%round(p,0),\"/cm**3\"\n",
- "print\"electron concentration in cm**-3 :%.1e\"%round(n,0),\"/cm**3\"\n",
- "print\"\\nNOTE:\\nSlight Variation in answer due to wrong value of ni in book as 1.6*10**16 instead of\",ni\n",
- "if n < e:\n",
- " \n",
- " print\"\\n\\nthe given Si is of P-type\" \n",
- "else:\n",
- " print \"\\nThe given Si is of N-type\"\n",
- " "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Hole concentration in cm**-3 : 1.3e+04 /cm**3\n",
- "electron concentration in cm**-3 :5.3e+04 /cm**3\n",
- "\n",
- "NOTE:\n",
- "Slight Variation in answer due to wrong value of ni in book as 1.6*10**16 instead of 1.63166259315e+16\n",
- "\n",
- "The given Si is of N-type\n"
- ]
- }
- ],
- "prompt_number": 42
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.11 Page No. 168"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "V=5\t\t #in volts\n",
- "Vo=0.7\t #in Volts\n",
- "R=100\t\t#in Kohm\n",
- "\n",
- "I=(V-Vo)/R\t#in Ampere\n",
- "\n",
- "print\"Current flowing through the circuit is\",round(I*1000,0),\"mA\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Current flowing through the circuit is 43.0 mA\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.12 Page No. 168"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "V=15\t\t\t #in volts\n",
- "Vo=0.7\t\t\t#in Volts\n",
- "R=7\t \t \t#in Kohm\n",
- "\n",
- "I=(V-2*Vo)/R\n",
- "I=(V-2*Vo)/R\t\t#in mAmpere\n",
- "VA=I*R\t \t\t#in Volts\n",
- "\n",
- "print\"Voltagee VA is \",VA,\"V\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Voltagee VA is 13.6 V\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.13 Page No.169"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "V=15 #V, voltage\n",
- "Vb=0.3 #V, Barrier Potential #When supply is switched on\n",
- "\n",
- "VA=V-Vb\n",
- "\n",
- "print\"The Voltage VA is \",VA,\"V\"\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The Voltage VA is 14.7 V\n"
- ]
- }
- ],
- "prompt_number": 23
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.14 Page No.172"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "Vz=5\t\t\t#in volts\n",
- "to=25\t\t\t#in degree centigrade\n",
- "t=100\t\t\t#in degree centigrade\n",
- "Vdrop=4.8\t\t#in Volts\n",
- "\n",
- "delVz=Vdrop-Vz\t\t#in Volts\n",
- "delt=t-to\t\t#in degree centigrade\n",
- "TempCoeff=delVz*100/(Vz*delt)\n",
- "\n",
- "print\"Temperature coefficient f zener diode is \",round(TempCoeff,3),\"percent\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Temperature coefficient f zener diode is -0.053 percent\n"
- ]
- }
- ],
- "prompt_number": 22
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.15 Page No. 174"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "Vz=8.0\t\t\t#in volts\n",
- "VS=12.0\t\t\t#in volts\n",
- "RL=10.0\t\t\t#in Kohm\n",
- "Rs=5.0\t\t\t#in Kohm\n",
- "\n",
- "Vout=Vz\t\t\t#in volts\n",
- "\n",
- "Vrs=VS-Vout\t\t#in volts\n",
- "IL=Vout/RL \t\t#in mAmpere\n",
- "Is=(VS-Vout)/Rs\t#in mAmpere\n",
- "\n",
- "Iz=Is-IL\t \t#in mAmpere\n",
- "\n",
- "print\"(a)Output voltage will be equal to Vout=\",Vout,\" Volts\"\n",
- "print\"(b)Voltage across Rs is Rs=\",Vrs,\"V\"\n",
- "print\"(c)Current through zener diode is Iz=\",round(Iz,1),\"mA\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(a)Output voltage will be equal to Vout= 8.0 Volts\n",
- "(b)Voltage across Rs is Rs= 4.0 V\n",
- "(c)Current through zener diode is Iz= 0.0 mA\n"
- ]
- }
- ],
- "prompt_number": 47
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.16 Page No. 175"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "Vz=50.\t\t\t#in volts\n",
- "VSmax=120.0\t\t#in volts\n",
- "VSmin=80.0\t\t#in volts\n",
- "RL=10.0\t\t\t#in Kohm\n",
- "Rs=5.0\t\t\t#in Kohm\n",
- "\n",
- "Vout=Vz\t\t\t#in Volts\n",
- "IL=Vout/RL\t\t#in mAmpere\n",
- "\n",
- "ISmax=(VSmax-Vout)/Rs\t#in mAmpere\n",
- "Izmax=ISmax-IL\t\t#in mA\n",
- "Ismin=(VSmin-Vout)/Rs#in mAmpere\n",
- "Izmin=Ismin-IL#in mA\n",
- "\n",
- "print\"Maximum zener diode current is \",Izmax,\"mA\"\n",
- "print\"Minimum zener diode current is \",Izmin,\"mA\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Maximum zener diode current is 9.0 mA\n",
- "Minimum zener diode current is 1.0 mA\n"
- ]
- }
- ],
- "prompt_number": 32
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.17 Page No. 175"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "Vz=15\t\t#in volts\n",
- "Izk=6.0\t\t#in mA\n",
- "Vout=15\t\t#in Volts\n",
- "Vs=20\t\t#in Volts\n",
- "ILmin=10.0\t#in mA\n",
- "ILmax=20.0\t#in mA\n",
- "RS=(Vs-Vz)*1000/(ILmax+Izk)\t#in ohm\n",
- "\n",
- "print\"sereis Resistance is \",round(RS,1),\"ohm\"\n",
- "print\"The zener current will be minimum i.e. Izk = 6mA when load current is maximum i.e. ILmax = 20mA\"\n",
- "print\"when the load current will decrease and become 10 mA, the zener current will increase and become 6+10 i.e. 16 mA. \\nThus the current through series resistance Rs will remain unchanged at 6+20 i.e. 26 mA. \\nThus voltage drop in series resistance Rs will remain constant. Consequently, the output voltage will also remain constant. \""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "sereis Resistance is 192.3 ohm\n",
- "The zener current will be minimum i.e. Izk = 6mA when load current is maximum i.e. ILmax = 20mA\n",
- "when the load current will decrease and become 10 mA, the zener current will increase and become 6+10 i.e. 16 mA. \n",
- "Thus the current through series resistance Rs will remain unchanged at 6+20 i.e. 26 mA. \n",
- "Thus voltage drop in series resistance Rs will remain constant. Consequently, the output voltage will also remain constant. \n"
- ]
- }
- ],
- "prompt_number": 48
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.18 Page No. 175"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "Vs=16.0\t\t #in volts\n",
- "RL=1.2\t\t\t#in Kohm\n",
- "Rs=1.0\t\t\t#in Kohm\n",
- "\n",
- "VL=Vs*RL/(Rs+RL)\t#in Volts\n",
- "Iz=0\t\t\t#in mA\n",
- "Pz=VL*Iz\t\t#in watts\n",
- "\n",
- "print\"When zener open circuited Voltage across load is \",round(VL,2),\"V\"\n",
- "print\"Zener current is \",Iz,\"mA\"\n",
- "print\"Power is\",Pz,\"watt\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "When zener open circuited Voltage across load is 8.73 V\n",
- "Zener current is 0 mA\n",
- "Power is 0.0 watt\n"
- ]
- }
- ],
- "prompt_number": 52
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.19 Page No. 126"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "Vin=20\t\t\t#in volts\n",
- "Rs=220.0\t\t\t#in Kohm\n",
- "Vz=10\t\t \t#in volts\n",
- "RL2=50.0\t\t\t#in Kohm\n",
- "RL1=200\t\t\t#in Kohm\n",
- "\n",
- "VL1=Vin*RL1/(RL+Rs)\n",
- "IR=Vin/(Rs+RL)\t#in mA\n",
- "IL=IR\t\t \t#in mA\n",
- "IZ=0\t\t\t #in mA\n",
- "\n",
- "if VL1< Vz:\n",
- " \n",
- " print\"Zener diode will not conduct and VL=\",round(VL1,1),\"V\" \n",
- "else:\n",
- " print \"Zener diode will conduct\"\n",
- "\n",
- " \n",
- "print\"When RL=200 ohm\"\n",
- "print\"IL is\",round(IL*1000,2),\"mA\"\n",
- "print\"IR is\",round(IR*10**3,2),\"mA\"\n",
- "print\"Iz in mA: \",round(IZ,0),\"mA\"\n",
- "\n",
- "RL=200\t\t\t#in Kohm\n",
- "VL2=Vin*RL2/(RL2+Rs)\n",
- "IR=Vin/(Rs+RL2)\t\t#in mA\n",
- "IL=IR\t\t\t#in mA\n",
- "IZ=0\t\t\t#in mA\n",
- "\n",
- "if VL2< Vz:\n",
- " \n",
- " print\"Zener diode will not conduct and VL=\",round(VL2,1),\"V\" \n",
- "else:\n",
- " print \"Zener diode will conduct\"\n",
- "\n",
- "print\"When RL=50 ohm\"\n",
- "print\"IL is\",round(IL*1000,2),\"mA\"\n",
- "print\"IR is\",round(IR*10**3,2),\"mA\"\n",
- "print\"Iz in mA: \",IZ,\"mA\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Zener diode will not conduct and VL= 9.5 V\n",
- "When RL=200 ohm\n",
- "IL is 47.62 mA\n",
- "IR is 47.62 mA\n",
- "Iz in mA: 0.0 mA\n",
- "Zener diode will not conduct and VL= 3.7 V\n",
- "When RL=50 ohm\n",
- "IL is 74.07 mA\n",
- "IR is 74.07 mA\n",
- "Iz in mA: 0 mA\n"
- ]
- }
- ],
- "prompt_number": 64
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.20 Page No. 176"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "RL=10.0\t\t\t #in Kohm\n",
- "Rs=5.0 #in Kohm\n",
- "Vin=100\t\t\t #in Volts\n",
- "\n",
- "V=Vin*RL/(RL+Rs)\t#in Volt\n",
- "VZ=50\t\t\t#in Volts\n",
- "VL=VZ\t\t\t#in volts\n",
- "VR=100-50\t\t#in Volts\n",
- "VR=50\t\t\t#in Volts\n",
- "\n",
- "if V< VZ:\n",
- " \n",
- " print\"Zener diode is OFF state\" \n",
- "else:\n",
- " print \"zener diode is ON state\"\n",
- "\n",
- "print\"Hence the voltage dropp across the 5 Kohm resistor in Volts is \",VR,\"V\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "zener diode is ON state\n",
- "Hence the voltage dropp across the 5 Kohm resistor in Volts is 50 V\n"
- ]
- }
- ],
- "prompt_number": 67
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.21 Page No. 176"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "RL=120.0\t\t\t#in ohm, load resistance\n",
- "Izmin=20\t\t#in mA min. diode current\n",
- "Izmax=200\t\t#in mA max. diode current\n",
- "VL=12\t\t\t#in Volts\n",
- "VDCmin=15\t\t#in Volts\n",
- "VDCmax=19.5\t\t#in Volts\n",
- "Vz=12\t\t\t#in Volts\n",
- "IL=VL/RL\t\t#in Ampere\n",
- "IL=IL*1000\t\t#in mAmpere\n",
- "\n",
- "VSmin=VDCmin-Vz\t\t#in Volts\n",
- "VSmax=VDCmax-Vz\t\t#in Volts\n",
- "ISmin=Izmin+IL\t\t#in mA\n",
- "Ri=VSmin/ISmin\t\t#in Kohm\n",
- "Ri=Ri*10**3\t\t#in ohm\n",
- "\n",
- "print\"The resistance Ri is \",Ri,\"ohm\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The resistance Ri is 25.0 ohm\n"
- ]
- }
- ],
- "prompt_number": 72
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 4.22 Page No. 177"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "VRL=10\t\t\t#in Volts Diode resistance\n",
- "Vi=50\t\t\t#in Volts\n",
- "R=1.0\t\t\t#in Kohm Resistance\n",
- "Vz=10\t\t\t#in Volts\n",
- "VL=Vz\t\t\t#in Volts\n",
- "Izm=32\t\t\t#in mA\n",
- "IR=(Vi-VL)/R\t\t#in mA\n",
- "\n",
- "Izmin=0\t\t\t #in mA\n",
- "ILmax=IR-Izmin\t\t#in mA\n",
- "RLmin=VL/ILmax\t\t#in Ohm\n",
- "Izmax=32\t\t #in mA\n",
- "ILmin=IR-Izmax\t\t#in mA\n",
- "VL=Vz\t\t\t #in Volts\n",
- "RLmax=VL/ILmin\t\t#in Ohm\n",
- "\n",
- "print\"Range of RL in Kohm : From \",RLmin*1000,\"ohm to \",RLmax,\"kohm\"\n",
- "print\"Range of IL in mA : From \",ILmin,\"mA to \",ILmax,\"mA\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Range of RL in Kohm : From 250.0 ohm to 1.25 kohm\n",
- "Range of IL in mA : From 8.0 mA to 40.0 mA\n"
- ]
- }
- ],
- "prompt_number": 71
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:606a5c9e48de665a7bdbd2fe9ec84d0a776a619019e1e88b4d21b1affe9620a0" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 4: Junction Properties" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.1 page No. 146" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#given data\n", + "import math\n", + "T=300\t\t\t #in Kelvin\n", + "ND=5*10**13\t\t #in cm**-3\n", + "NA=0\t\t\t #in cm**-3\n", + "ni=2.4*10**13\t\t#in cm**-3\n", + "\n", + "#Calculation\n", + "no=ND/2.0+math.sqrt((ND/2.0)**2+ni**2)\t#in cm**-3\n", + "po=ni**2/no\t\t#in cm**-3\n", + "\n", + "#Result\n", + "print\"Majority carrier electron concentration is \",round(no,-11),\"cm**-3\"\n", + "print\"Minority carrier hole concentration is \",round(po,-11),\" cm**-3\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Majority carrier electron concentration is 5.97e+13 cm**-3\n", + "Minority carrier hole concentration is 9.7e+12 cm**-3\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.2 Page No.146" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#given data\n", + "import math\n", + "T=300\t\t\t#in Kelvin\n", + "ND=10**16\t\t#in cm**-3\n", + "NA=0\t\t\t #in cm**-3\n", + "ni=1.5*10**10\t\t#in cm**-3\n", + "\n", + "#Calculation\n", + "no=ND/2.0+math.sqrt((ND/2.0)**2+ni**2)\t#in cm**-3\n", + "po=ni**2/no\t\t#in cm**-3\n", + "\n", + "#result\n", + "print\"Majority carrier electron concentration is \",no,\"cm**-3\"\n", + "print\"Minority carrier hole concentration is \",round(po,0),\" cm**-3\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Majority carrier electron concentration is 1e+16 cm**-3\n", + "Minority carrier hole concentration is 22500.0 cm**-3\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.3 Page No. 147" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#given data\n", + "import math\n", + "T=300\t\t\t#in Kelvin\n", + "ND=3*10**15\t\t#in cm**-3\n", + "NA=10**16\t\t#in cm**-3\n", + "ni=1.6*10**10\t\t#in cm**-3\n", + "\n", + "#Calculation\n", + "po=(NA-ND)/2+math.sqrt(((NA-ND)/2.0)**2+ni**2.0)\t#in cm**-3\n", + "no=ni**2/po\t\t#in cm**-3\n", + "\n", + "#Result\n", + "print\"Majority carrier hole concentration is\",round(po,-8),\" cm**-3\"\n", + "print\"Minority carrier electron concentration is \",round(no,0),\" cm**-3\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Majority carrier hole concentration is 7e+15 cm**-3\n", + "Minority carrier electron concentration is 36571.0 cm**-3\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.4 Page No. 147" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#Given \n", + "import math\n", + "ND=3*10**15\t\t#in cm**-3\n", + "Eg=1.12 #eV\n", + "k=8.62*10**-5 #eV/k\n", + "Nc=2.8*10**19\n", + "Nv=1.04*10**19\n", + "\n", + "#Calculation\n", + "import math\n", + "# from the equation po=(NA-ND)/2+math.sqrt(((NA-ND)/2.0)**2+ni**2.0)\t#in cm**-3\n", + "No=1.05*ND\n", + "ni=math.sqrt((No-ND/2.0)**2-0.25*ND**2)\n", + "#From ni**2=Nc*Nv*exp(-Eg/(k*t))\n", + "T=Eg/(-math.log(ni**2/(Nc*Nv))*k)\n", + "\n", + "#Result\n", + "print \"The maximum Temprature is \",round(T,1),\"K\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The maximum Temprature is 642.0 K\n" + ] + } + ], + "prompt_number": 45 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.5 Page No. 151" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + " \n", + "#given data\n", + "import math\n", + "T=300\t\t#in Kelvin\n", + "ND=10**15\t#in cm**-3\n", + "NA=10**18\t#in cm**-3\n", + "ni=1.5*10**10\t#in cm**-3\n", + "VT=T/11600.0\t#in Volts\n", + "\n", + "#Calculation\n", + "Vbi=VT*math.log(NA*ND/ni**2)\t#in Volts\n", + "\n", + "#result\n", + "print\"Built in potential barrier is\",round(Vbi,4),\"V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Built in potential barrier is 0.7532 V\n" + ] + } + ], + "prompt_number": 47 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.6 Page No.151" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "T=300\t\t #in Kelvin\n", + "ND=10**21\t #in m**-3\n", + "NA=10**21\t #in m**-3\n", + "ni=1.5*10**16 #in m**-3\n", + "VT=T/11600.0\t#in Volts\n", + "\n", + "#Calculation\n", + "import math\n", + "Vo=VT*math.log(NA*ND/ni**2)\t#in Volts\n", + "\n", + "#result\n", + "print\"Contact potential is\",round(Vo,4),\"V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Contact potential is 0.5745 V\n" + ] + } + ], + "prompt_number": 52 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.7 Page No. 154" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#given data\n", + "import math\n", + "T=300\t\t\t#in Kelvin\n", + "ND=10**15\t\t#in cm**-3\n", + "NA=10**16\t\t#in cm**-3\n", + "ni=1.5*10**10\t\t#in cm**-3\n", + "VT=T/11600.0\t\t#in Volts\n", + "e=1.6*10**-19\t #in Coulamb\n", + "\n", + "#calculation\n", + "epsilon=11.7*8.854*10**-14\t #constant\n", + "Vbi=VT*math.log(NA*ND/ni**2)\t\t#in Volts\n", + "SCW=math.sqrt((2*epsilon*Vbi/e)*(NA+ND)/(NA*ND))#in cm\n", + "SCW=SCW*10**4 #in uMeter\n", + "xn=0.864\t\t#in uM\n", + "xp=0.086\t\t#in uM\n", + "Emax=-e*ND*xn/epsilon\t#in V/cm\n", + "\n", + "#result\n", + "print\"Space charge width is\",round(SCW,2),\"micro meter\"\n", + "print\"At metallurgical junction, i.e for x=0 the electric field is \",round(Emax/10000,0),\"V\"#Note : Ans in the book is wrong" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Space charge width is 0.95 micro meter\n", + "At metallurgical junction, i.e for x=0 the electric field is -13345.0 V\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.8 Page No.160" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#given data\n", + "import math\n", + "Ecf=0.3 #in Volts\n", + "T=27.0+273.0 #in Kelvin\n", + "delT=55 #in degree centigrade\n", + "\n", + "#calculation\n", + "#formula : Ecf=Ec-Ef=K*T*math.log(nc/ND)\n", + "#let K*math.log(nc/ND)=y\n", + "#Ecf=Ec-Ef=T*y\n", + "y=Ecf/T #assumed\n", + "Tnew=273+55 #in Kelvin\n", + "EcfNEW=y*Tnew #in Volts\n", + "\n", + "#result\n", + "print\"New position of fermi level is \",round(EcfNEW,4),\"V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "New position of fermi level is 0.328 V\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.9 Page No. 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + " \n", + "#given data\n", + "import math\n", + "T=300\t\t\t#in Kelvin\n", + "ND=8*10**14\t\t#in cm**-3\n", + "NA=8*10**14\t\t#in cm**-3\n", + "ni=2*10**13\t\t#in cm**-3\n", + "k=8.61*10**-5\t\t#in eV/K\n", + "\n", + "#calculation\n", + "Vo=k*T*math.log(NA*ND/ni**2)\t#in Volts\n", + "\n", + "#Result\n", + "print\"Contact potential is \",round(Vo,2),\"V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Contact potential is 0.19 V\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.10 page No.161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#given data\n", + "ND=2*10**16 #in cm**-3\n", + "NA=5*10**15 #in cm**-3\n", + "Ao=4.83*10**21 \t#constant\n", + "T=300.0\t\t\t #in Kelvin\n", + "EG=1.1\t \t \t #in eV\n", + "kT=0.026 \t\t#in eV\n", + "\n", + "#Calculation\n", + "ni=Ao*T**(1.5)*math.exp(-EG/(2*kT))\t\t#in m**-3\n", + "p=(ni/10**6)**2/ND\t\t\t#in cm**-3\n", + "n=((ni/10**6)**2)/NA\t\t\t#in cm**-3\n", + "\n", + "#Result\n", + "\n", + "print\"Hole concentration in cm**-3 : %.1e\"%round(p,0),\"/cm**3\"\n", + "print\"electron concentration in cm**-3 :%.1e\"%round(n,0),\"/cm**3\"\n", + "print\"\\nNOTE:\\nSlight Variation in answer due to wrong value of ni in book as 1.6*10**16 instead of\",ni\n", + "if n < e:\n", + " \n", + " print\"\\n\\nthe given Si is of P-type\" \n", + "else:\n", + " print \"\\nThe given Si is of N-type\"\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Hole concentration in cm**-3 : 1.3e+04 /cm**3\n", + "electron concentration in cm**-3 :5.3e+04 /cm**3\n", + "\n", + "NOTE:\n", + "Slight Variation in answer due to wrong value of ni in book as 1.6*10**16 instead of 1.63166259315e+16\n", + "\n", + "The given Si is of N-type\n" + ] + } + ], + "prompt_number": 42 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.11 Page No. 168" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "V=5\t\t #in volts\n", + "Vo=0.7\t #in Volts\n", + "R=100\t\t#in Kohm\n", + "\n", + "#Calculation\n", + "I=(V-Vo)/R\t#in Ampere\n", + "\n", + "#result\n", + "print\"Current flowing through the circuit is\",round(I*1000,0),\"mA\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Current flowing through the circuit is 43.0 mA\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.12 Page No. 168" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "V=15\t\t\t #in volts\n", + "Vo=0.7\t\t\t#in Volts\n", + "R=7\t \t \t#in Kohm\n", + "\n", + "#Calculation\n", + "I=(V-2*Vo)/R\n", + "I=(V-2*Vo)/R\t\t#in mAmpere\n", + "VA=I*R\t \t\t#in Volts\n", + "\n", + "#result\n", + "print\"Voltagee VA is \",VA,\"V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Voltagee VA is 13.6 V\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.13 Page No.169" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "V=15 #V, voltage\n", + "Vb=0.3 #V, Barrier Potential #When supply is switched on\n", + "\n", + "#Calculation\n", + "VA=V-Vb\n", + "\n", + "#Result\n", + "print\"The Voltage VA is \",VA,\"V\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Voltage VA is 14.7 V\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.14 Page No.172" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#given data\n", + "Vz=5\t\t\t#in volts\n", + "to=25\t\t\t#in degree centigrade\n", + "t=100\t\t\t#in degree centigrade\n", + "Vdrop=4.8\t\t#in Volts\n", + "\n", + "#calculation\n", + "delVz=Vdrop-Vz\t\t#in Volts\n", + "delt=t-to\t\t#in degree centigrade\n", + "TempCoeff=delVz*100/(Vz*delt)\n", + "\n", + "#result\n", + "print\"Temperature coefficient f zener diode is \",round(TempCoeff,3),\"percent\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Temperature coefficient f zener diode is -0.053 percent\n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.15 Page No. 174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "Vz=8.0\t\t\t#in volts\n", + "VS=12.0\t\t\t#in volts\n", + "RL=10.0\t\t\t#in Kohm\n", + "Rs=5.0\t\t\t#in Kohm\n", + "\n", + "#part (a)\n", + "Vout=Vz\t\t\t#in volts\n", + "\n", + "#part (b)\n", + "Vrs=VS-Vout\t\t#in volts\n", + "IL=Vout/RL \t\t#in mAmpere\n", + "Is=(VS-Vout)/Rs\t#in mAmpere\n", + "\n", + "#part c\n", + "Iz=Is-IL\t \t#in mAmpere\n", + "\n", + "#result\n", + "print\"(a)Output voltage will be equal to Vout=\",Vout,\" Volts\"\n", + "print\"(b)Voltage across Rs is Rs=\",Vrs,\"V\"\n", + "print\"(c)Current through zener diode is Iz=\",round(Iz,1),\"mA\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a)Output voltage will be equal to Vout= 8.0 Volts\n", + "(b)Voltage across Rs is Rs= 4.0 V\n", + "(c)Current through zener diode is Iz= 0.0 mA\n" + ] + } + ], + "prompt_number": 47 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.16 Page No. 175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#given data\n", + "Vz=50.\t\t\t#in volts\n", + "VSmax=120.0\t\t#in volts\n", + "VSmin=80.0\t\t#in volts\n", + "RL=10.0\t\t\t#in Kohm\n", + "Rs=5.0\t\t\t#in Kohm\n", + "\n", + "#Calculation\n", + "Vout=Vz\t\t\t#in Volts\n", + "IL=Vout/RL\t\t#in mAmpere\n", + "\n", + "ISmax=(VSmax-Vout)/Rs\t#in mAmpere\n", + "Izmax=ISmax-IL\t\t#in mA\n", + "Ismin=(VSmin-Vout)/Rs#in mAmpere\n", + "Izmin=Ismin-IL#in mA\n", + "\n", + "#Result\n", + "print\"Maximum zener diode current is \",Izmax,\"mA\"\n", + "print\"Minimum zener diode current is \",Izmin,\"mA\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum zener diode current is 9.0 mA\n", + "Minimum zener diode current is 1.0 mA\n" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.17 Page No. 175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "Vz=15\t\t#in volts\n", + "Izk=6.0\t\t#in mA\n", + "Vout=15\t\t#in Volts\n", + "Vs=20\t\t#in Volts\n", + "ILmin=10.0\t#in mA\n", + "ILmax=20.0\t#in mA\n", + "RS=(Vs-Vz)*1000/(ILmax+Izk)\t#in ohm\n", + "\n", + "#result\n", + "print\"sereis Resistance is \",round(RS,1),\"ohm\"\n", + "print\"The zener current will be minimum i.e. Izk = 6mA when load current is maximum i.e. ILmax = 20mA\"\n", + "print\"when the load current will decrease and become 10 mA, the zener current will increase and become 6+10 i.e. 16 mA. \\nThus the current through series resistance Rs will remain unchanged at 6+20 i.e. 26 mA. \\nThus voltage drop in series resistance Rs will remain constant. Consequently, the output voltage will also remain constant. \"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "sereis Resistance is 192.3 ohm\n", + "The zener current will be minimum i.e. Izk = 6mA when load current is maximum i.e. ILmax = 20mA\n", + "when the load current will decrease and become 10 mA, the zener current will increase and become 6+10 i.e. 16 mA. \n", + "Thus the current through series resistance Rs will remain unchanged at 6+20 i.e. 26 mA. \n", + "Thus voltage drop in series resistance Rs will remain constant. Consequently, the output voltage will also remain constant. \n" + ] + } + ], + "prompt_number": 48 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.18 Page No. 175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "Vs=16.0\t\t #in volts\n", + "RL=1.2\t\t\t#in Kohm\n", + "Rs=1.0\t\t\t#in Kohm\n", + "\n", + "#calculation\n", + "#If zener open circuited\n", + "VL=Vs*RL/(Rs+RL)\t#in Volts\n", + "Iz=0\t\t\t#in mA\n", + "Pz=VL*Iz\t\t#in watts\n", + "\n", + "#result\n", + "print\"When zener open circuited Voltage across load is \",round(VL,2),\"V\"\n", + "print\"Zener current is \",Iz,\"mA\"\n", + "print\"Power is\",Pz,\"watt\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "When zener open circuited Voltage across load is 8.73 V\n", + "Zener current is 0 mA\n", + "Power is 0.0 watt\n" + ] + } + ], + "prompt_number": 52 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.19 Page No. 126" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "Vin=20\t\t\t#in volts\n", + "Rs=220.0\t\t\t#in Kohm\n", + "Vz=10\t\t \t#in volts\n", + "RL2=50.0\t\t\t#in Kohm\n", + "RL1=200\t\t\t#in Kohm\n", + "\n", + "#calculation\n", + "# part (i) RL=50\t#in Kohm\n", + "VL1=Vin*RL1/(RL+Rs)\n", + "IR=Vin/(Rs+RL)\t#in mA\n", + "IL=IR\t\t \t#in mA\n", + "IZ=0\t\t\t #in mA\n", + "\n", + "if VL1< Vz:\n", + " \n", + " print\"Zener diode will not conduct and VL=\",round(VL1,1),\"V\" \n", + "else:\n", + " print \"Zener diode will conduct\"\n", + "\n", + " \n", + "#Result\n", + "print\"When RL=200 ohm\"\n", + "print\"IL is\",round(IL*1000,2),\"mA\"\n", + "print\"IR is\",round(IR*10**3,2),\"mA\"\n", + "print\"Iz in mA: \",round(IZ,0),\"mA\"\n", + "\n", + "# part (ii) RL=200#in Kohm\n", + "RL=200\t\t\t#in Kohm\n", + "VL2=Vin*RL2/(RL2+Rs)\n", + "IR=Vin/(Rs+RL2)\t\t#in mA\n", + "IL=IR\t\t\t#in mA\n", + "IZ=0\t\t\t#in mA\n", + "\n", + "#result\n", + "if VL2< Vz:\n", + " \n", + " print\"Zener diode will not conduct and VL=\",round(VL2,1),\"V\" \n", + "else:\n", + " print \"Zener diode will conduct\"\n", + "\n", + "print\"When RL=50 ohm\"\n", + "print\"IL is\",round(IL*1000,2),\"mA\"\n", + "print\"IR is\",round(IR*10**3,2),\"mA\"\n", + "print\"Iz in mA: \",IZ,\"mA\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zener diode will not conduct and VL= 9.5 V\n", + "When RL=200 ohm\n", + "IL is 47.62 mA\n", + "IR is 47.62 mA\n", + "Iz in mA: 0.0 mA\n", + "Zener diode will not conduct and VL= 3.7 V\n", + "When RL=50 ohm\n", + "IL is 74.07 mA\n", + "IR is 74.07 mA\n", + "Iz in mA: 0 mA\n" + ] + } + ], + "prompt_number": 64 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.20 Page No. 176" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "RL=10.0\t\t\t #in Kohm\n", + "Rs=5.0 #in Kohm\n", + "Vin=100\t\t\t #in Volts\n", + "\n", + "#Calculation\n", + "V=Vin*RL/(RL+Rs)\t#in Volt\n", + "VZ=50\t\t\t#in Volts\n", + "VL=VZ\t\t\t#in volts\n", + "#Apply KVL\n", + "VR=100-50\t\t#in Volts\n", + "VR=50\t\t\t#in Volts\n", + "\n", + "if V< VZ:\n", + " \n", + " print\"Zener diode is OFF state\" \n", + "else:\n", + " print \"zener diode is ON state\"\n", + "\n", + "print\"Hence the voltage dropp across the 5 Kohm resistor in Volts is \",VR,\"V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "zener diode is ON state\n", + "Hence the voltage dropp across the 5 Kohm resistor in Volts is 50 V\n" + ] + } + ], + "prompt_number": 67 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.21 Page No. 176" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "RL=120.0\t\t\t#in ohm, load resistance\n", + "Izmin=20\t\t#in mA min. diode current\n", + "Izmax=200\t\t#in mA max. diode current\n", + "VL=12\t\t\t#in Volts\n", + "VDCmin=15\t\t#in Volts\n", + "VDCmax=19.5\t\t#in Volts\n", + "Vz=12\t\t\t#in Volts\n", + "IL=VL/RL\t\t#in Ampere\n", + "IL=IL*1000\t\t#in mAmpere\n", + "\n", + "#calculation\n", + "#For VDCmin = 15 volts\n", + "VSmin=VDCmin-Vz\t\t#in Volts\n", + "#For VDCmax = 19.5 volts\n", + "VSmax=VDCmax-Vz\t\t#in Volts\n", + "ISmin=Izmin+IL\t\t#in mA\n", + "Ri=VSmin/ISmin\t\t#in Kohm\n", + "Ri=Ri*10**3\t\t#in ohm\n", + "\n", + "#result\n", + "print\"The resistance Ri is \",Ri,\"ohm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The resistance Ri is 25.0 ohm\n" + ] + } + ], + "prompt_number": 72 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.22 Page No. 177" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "VRL=10\t\t\t#in Volts Diode resistance\n", + "Vi=50\t\t\t#in Volts\n", + "R=1.0\t\t\t#in Kohm Resistance\n", + "Vz=10\t\t\t#in Volts\n", + "VL=Vz\t\t\t#in Volts\n", + "Izm=32\t\t\t#in mA\n", + "IR=(Vi-VL)/R\t\t#in mA\n", + "\n", + "Izmin=0\t\t\t #in mA\n", + "ILmax=IR-Izmin\t\t#in mA\n", + "RLmin=VL/ILmax\t\t#in Ohm\n", + "Izmax=32\t\t #in mA\n", + "ILmin=IR-Izmax\t\t#in mA\n", + "VL=Vz\t\t\t #in Volts\n", + "RLmax=VL/ILmin\t\t#in Ohm\n", + "\n", + "#Result\n", + "print\"Range of RL in Kohm : From \",RLmin*1000,\"ohm to \",RLmax,\"kohm\"\n", + "print\"Range of IL in mA : From \",ILmin,\"mA to \",ILmax,\"mA\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Range of RL in Kohm : From 250.0 ohm to 1.25 kohm\n", + "Range of IL in mA : From 8.0 mA to 40.0 mA\n" + ] + } + ], + "prompt_number": 71 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Fundamental_of_Electronics_Devices/Ch8.ipynb b/Fundamental_of_Electronics_Devices/Ch8.ipynb index 71bad3db..aa872860 100644 --- a/Fundamental_of_Electronics_Devices/Ch8.ipynb +++ b/Fundamental_of_Electronics_Devices/Ch8.ipynb @@ -1,207 +1,219 @@ -{
- "metadata": {
- "name": ""
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 8: Photonic Devices"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.1 Page no 293"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "NA=10**22 #in atoms/m**3\n",
- "ND=10**22 #in atoms/m**3\n",
- "De=25*10**-4 \t#in m**2/s\n",
- "Dh=10**-3\t\t#in m**2/s\n",
- "TAUeo=500\t\t#in ns\n",
- "TAUho=100\t\t#in ns\n",
- "ni=1.5*10**16\t\t#in atoms/m**3\n",
- "VR=-10\t\t\t#in Volt\n",
- "epsilon=11.6*8.854*10**-12\t#in F/m\n",
- "e=1.6*10**-19\t\t\t#in Coulamb\n",
- "VT=26\t\t\t\t#in mV\n",
- "GL=10**27\t\t\t#in m**-3 s**-1\n",
- "\n",
- "\n",
- "import math\n",
- "Le=math.sqrt(De*TAUeo*10**-9)\t#in um\n",
- "Le=Le*10**6\t\t\t#in um\n",
- "Lh=math.sqrt(Dh*TAUho*10**-9)\t#in um\n",
- "Lh=Lh*10**6\t\t\t#in um\n",
- "Vbi=VT*10**-3*math.log(NA*ND/ni**2)\t#in Volt\n",
- "Vo=Vbi\t\t\t\t#in Volt\n",
- "VB=Vo-VR\t\t\t#in Volt\n",
- "W=math.sqrt((2*epsilon*VB/e)*(1/NA+1/ND))\t#in um\n",
- "W=W*10**6\t\t\t#in um\n",
- "JL=e*(W+Le+Lh)*10**-6*GL\t#in A/cm**2\n",
- "\n",
- "print \"Steady state photocurrent density is \",round(JL/10**4,3),\"A/cm**2\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Steady state photocurrent density is 0.726 A/cm**2\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.2 Page no 295"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "W=25\t\t\t#in um\n",
- "PhotonFlux=10**21\t#in m**2s**-1\n",
- "alfa=10**5\t\t#in m**-1\n",
- "e=1.6*10**-19\t\t#in Coulambs\n",
- "\n",
- "GL1=alfa*PhotonFlux\t#in m**-3s**-1\n",
- "GL2=alfa*PhotonFlux*math.exp(-alfa*W*10**-6)\t#in m**-3s**-1\n",
- "JL=e*PhotonFlux*(1-math.exp(-alfa*W*10**-6))\t#in mA/cm**2\n",
- "\n",
- "print\"Steady state photocurrent density is \",round(JL/10,2),\"mA/cm**2\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Steady state photocurrent density is 14.69 mA/cm**2\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.3 Page no 304"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "NA=7.5*10**24\t\t#in atoms/m**3\n",
- "ND=1.5*10**22\t\t#in atoms/m**3\n",
- "De=25.0*10**-4\t\t#in m**2/s\n",
- "Dh=10.0**-3\t\t#in m**2/s\n",
- "TAUeo=500.0\t\t#in ns\n",
- "TAUho=100.0\t\t#in ns\n",
- "ni=1.5*10**16\t\t#in atoms/m**3\n",
- "VR=-10.0\t\t\t#in Volt\n",
- "epsilon=11.6*8.854*10**-12\t#in F/m\n",
- "e=1.6*10**-19\t\t#in Coulamb\n",
- "VT=26.0\t\t\t#in mV\n",
- "GL=10.0**27\t\t#in m**-3 s**-1\n",
- "\n",
- "import math\n",
- "Le=math.sqrt(De*TAUeo*10**-9)\t#in m\n",
- "Le=Le*10**6\t\t\t#in um\n",
- "Lh=math.sqrt(Dh*TAUho*10**-9)\t#in m\n",
- "Lh=Lh*10**6\t\t\t#in um\n",
- "JS=e*(ni**2)*(De/(Le*10**-6*NA)+Dh/(Lh*10**-6*ND))\t#in A/cm**2\n",
- "JL=12.5\t\t\t\t#in mA/cm**2\n",
- "VOC=VT*math.log(1.0+((JL*10**-3)/(JS*10**-4)))\t\t#in Volt\n",
- "\n",
- "print\"Open circuit voltage is\",round(VOC/1000,3),\"V\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Open circuit voltage is 0.522 V\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 8.4 Page no 304"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "Vout=28\t\t\t#in Volts\n",
- "Vcell=0.45\t\t#in Volt\n",
- "n=Vout/Vcell\t\t#Unitless\n",
- "Iout=1\t\t\t#in A\n",
- "Icell=50\t\t#in mA\n",
- "\n",
- "m=Iout/(Icell*10**-3)\t#unitless\n",
- "\n",
- "print\"The total no. of cells required : \",round(m*n)\n",
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The total no. of cells required : 1244.0\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:10bc56ed65806cbbee507a717cc3074e0bb64182283ec8c23086b1c40de0014f" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Photonic Devices" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.1 Page no 293" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#given data \n", + "NA=10**22 #in atoms/m**3\n", + "ND=10**22 #in atoms/m**3\n", + "De=25*10**-4 \t#in m**2/s\n", + "Dh=10**-3\t\t#in m**2/s\n", + "TAUeo=500\t\t#in ns\n", + "TAUho=100\t\t#in ns\n", + "ni=1.5*10**16\t\t#in atoms/m**3\n", + "VR=-10\t\t\t#in Volt\n", + "epsilon=11.6*8.854*10**-12\t#in F/m\n", + "e=1.6*10**-19\t\t\t#in Coulamb\n", + "VT=26\t\t\t\t#in mV\n", + "GL=10**27\t\t\t#in m**-3 s**-1\n", + "\n", + "\n", + "#calculation\n", + "import math\n", + "Le=math.sqrt(De*TAUeo*10**-9)\t#in um\n", + "Le=Le*10**6\t\t\t#in um\n", + "Lh=math.sqrt(Dh*TAUho*10**-9)\t#in um\n", + "Lh=Lh*10**6\t\t\t#in um\n", + "Vbi=VT*10**-3*math.log(NA*ND/ni**2)\t#in Volt\n", + "Vo=Vbi\t\t\t\t#in Volt\n", + "VB=Vo-VR\t\t\t#in Volt\n", + "W=math.sqrt((2*epsilon*VB/e)*(1/NA+1/ND))\t#in um\n", + "W=W*10**6\t\t\t#in um\n", + "JL=e*(W+Le+Lh)*10**-6*GL\t#in A/cm**2\n", + "\n", + "#Result\n", + "print \"Steady state photocurrent density is \",round(JL/10**4,3),\"A/cm**2\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Steady state photocurrent density is 0.726 A/cm**2\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.2 Page no 295" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "import math\n", + "W=25\t\t\t#in um\n", + "PhotonFlux=10**21\t#in m**2s**-1\n", + "alfa=10**5\t\t#in m**-1\n", + "e=1.6*10**-19\t\t#in Coulambs\n", + "\n", + "#calculation\n", + "GL1=alfa*PhotonFlux\t#in m**-3s**-1\n", + "GL2=alfa*PhotonFlux*math.exp(-alfa*W*10**-6)\t#in m**-3s**-1\n", + "JL=e*PhotonFlux*(1-math.exp(-alfa*W*10**-6))\t#in mA/cm**2\n", + "\n", + "#Result\n", + "print\"Steady state photocurrent density is \",round(JL/10,2),\"mA/cm**2\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Steady state photocurrent density is 14.69 mA/cm**2\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.3 Page no 304" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "NA=7.5*10**24\t\t#in atoms/m**3\n", + "ND=1.5*10**22\t\t#in atoms/m**3\n", + "De=25.0*10**-4\t\t#in m**2/s\n", + "Dh=10.0**-3\t\t#in m**2/s\n", + "TAUeo=500.0\t\t#in ns\n", + "TAUho=100.0\t\t#in ns\n", + "ni=1.5*10**16\t\t#in atoms/m**3\n", + "VR=-10.0\t\t\t#in Volt\n", + "epsilon=11.6*8.854*10**-12\t#in F/m\n", + "e=1.6*10**-19\t\t#in Coulamb\n", + "VT=26.0\t\t\t#in mV\n", + "GL=10.0**27\t\t#in m**-3 s**-1\n", + "\n", + "#Calculation\n", + "import math\n", + "Le=math.sqrt(De*TAUeo*10**-9)\t#in m\n", + "Le=Le*10**6\t\t\t#in um\n", + "Lh=math.sqrt(Dh*TAUho*10**-9)\t#in m\n", + "Lh=Lh*10**6\t\t\t#in um\n", + "JS=e*(ni**2)*(De/(Le*10**-6*NA)+Dh/(Lh*10**-6*ND))\t#in A/cm**2\n", + "JL=12.5\t\t\t\t#in mA/cm**2\n", + "VOC=VT*math.log(1.0+((JL*10**-3)/(JS*10**-4)))\t\t#in Volt\n", + "\n", + "#Result\n", + "print\"Open circuit voltage is\",round(VOC/1000,3),\"V\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Open circuit voltage is 0.522 V\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.4 Page no 304" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "Vout=28\t\t\t#in Volts\n", + "Vcell=0.45\t\t#in Volt\n", + "n=Vout/Vcell\t\t#Unitless\n", + "Iout=1\t\t\t#in A\n", + "Icell=50\t\t#in mA\n", + "\n", + "#Calculation\n", + "m=Iout/(Icell*10**-3)\t#unitless\n", + "\n", + "#Result\n", + "print\"The total no. of cells required : \",round(m*n)\n", + "#Note : Answer in the book is wrong." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The total no. of cells required : 1244.0\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Fundamentals_of_Fluid_Mechanics/Ch_8.ipynb b/Fundamentals_of_Fluid_Mechanics/Ch_8.ipynb index 81ed821d..7f3f0078 100644 --- a/Fundamentals_of_Fluid_Mechanics/Ch_8.ipynb +++ b/Fundamentals_of_Fluid_Mechanics/Ch_8.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:f5ae274b7edcc57a7498bbeb71a07ac716fad352b5f8f5416ad4bc0b8ec4e837" + "signature": "sha256:1716332d19547024e2a8a33717a7202a43672037e0646cbfaa8a401151eba8cb" }, "nbformat": 3, "nbformat_minor": 0, @@ -930,8 +930,6 @@ "l1=1000 #ft\n", "l2=500 #ft\n", "l3=400 #ft\n", - "#assuming fluid flows into B\n", - "#applying energy equation bwtween (1 and 3) and (1 and 2) and using the relation V1=V2+V3\n", "\n", "#Calculation\n", "from scipy.optimize import fsolve\n", diff --git a/Fundamentals_of_Fluid_Mechanics/Ch_9.ipynb b/Fundamentals_of_Fluid_Mechanics/Ch_9.ipynb index 1920fc56..b77b5418 100644 --- a/Fundamentals_of_Fluid_Mechanics/Ch_9.ipynb +++ b/Fundamentals_of_Fluid_Mechanics/Ch_9.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:06a8229032f3641da086be083528411370ee7c42af377d79bce74559722d5125" + "signature": "sha256:2c766184265d0fbac418d28bb9bf90901876d6391c17795f3832fa9524c975b3" }, "nbformat": 3, "nbformat_minor": 0, @@ -295,7 +295,7 @@ "input": [ "\n", "D=1.5 #in\n", - "#assuming CD=0.5 and verifying this value using value of Re\n", + "\n", "CD=0.5\n", "dice=1.84 #slugs/(ft**3) density of ice\n", "dair=2.38*(10**(-3)) #slugs/(ft**3)\n", diff --git a/Fundamentals_of_Fluid_Mechanics/ch_3.ipynb b/Fundamentals_of_Fluid_Mechanics/ch_3.ipynb index 8e1a758f..04a152bb 100644 --- a/Fundamentals_of_Fluid_Mechanics/ch_3.ipynb +++ b/Fundamentals_of_Fluid_Mechanics/ch_3.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:00c918c136b4f9ed73225af6aeb1443af9f75c0c5580d833c175de43873af847" + "signature": "sha256:4067bfb2c9423fe8c0e3cecaadb09104b0d89649fe113f722afc785b2ac06d44" }, "nbformat": 3, "nbformat_minor": 0, @@ -439,10 +439,7 @@ "V=5 #m/s\n", "sg=1.03\n", "h=50 #m\n", - "#since static pressure is greater than stagnation pressure, Bernoulli's equation is incorrect\n", - "#calculation\n", - "#p2=(d*(V1**2)/2)+(d*g*h) V1=V\n", - "#result\n", + "\n", "p2=(((sg*1000)*(V**2)/2) + (sg*1000*9.81*h))/1000 #kPa\n", "print \"The pressure at stagnation point 2 =\",round(p2,1),\"kpa\"" ], diff --git a/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_1.ipynb b/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_1.ipynb index 7c755d06..91987df5 100644 --- a/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_1.ipynb +++ b/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_1.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:711f56c3e3096fd85ba076900a2d5d1fac9fbc28d9c6a8c278c36feee7744bc6" + "signature": "sha256:2ba7e707b3be5d9c0c54b9bb8556d6e5f96b70b9fbb7f8e292b6019cfe481029" }, "nbformat": 3, "nbformat_minor": 0, @@ -125,7 +125,6 @@ "input": [ "\n", "\n", - "# Find Velocity of Coolant Fluid\n", "import math\n", "Ts = 56.4+273.15; \t\t\t\t\t#[K] - Surface Temperature of Steam\n", "Tsurr = 25+273.15; \t\t\t\t\t#[K] - Temperature of Surroundings\n", @@ -184,7 +183,6 @@ "input": [ "\n", "\n", - "# Find Skin Temperature & Heat loss rate\n", "import math\n", "A=1.8;\t \t\t\t\t\t\t\t\t# [m^2] Area for Heat transfer i.e. both surfaces\n", "Ti = 35+273.; \t \t\t\t\t\t\t\t#[K] - Inside Surface Temperature of Body\n", @@ -260,8 +258,6 @@ "input": [ "\n", "%pylab inline\n", - "# (a) Curie Temperature for h = 15 W/m^2\n", - "# (b) Value of h for cure temp = 50 deg C\n", "\n", "import math\n", "import numpy\n", diff --git a/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_12.ipynb b/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_12.ipynb index 9072d911..0458d8c6 100644 --- a/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_12.ipynb +++ b/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_12.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:304ae148e504c8ed241176c62ed1b8e5847971fcae322bbded93788c7a0511f7" + "signature": "sha256:3f70bd8e66ed069013ea8da0a0db103f64597532e63478b727d2e9fd79a10d32" }, "nbformat": 3, "nbformat_minor": 0, @@ -31,9 +31,7 @@ "\n", "\n", "import math\n", - "# a) Intensity of emission in each of the three directions\n", - "# b) Solid angles subtended by the three surfaces\n", - "# c) Rate at which radiation is intercepted by the three surfaces\n", + "\n", "\n", "A1 = .001\t\t;#[m^2] Area of emitter\n", "In = 7000\t\t;#[W/m^2.Sr] Intensity of radiation in normal direction\n", @@ -172,10 +170,7 @@ "\n", "\n", "import math\n", - "# Spectral Emissive Power of a small aperture on the enclosure\n", - "# wavelengths below which and above which 10% of the radiation is concentrated\n", - "# Spectral emissive power and wavelength associated with maximum emission\n", - "# Irradiation on a small object inside the enclosure\n", + "\n", "\n", "T = 2000.\t\t\t\t\t\t\t\t;#[K] temperature of surface\n", "stfncnstt = 5.67*math.pow(10,-8)\t\t;#[W/m^2.K^4] Stefan-Boltzmann constant\n", @@ -245,7 +240,7 @@ "import math\n", "import scipy\n", "from scipy import integrate\n", - "# Rate of emission per unit area over all directions between 0 degC and 60 degC and over all wavelengths between wavelengths 2 and 4 micro-m\n", + "\n", "\n", "T = 1500.\t\t\t\t\t\t\t\t;#[K] temperature of surface\n", "stfncnstt = 5.67*math.pow(10,-8)\t\t;#[W/m^2.K^4] Stefan-Boltzmann constant\n", @@ -298,9 +293,7 @@ "input": [ "\n", "import math\n", - "# Total hemispherical emissivity\n", - "# Total emissive Power\n", - "# Wavelength at which spectral emissive power will be maximum\n", + "\n", "\n", "T = 1600.\t\t\t\t\t\t\t\t;#[K] temperature of surface\n", "wl1 = 2 \t\t\t\t\t\t;#[micro-m] wavelength 1\n", @@ -381,8 +374,6 @@ "import math\n", "import scipy\n", "from scipy import integrate\n", - "# Spectral , Normal emissivity en and spectral hemispherical emissivity e\n", - "# Spectral normal intensity In and Spectral emissive power\n", "\n", "T = 2000.\t\t\t\t\t\t\t\t;#[K] temperature of surface\n", "wl = 1 \t\t\t\t\t\t;#[micro-m] wavelength \n", @@ -459,9 +450,7 @@ "import matplotlib\n", "from matplotlib import pyplot\n", "%pylab inline\n", - "# Spectral distribution of reflectivity\n", - "# Total, hemispherical absorptivity\n", - "# Nature of surface temperature change\n", + "\n", "\n", "T = 500.\t\t\t\t\t\t\t\t;#[K] temperature of surface\n", "e = .8;\n", @@ -535,7 +524,6 @@ "input": [ "\n", "import math\n", - "# Total emissivity of cover glass to solar radiation\n", "\n", "T = 5800.\t\t\t\t\t\t\t\t;#[K] temperature of surface\n", "e = .8;\n", @@ -582,9 +570,6 @@ "\n", "\n", "import math\n", - "# Total hemispherical emissivity of fire brick wall\n", - "# Total emissive power of brick wall\n", - "# Absorptivity of the wall to irradiation from coals\n", "\n", "Ts = 500.\t\t\t\t\t\t\t;#[K] temperature of brick surface\n", "Tc = 2000. \t\t\t\t;#[K] Temperature of coal exposed\n", @@ -650,8 +635,6 @@ "input": [ "\n", "import math\n", - "# Total hemispherical absorptivity and emissivity of sphere for initial condition\n", - "# values of absoprtivity and emissivity after sphere has been in furnace a long time\n", "\n", "Ts = 300.;\t\t\t\t\t\t\t#[K] temperature of surface\n", "Tf = 1200; \t\t\t\t#[K] Temperature of Furnace\n", @@ -714,8 +697,6 @@ "\n", "\n", "import math\n", - "# Useful heat removal rate per unit area\n", - "# Efficiency of the collector\n", "\n", "Ts = 120+273.;\t\t\t\t\t\t\t#[K] temperature of surface\n", "Gs = 750; \t\t\t\t#[W/m^2] Solar irradiation\n", diff --git a/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_13.ipynb b/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_13.ipynb index 908362f2..c86d6c34 100644 --- a/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_13.ipynb +++ b/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_13.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:9fc173b0d74248d2dec7a4473e85a2d5663ed8938149f46e30b414437d81486f" + "signature": "sha256:0be077d15f32f0d1b8e0a08fdc77fccd31f63a0aa5b7d4531be27e5ff004495f" }, "nbformat": 3, "nbformat_minor": 0, @@ -30,7 +30,6 @@ "input": [ "\n", "\n", - "# View Factors of known surface Geometries\n", "import math\n", "# (1) Sphere within Cube\n", "F12a = 1 \t\t;#By Inspection\n", @@ -93,7 +92,6 @@ "import math\n", "import numpy\n", "from numpy import linalg\n", - "# Net rate of Heat transfer to the absorber surface\n", "\n", "L = 10 \t;#[m] Collector length = Heater Length\n", "T2 = 600 \t;#[K] Temperature of curved surface\n", @@ -164,7 +162,6 @@ "\n", "\n", "import math\n", - "# Power required to maintain prescribed temperatures\n", "\n", "T3 = 300. \t\t\t\t\t;#[K] Temperature of surrounding\n", "L = .15 \t\t\t\t\t\t;#[m] Furnace Length\n", @@ -216,8 +213,6 @@ "\n", "\n", "import math\n", - "# Heat gain by the fluid passing through the inner tube\n", - "# Percentage change in heat gain with radiation shield inserted midway between inner and outer tubes\n", "\n", "T2 = 300 \t;#[K] Temperature of inner surface\n", "D2 = .05 \t;#[m] Diameter of Inner Surface\n", @@ -270,8 +265,6 @@ "input": [ "\n", "import math\n", - "# Rate at which heat must be supplied per unit length of duct\n", - "# Temperature of the insulated surface\n", "\n", "T2 = 500 \t\t\t\t\t;#[K] Temperature of Painted surface\n", "e2 = .4 \t \t\t\t\t;# emissivity of Painted Surface\n", @@ -332,8 +325,7 @@ "\n", "\n", "import math\n", - "# Rate at which heat must be supplied \n", - "# Temperature of the insulated surface\n", + "\n", "\n", "T1 = 1000. \t\t\t\t;#[K] Temperature of Heated Surface\n", "e1 = .8 \t\t\t\t\t;# emissivity of Heated Surface\n", diff --git a/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_14.ipynb b/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_14.ipynb index 6d3fd60d..b13d25b6 100644 --- a/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_14.ipynb +++ b/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_14.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:23004d8fb27d32537f04ac072677553656b3c1c397997f3010334189894b890f" + "signature": "sha256:c20c5ffc14398659aab9089e6b803cb3218676cd974382b644456d53b86a097c" }, "nbformat": 3, "nbformat_minor": 0, @@ -31,7 +31,6 @@ "\n", "\n", "import math\n", - "# Molar and mass fluxes of hydrogen and the relative values of the mass and thermal diffusivities for the three cases\n", "\n", "T = 293. \t \t\t\t\t;#[K] Temperature\n", "Ma = 2 \t\t\t\t\t;#[kg/kmol] Molecular Mass\n", @@ -139,7 +138,6 @@ "from numpy import linalg\n", "import matplotlib\n", "from matplotlib import pyplot\n", - "# Evaporation rate through a single pore\n", "\n", "T = 298 \t\t\t;#[K] Temperature\n", "D = 10*math.pow(10,-6) \t;#[m]\n", @@ -199,7 +197,6 @@ "#Variable Initialization\n", "\n", "import math\n", - "# Rate of water vapor molar diffusive ttansfer through the trough wall\n", "\n", "D = .005 \t\t\t\t\t\t;#[m] Diameter\n", "L = 50*math.pow(10,-6); \t#[m] Length\n", @@ -245,7 +242,6 @@ "#Variable Initialization\n", "\n", "import math\n", - "# The rate of change of the helium pressure dp/dt\n", "\n", "D = .2 \t\t\t;#[m] Diameter\n", "L = 2*math.pow(10,-3) ;#[m] Thickness\n", @@ -293,9 +289,6 @@ "#Variable Initialization\n", "\n", "import math\n", - "# The Hydrogen mass diffusive flux nA (kg/s.m^2)\n", - "#A -> Hydrogen\n", - "#B -> Plastic\n", "\n", "Dab = 8.7*math.pow(10,-8) ;#[m^2/s] Diffusion coefficient\n", "Sab = 1.5*math.pow(10,-3) ;#[kmol/m^3.bar] Solubility\n", @@ -345,7 +338,6 @@ "#Variable Initialization\n", "\n", "import math\n", - "# Maximum Thickness of a bacteria laden biofilm, that may be siccessfully treated\n", "\n", "Dab = 2*math.pow(10,-12) \t;#[m^2/s] Diffusion coefficient\n", "Ca0 = 4*math.pow(10,-3) \t\t;#[kmol/m^3] Fixed Concentration of medication\n", @@ -390,7 +382,6 @@ "#Variable Initialization\n", "\n", "import math\n", - "# Total dosage of medicine delivered to the patient over a one-week time period, sensivity of the dosage to the mass duffusivity of the patch and skin\n", "\n", "Dap = .1*math.pow(10,-12) ;#[m^2/s] Diffusion coefficient of medication with patch\n", "Das = .2*math.pow(10,-12) ;#[m^2/s] Diffusion coefficient of medication with skin\n", diff --git a/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_2.ipynb b/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_2.ipynb index 0de7a462..d440a2d3 100644 --- a/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_2.ipynb +++ b/Fundamentals_of_Heat_and_Mass_Transfer/Chapter_2.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:9a142a6e8cf26110d3ff9748fc8583daf04a172f1232dcfc8ee5e1fe6a9f5ec3" + "signature": "sha256:4b81d2c2d1afd02d772e0a94bc27f4f0abc2b4c7049b86921017b2dd7bb1c1b3" }, "nbformat": 3, "nbformat_minor": 0, @@ -33,9 +33,6 @@ "def alpha(p, Cp, k):\n", " a=k/(p*Cp); #[m^2/s]\n", " return a;\n", - "#(a) Pure Aluminium at 300K\n", - "# From Appendix A, Table A.1\n", - "#calculations and results\n", "\n", "p = 2702.; \t\t#[Kg/m^3] - Density Of Material \n", "Cp = 903.; \t\t\t#[J/kg.K] - Specific heat of Material\n", diff --git a/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_12.ipynb b/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_12.ipynb index 152f64d3..dd2d06ef 100644 --- a/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_12.ipynb +++ b/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_12.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:0272b11c37a42cf15d1c049753dc4426e759c84397cb741ebb3033f45eac2495" + "signature": "sha256:2b2623ff77afaafd7c16fc0720e69537bf598cad89dca70b267d9306235c5968" }, "nbformat": 3, "nbformat_minor": 0, @@ -68,7 +68,7 @@ "\n", "\n", "#Variable declaration:\n", - "#From steam tables:\n", + "\n", "U1 = 1237.1 #Internnal energy of gas (Btu/lb)\n", "U2_g = 1112.2 #Internal energy of gas (Btu/lb)\n", "U2_l = 343.15 #Internal energy of liquid (Btu/lb)\n", diff --git a/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_26.ipynb b/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_26.ipynb index bc45d0b7..64b80ece 100644 --- a/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_26.ipynb +++ b/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_26.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:69bf1b06698ebd52373cd9d0afc4312e7a8e8c49afae73fb0be120a794b9fc92" + "signature": "sha256:4c0513ab1606f42cc2658f4efc57e03793ddba6911c2c7915b3159fc7138c6b8" }, "nbformat": 3, "nbformat_minor": 0, @@ -115,9 +115,6 @@ "from __future__ import division\n", "from scipy.optimize import fmin_cobyla as optimize\n", "\n", - "#Key:\n", - "#f(x) : Objective Function\n", - "#ci(x)'s : Constraints\n", "\n", "#Variable Declaration:\n", "def f(x):\t\n", diff --git a/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_28.ipynb b/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_28.ipynb index ef8b65ac..9031d510 100644 --- a/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_28.ipynb +++ b/Heat_Transfer_Applications_for_the_Practicing_Engineer_/Chapter_28.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:b9472c6f66e6af9fe688bfa1efb446d7b7edd950704f6c5633d9a86768f75a3d" + "signature": "sha256:14824d48a431915b3dac3068270b7ce0d86b9e98bf4622dc413ebf717903e290" }, "nbformat": 3, "nbformat_minor": 0, @@ -30,9 +30,6 @@ "input": [ "\n", "\n", - "#Variable declaration:\n", - "#From table 28.3:\n", - "#For stream 1 to be heated:\n", "hm1 = 50000 #Mass flowrate (lb/h)\n", "hcP1 = 0.65 #Heat capacity (Btu/lb.\u00b0F)\n", "hTi1 = 70 #Inlet temperature (\u00b0F)\n", diff --git a/Hydraulics/Chapter_1.ipynb b/Hydraulics/Chapter_1.ipynb index afe45972..0bf18fae 100644 --- a/Hydraulics/Chapter_1.ipynb +++ b/Hydraulics/Chapter_1.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:64f6f7af2b4765d579e2e197e51bf5b0d4a46d9e2613b339c736b1f3c01726e3" + "signature": "sha256:479142d4049abdadf07bf1d76656a8c86c874f2a835275461f9e38f39f10cbd5" }, "nbformat": 3, "nbformat_minor": 0, @@ -879,7 +879,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "# calculate angle through which the cube will tilt\n", "\n", "import math \n", "import numpy\n", diff --git a/Industrial_Instrumentation/Chapter_2.ipynb b/Industrial_Instrumentation/Chapter_2.ipynb index 41a457ab..58fb16b3 100644 --- a/Industrial_Instrumentation/Chapter_2.ipynb +++ b/Industrial_Instrumentation/Chapter_2.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:e12000c40c7eba5fb38d72e0bdbc08735899d3485eb0ecea04e85215c845b6b8" + "signature": "sha256:71218a03a9605d3f7a7341594baa7c6aaf03b045951699482ae5c6da5c0be5f7" }, "nbformat": 3, "nbformat_minor": 0, @@ -28,10 +28,7 @@ "input": [ "\n", "\n", - "#(a)\n", "\n", - "#variable declaration\n", - "#1kg/cm^2=10000 mmWG\n", "x=10000.0*10.0 #equivalnt to 10kg/cm^2\n", "\n", "#result\n", diff --git a/Industrial_Instrumentation/Chapter_4.ipynb b/Industrial_Instrumentation/Chapter_4.ipynb index ea3f076f..3b3b8ccb 100644 --- a/Industrial_Instrumentation/Chapter_4.ipynb +++ b/Industrial_Instrumentation/Chapter_4.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:81d0436ef2f36f55ad662ab91b6d5e2e47a4c3c61b8080d3706a64417c68403d" + "signature": "sha256:8e99bc6fbce377831d9d5264a85c645ae2d9072f899aca1128c61ad0649fa729" }, "nbformat": 3, "nbformat_minor": 0, @@ -299,7 +299,6 @@ "\n", "#(a)\n", "\n", - "#Specific gravity at 60 degree F\n", "sg_at_60=1.02\n", "\n", "#calculation\n", diff --git a/Industrial_Instrumentation/Chapter_5.ipynb b/Industrial_Instrumentation/Chapter_5.ipynb index 4ec568e3..e24a4f35 100644 --- a/Industrial_Instrumentation/Chapter_5.ipynb +++ b/Industrial_Instrumentation/Chapter_5.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:6f1ee33190d8c693b6015349dc3ea8fa65731657e9afb9deaa10542a8aa4bde7" + "signature": "sha256:981874370471c716824dfdef461e37258f322dfc13d6037062140fc3ad5e0ae2" }, "nbformat": 3, "nbformat_minor": 0, @@ -340,7 +340,7 @@ "\n", "import math\n", "\n", - "#1kg/m^2=10 meters water head\n", + "\n", "\n", "#variable declaration\n", "g=9.81 #acceleration due to gravity\n", diff --git a/Industrial_Instrumentation/ch9.ipynb b/Industrial_Instrumentation/ch9.ipynb index fb7369a6..d03841d8 100644 --- a/Industrial_Instrumentation/ch9.ipynb +++ b/Industrial_Instrumentation/ch9.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:48e3494ec100096b5d245db7f5c631c3ee779596f8c61001fb43d1b21ba3707b" + "signature": "sha256:299eac653f64d8a7c5614d61c55d5e5b51bd64ec7dc4bb7d26a6abfad893f9e1" }, "nbformat": 3, "nbformat_minor": 0, @@ -508,7 +508,6 @@ "collapsed": false, "input": [ "\n", - "# Calculate the values of C p , C v , c p and c v for the mixture.\n", "import math \n", "\n", "# Variables\n", diff --git a/Introduction_To_Chemical_Engineering/ch3.ipynb b/Introduction_To_Chemical_Engineering/ch3.ipynb index 0b6043d2..ea36928b 100644 --- a/Introduction_To_Chemical_Engineering/ch3.ipynb +++ b/Introduction_To_Chemical_Engineering/ch3.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:dbac782d2047bc932ec3aad32143307f0552c9467f7618787890ce24a03238d4" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,12 +28,14 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "w_C = 0.6; #amount of carbon in coal\n", "N2_content = 40. #in m3 per 100m3 air\n", "\n", + "# Calculations\n", "air_consumed = N2_content/0.79;\n", "weight_air = air_consumed*(28.8/22.4);\n", "O2_content = air_consumed*32*(0.21/22.4); #in kg\n", @@ -47,6 +50,7 @@ "total_consumption = C_consumption1+C_consumption2;\n", "coal_consumption = total_consumption/w_C;\n", "\n", + "# Results\n", "print \"coal consumption = %f kg\"%(coal_consumption)\n" ], "language": "python", @@ -74,13 +78,15 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "NH3_required = (17./63)*1000; #NH3 required for 1 ton of nitric acid\n", "NO_consumption = 0.96;\n", "HNO3_consumption = 0.92;\n", "\n", + "# Calculations and Results\n", "NH3_consumed = NH3_required/(NO_consumption*HNO3_consumption);\n", "volume_NH3 = NH3_consumed*(22.4/17);\n", "print \"volume of ammonia consumed= %f cubic metre/h\"%(volume_NH3)\n", @@ -115,14 +121,16 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "HCl_production = 500. #required to be produced in kg\n", "NaCl_required = (117./73)*HCl_production;\n", "yield_ = 0.92;\n", "purity_NaCl= 0.96;\n", "\n", + "# Calculations and Results\n", "actual_NaCl = NaCl_required/(purity_NaCl*yield_);\n", "print \"amount of NaCl required = %f kg\"%(actual_NaCl)\n", "\n", @@ -160,15 +168,19 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "C2H2_produced = (1./64)*0.86; #in kmol\n", "volume_C2H2 = C2H2_produced*22.4*1000; #in l\n", "\n", + "# Calculations\n", + "#assuming ideal behaviour,\n", "volume = (100/101.3)*(273./(273+30));\n", "time = (volume_C2H2/volume)*(1./60);\n", "\n", + "# Results\n", "print \"time of service = %f hr\"%(time)\n", "\n" ], @@ -197,14 +209,16 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "xv = 0.88;\n", "xf = 0.46;\n", "xl = 0.32;\n", "F= 100. #in kg\n", "\n", + "# Calculations and Results\n", "L = (F*(xf-xv))/(xl-xv);\n", "V = F-L;\n", "print \"L = %f Kg V = %f Kg\"%(L,V)\n", @@ -246,13 +260,15 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "G1 = 3600. #in m3/h\n", "P = 106.6 #in kPa\n", "T = 40 #in degree C\n", "\n", + "# Calculations and Results\n", "q = G1*(P/101.3)*(273./((273+T))); #in m3/s\n", "m = q/22.4; #in kmol/h\n", "y1 = 0.02;\n", @@ -263,12 +279,16 @@ "Gs = m*(1-y1);\n", "print \"moles of benzene free gas = %f kmol drygas/h\"%(Gs)\n", "\n", + "#for 95% removal\n", "Y2 = Y1*(1-0.95);\n", "print \"final mole ratio of benzene = %f kmol benzene/kmol dry gas\"%(Y2)\n", "\n", "x2 = 0.002\n", "X2 = 0.002/(1-0.002);\n", "\n", + "#at equilibrium y* = 0.2406X\n", + "#part 1\n", + "#for oil rate to be minimum the wash oil leaving the absorber must be in equilibrium with the entering gas\n", "\n", "y1 = 0.02;\n", "x1 = y1/(0.2406);\n", @@ -276,6 +296,7 @@ "min_Ls = Gs*((Y1-Y2)/(X1-X2));\n", "print \"minimum Ls required = %f kg/h\"%(min_Ls*260)\n", "\n", + "#for 1.5 times of the minimum\n", "Ls = 1.5*min_Ls;\n", "print \"flow rate of wash oil = %f kg/h\"%(Ls*260)\n", "X1 = X2 + (Gs*((Y1-Y2)/Ls));\n", @@ -311,38 +332,46 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "from scipy.optimize import fsolve \n", "import math \n", "\n", + "# Variables\n", "xf = 0.01\n", "Xf = xf/(1-xf);\n", "Feed = 100 #feed in kg\n", "\n", + "# Calculations and Results\n", "c_nicotine = Feed*Xf; #nicotine conc in feed\n", "c_water = Feed*(1-Xf) #water conc in feed\n", "\n", + "#part 1\n", "def F1(x):\n", " return (x/150.)-0.9*((1-x)/99.);\n", "\n", + "#initial guess\n", "x = 10.;\n", "y = fsolve(F1,x)\n", "print \"amount of nicotine removed N = %f kg\"%(y)\n", + "#part 2\n", "def F2(x):\n", " return (x/50.)-0.9*((1-x)/99.);\n", "\n", + "#initial guess\n", "x = 10.;\n", "N1 = fsolve(F2,x)\n", "print \"amount of nicotine removed in stage 1, N1 = %f kg\"%(N1)\n", "def F3(x):\n", " return (x/50.)-0.9*((1-x-N1)/99.);\n", "\n", + "#initial guess\n", "x = 10.;\n", "N2 = fsolve(F3,x)\n", "print \"amount of nicotine removed in stage 2, N2 = %f kg\"%(N2)\n", "def F4(x):\n", " return (x/50.)-0.9*((1-x-N2-N1)/99.);\n", "\n", + "#initial guess\n", "x = 10.;\n", "N3 = fsolve(F4,x)\n", "\n", @@ -379,9 +408,10 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "vp_water = 31.06 #in kPa\n", "vp_benzene = 72.92 #in kPa\n", "\n", @@ -389,11 +419,13 @@ "x_benzene = vp_benzene/P;\n", "x_water = vp_water/P;\n", "\n", + "# Calculations\n", "initial_water = 50./18; #in kmol of water\n", "initial_benzene = 50./78 #in kmol of benzene\n", "water_evaporated = initial_benzene*(x_water/x_benzene);\n", "water_left = (initial_water - water_evaporated);\n", "\n", + "# Results\n", "print \"amount of water left in residue = %f kg\"%(water_left*18)\n" ], "language": "python", @@ -421,12 +453,14 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "po_D = 4.93 #in kPa\n", "po_W = 96.3 #in kPa\n", "n = 0.75 #vaporization efficiency\n", "\n", + "# Calculations and Results\n", "P = n*po_D+po_W;\n", "print \"P = %f kPa\"%(P)\n", "\n", @@ -435,6 +469,7 @@ "wt_dimethylanaline = (x_dimethylanaline*121)/(x_dimethylanaline*121+x_water*18);\n", "print \"weight of dimethylanaline in water = %f\"%(wt_dimethylanaline*100)\n", "\n", + "#part 1\n", "n = 0.8;\n", "po_D = 32 #in kPa\n", "actual_vp = n*po_D;\n", @@ -442,6 +477,7 @@ "steam_required = (p_water*18)/(actual_vp*121);\n", "print \"amount of steam required = %f kg steam/kg dimethylanaline\"%(steam_required)\n", "\n", + "#part 2\n", "x_water = p_water/100.;\n", "wt_water = x_water*18./(x_water*18+(1-x_water)*121.);\n", "print \"weight of water vapor = %f weight of dimethylanaline =%f\"%(wt_water*100,100*(1-wt_water))\n" @@ -474,18 +510,21 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "xf = 0.15;\n", "xl = (114.7)/(114.7+1000);\n", "xc = 1;\n", "\n", + "# Calculations\n", "K2Cr2O7_feed = 1000*0.15; #in kg\n", "\n", "n = 0.8;\n", "C = n*K2Cr2O7_feed;\n", "V = (K2Cr2O7_feed-120 - 880*0.103)/(-0.103);\n", "\n", + "# Results\n", "print \"amount of water evaporated = %f kg\"%(V)\n" ], "language": "python", @@ -513,12 +552,14 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "xc = round(106./286,3);\n", "xf = 0.25;\n", "xl = round(27.5/127.5,3);\n", "\n", + "# Calculations\n", "water_present = 100*(1-xf); #in kg\n", "V = 0.15*75; #in kg\n", "C = (100*xf - 88.7*xl)/(xc-xl);\n", @@ -526,6 +567,7 @@ "\n", "yield_ = (C/Na2CO3_feed)*100;\n", "\n", + "# Results\n", "print \"yield = %.1f %%\"%(yield_)\n" ], "language": "python", @@ -553,20 +595,23 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "r = 50. #weight of dry air passing through drier\n", "w1 = 1.60 #in kg per kg dry solid\n", "w2 = 0.1 #in kg/kg dry solid\n", "H0 = 0.016 #in kg water vapor/kg dry air\n", "H2 = 0.055 #in kg water vapor/kg dry air\n", "\n", + "# Calculations and Results\n", "y = 1 - (w1-w2)/(r*(H2-H0));\n", "print \"fraction of air recirculated = %f\"%(y)\n", "\n", "H1 = H2 - (w1-w2)/r;\n", "print \"humidity of air entering the drier = %f kg water vapor/kg kg dry air\"%(H1)\n", "\n", + "#check\n", "H11 = H2*y+H0*(1-y);\n", "if H1 == H11:\n", " print \"fraction of air recirculated = %f verified\"%(y)\n" @@ -598,12 +643,14 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "Hf = 0.012;\n", "Hi = 0.033;\n", "H1 = 0.0075;\n", "\n", + "# Calculations and Results\n", "water_vapor = Hf/18.; #in kmol of water vapor\n", "dry_air = 1/28.9; #in kmol\n", "total_mass = water_vapor+dry_air;\n", @@ -612,10 +659,12 @@ "weight = 60/volume;\n", "print \"weight of dry air handled per hr = %f kg\"%(weight)\n", "\n", + "#part 1\n", "inlet_watervapor = 0.033/18; #in kmol of water vapor\n", "volume_inlet = 22.4*(308./273)*(inlet_watervapor+dry_air);\n", "print \"volumetric flow rate of inlet air = %f cubic meter\"%(volume_inlet*weight)\n", "\n", + "#part 2\n", "y = (Hf - Hi)/(H1 - Hi);\n", "print \"fraction of inlet air passing through cooler = %f\"%(y)\n" ], @@ -646,18 +695,24 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", + "#x- moles of N2 and H2 recycled; y - moles of N2 H2 purged\n", "Ar_freshfeed = 0.2;\n", + "#argon in fresh feed is equal to argon in purge \n", "\n", + "# Calculations and Results\n", "y = 0.2/0.0633; #argon in purge = 0.0633y\n", "x = (0.79*100 - y)/(1-0.79);\n", "print \"y = %f kmolx = %f kmol\"%(y,x)\n", "\n", + "#part 1\n", "fraction = y/x;\n", "print \"fration of recycle that is purged = %f\"%(fraction)\n", "\n", + "#part 2\n", "yield_ = 0.105*(100+x);\n", "print \"overall yield of ammonia = %f kmol\"%(yield_)\n" ], @@ -688,14 +743,17 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "H0_CH4 = -74.9 #in kJ\n", "H0_CO2 = -393.5 #in kJ\n", "H0_H2O = -241.8 #in kJ\n", "\n", + "# Calculations\n", "delta_H0 = H0_CO2+2*H0_H2O-H0_CH4;\n", "\n", + "# Results\n", "print \"change in enthalpy = %f kJ\"%(delta_H0)\n" ], "language": "python", @@ -723,16 +781,20 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "H0_glucose = -1273 #in kJ\n", "H0_ethanol = -277.6 #in kJ\n", "H0_CO2 = -393.5 #in kJ\n", "H0_H2O = -285.8 #in kJ\n", "\n", + "# Calculations and Results\n", + "#for reaction 1\n", "delta_H1 = 2*H0_ethanol+2*H0_CO2-H0_glucose;\n", "print \"enthalpy change in reaction 1 = %f KJ\"%(delta_H1)\n", "\n", + "#for reaction 2\n", "delta_H2 = 6*H0_H2O+6*H0_CO2-H0_glucose;\n", "print \"enthalpy change in reaction 2 = %f kJ\"%(delta_H2)\n", "\n", @@ -768,15 +830,18 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "delta_H2 = 11.7 #in kJ/mol\n", "m_CuSO4 = 16 #in gm\n", "m_H2O = 384 #in gm\n", "\n", + "# Calculations\n", "delta_H3 = -((m_CuSO4+m_H2O)*4.18*3.95*159.6)/(16*10**3)\n", "delta_H1 = delta_H3 - delta_H2;\n", "\n", + "# Results\n", "print \"enthalpy of formation = %f kJ/mol\"%(delta_H1)\n" ], "language": "python", @@ -804,16 +869,19 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "H_combustion = 1560000 #in kJ/kmol \n", "H0_CO2 = 54.56 #in kJ/kmol\n", "H0_O2 = 35.2 #in kJ/kmol\n", "H0_steam = 43.38 #in kJ/kmol\n", "H0_N2 = 33.32 #in kJ/kmol\n", "\n", + "# Calculations\n", "t = H_combustion/(2*H0_CO2+3*H0_steam+0.875*H0_O2+16.46*H0_N2);\n", "\n", + "# Results\n", "print \"theoritical temperature of combustion = %f degree C\"%(t)\n" ], "language": "python", @@ -841,13 +909,15 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "H_NaCl = 410.9 #in MJ/kmol\n", "H_H2SO4 = 811.3 #in MJ/kmol\n", "H_Na2SO4 = 1384 #in MJ/kmol\n", "H_HCl = 92.3 #in MJ/kmol\n", "\n", + "# Calculations and Results\n", "Q = H_Na2SO4 + 2*H_HCl -2*H_NaCl-H_H2SO4;\n", "print \"heat of reaction = %f MJ\"%(Q)\n", "\n", @@ -881,17 +951,20 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "cp_water = 146.5 #in kj/kg\n", "cp_steam = 3040 #in kJ/kg\n", "d = 0.102 #in m\n", "u = 1.5 #in m/s\n", "density = 1000 #in kg/m3\n", "\n", + "# Calculations\n", "m = (3.14/4)*d**2*u*density;\n", "Q = m*(cp_steam-cp_water);\n", "\n", + "# Results\n", "print \"rate of heat flow = %f kW\"%(Q)\n" ], "language": "python", @@ -919,8 +992,9 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "wt_C = 0.75 #in kg\n", "wt_H2 = 0.05 #in kg\n", "wt_O2 = 0.12 #in kg\n", @@ -928,6 +1002,7 @@ "wt_S = 0.01 #in kg\n", "wt_ash = 0.04 #in kg\n", "\n", + "# Calculations and Results\n", "O2_C = wt_C*(32./12); #in kg\n", "O2_H2 = wt_H2*(16./2); #in kg\n", "O2_S = wt_S*(32./32); #in kg\n", @@ -965,6 +1040,7 @@ "print \"N2 = %f %%\"%(x_N2*100)\n", "print \"O2 = %f %%\"%(x_O2*100)\n", "\n", + "# Note : answers are slightly different because of rounding error." ], "language": "python", "metadata": {}, @@ -996,13 +1072,16 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "C = 0.8 #in kg\n", "H2 = 0.05 #in kg\n", "S = 0.005 #in kg\n", "ash = 0.145 #in kg\n", "\n", + "# Calculations and Results\n", + "#required oxygen in kg\n", "C_O2 = C*(32./12); \n", "H2_O2 = H2*(16./2);\n", "S_O2 = S*(32./32);\n", @@ -1013,6 +1092,7 @@ "wt_airsupplied = 1.25*wt_air;\n", "print \"amount of air supplied = %f kg\"%(wt_airsupplied)\n", "\n", + "#flue gas composition\n", "m_N2 = wt_airsupplied*0.77; #in kg\n", "mole_N2 = m_N2/28.;\n", "\n", @@ -1030,6 +1110,7 @@ "\n", "m = m_N2+m_O2+m_CO2+m_H2O+m_SO2\n", "\n", + "#percent by weight\n", "w_N2 = m_N2/m;\n", "print \"percentage of N2 by weight = %f\"%(w_N2*100)\n", "\n", @@ -1047,6 +1128,7 @@ "\n", "m1 = mole_N2+mole_O2+mole_CO2+mole_H2O+mole_SO2\n", "\n", + "#percent by mole \n", "x_N2 = mole_N2/m1;\n", "print \"percentage of N2 by mole = %f\"%(x_N2*100)\n", "\n", @@ -1098,13 +1180,15 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "wt_H2 = 0.15;\n", "wt_C = 0.85;\n", "O2_H2 = wt_H2*(16./2);\n", "O2_C = wt_C*(32./12);\n", "\n", + "# Calculations and Results\n", "total_O2 = O2_H2+O2_C;\n", "wt_air = total_O2/0.23;\n", "air_supplied = 1.15*(wt_air);\n", @@ -1152,16 +1236,19 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "N2 = 80.5 #in m3\n", "air_supplied = N2/0.79 #in m3\n", "volume_O2 = air_supplied*0.21; #in m3\n", "O2_fluegas = 6.1 #in m3\n", "\n", + "# Calculations\n", "O2_used = volume_O2 - O2_fluegas;\n", "excess_air_supplied = (O2_fluegas/O2_used)*100;\n", "\n", + "# Results\n", "print \"percentage of excess air supplied = %f\"%(excess_air_supplied)\n" ], "language": "python", @@ -1189,12 +1276,14 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "q_NTP = 10*(200/101.3)*(273./313);\n", "m_CO2 = 44*(q_NTP/22.4);\n", "s_CO2 = 0.85 #in kJ/kg K\n", "\n", + "# Calculations\n", "Q = m_CO2*s_CO2*(40-20) #Q = ms*delta_T\n", "\n", "d0 = 0.023 #in mm\n", @@ -1209,6 +1298,7 @@ "s_water = 4.19 #in kJ/kg K\n", "t = 15+(Q/(m_water*s_water));\n", "\n", + "# Results\n", "print \"exit water temperature = %f degree C\"%(t)\n" ], "language": "python", @@ -1236,11 +1326,13 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "F = 1000 #in kg\n", "xF = 0.01 \n", "\n", + "# Calculations and Results\n", "solid_feed = F*xF;\n", "water_feed = F - solid_feed;\n", "\n", @@ -1262,6 +1354,7 @@ "tc = 108.4 #in degree C\n", "hc = 454 #in kJ/kg\n", "\n", + "#applying heat balance\n", "S = (F*hF-V*Hv-L*hL)/(hc-Hs);\n", "print \"weight of steam required = %f kg/hr\"%(S)\n", "\n", @@ -1297,8 +1390,9 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "hF = 171 #in kJ/kg\n", "hD = 67 #in kJ/kg\n", "hL = hD;\n", @@ -1312,6 +1406,7 @@ "xW = 0.02;\n", "xD = 0.97;\n", "\n", + "# Calculations and Results\n", "D = F*(xF-xW)/(xD-xW);\n", "W = F-D;\n", "\n", @@ -1359,19 +1454,22 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "F = 1000.; #in kg\n", "V = 0.05*F; #in kg\n", "xF = 0.48;\n", "xL = 75./(100+75);\n", "xC = 1.;\n", "\n", + "# Calculations and Results\n", "C = (F*xF-950*xL)/(1-0.429);\n", "print \"rate of crystal formation = %f kg\"%(C)\n", "\n", "L = F-C-V;\n", "\n", + "#cooling water\n", "W = (F*2.97*(85-35)+126.9*75.2-V*2414)/(4.19*11);\n", "print \"rate of cooling water = %f kg\"%(W)\n", "\n", @@ -1410,12 +1508,15 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "delta_n = 10-12.; #mole per mole napthanlene\n", "\n", + "#basis 1g\n", "moles_napthalene = (1./128);\n", "\n", + "# Calculations and Results\n", "print ('part 1')\n", "Qv = 40.28 #in kJ\n", "Qp = Qv-(delta_n*moles_napthalene*8.3144*298./1000);\n", diff --git a/Introduction_To_Chemical_Engineering/ch5.ipynb b/Introduction_To_Chemical_Engineering/ch5.ipynb index 6af51e50..24e997c2 100644 --- a/Introduction_To_Chemical_Engineering/ch5.ipynb +++ b/Introduction_To_Chemical_Engineering/ch5.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:a84d51472594c75f9afdf6cd721b95cb9d112fa36b409d534c3bc68aa928266a" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,18 +28,21 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "A=5.*4 #in m2\n", "T1=100.; #in K\n", "T2=30.; #in K\n", "\n", + "# Calculations\n", "delta_T=T1-T2;\n", "\n", "x=0.25 #in m\n", "k=0.70 #in W/mK\n", "Q=k*A*(delta_T/x);\n", "\n", + "# Results\n", "print \"rate of heat loss = %f W\"%(Q)\n" ], "language": "python", @@ -66,12 +70,14 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "d1=0.15 #in m\n", "d2=0.16 #in m\n", "l=1. #in m\n", "\n", + "# Calculations\n", "A1=3.14*d1*l;\n", "A2=3.14*d2*l\n", "Am=(A1-A2)/math.log (A1/A2);\n", @@ -84,6 +90,7 @@ "k=50. #in W/mK\n", "Q=k*Am*(delta_T/x);\n", "\n", + "# Results\n", "print \"rate of heat loss per unit length = %f W/m\"%(Q)\n" ], "language": "python", @@ -111,13 +118,15 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "ri=0.5 #in m\n", "ro=0.6; #in m\n", "A1=4*3.14*ri**2;\n", "A2=4*3.14*ro**2;\n", "\n", + "# Calculations\n", "Am=(A1*A2)**0.5;\n", "\n", "Ti=140.; #in K\n", @@ -128,6 +137,7 @@ "\n", "Q=k*Am*(delta_T/x);\n", "\n", + "# Results\n", "print \"Heat loss through sphere = %f W\"%(Q)\n" ], "language": "python", @@ -155,13 +165,16 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "x1=0.250; #in m\n", "k1=0.7; #in W/mK\n", "A1=1.; #in m2\n", "R1=x1/(k1*A1); #in K/W\n", "\n", + "# Calculations and Results\n", + "#for the felt layer\n", "x2=0.020; #in m\n", "k2=0.046; #in W/mK\n", "A2=1.; #in m2\n", @@ -201,8 +214,9 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "d1=0.15 #in m\n", "d2=0.16 #in m\n", "l=1. #in m\n", @@ -213,6 +227,8 @@ "k1=50. #in W/mK\n", "R1=x1/(k1*Am1);\n", "\n", + "# Calculations and Results\n", + "#resistance by insulation\n", "d2=0.16 #in m\n", "d3=0.26 #in m\n", "l=1. #in m\n", @@ -259,8 +275,9 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "x1=0.1; #in m\n", "x2= 0.25; #in m\n", "k_rb=0.93; #in W/mK\n", @@ -268,6 +285,8 @@ "k_al=203.6 #in W/mK\n", "A=0.1 #in m2\n", "\n", + "# Calculations and Results\n", + "#to find resistance without rivets\n", "R=(1/A)*((x1/k_rb)+(x2/k_ib));\n", "T1=225 #in K\n", "T2=37 #in K\n", @@ -275,6 +294,7 @@ "Q=delta_T/R;\n", "print \"heat transfer rate = %f W\"%(Q)\n", "\n", + "#to find resistance with rivet\n", "d=0.03 #in m\n", "rivet_area= (3.14/4)*d**2;\n", "R_r=(x1+x2)/(k_al*rivet_area);\n", @@ -314,20 +334,17 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "calculate the heat tranfer coefficient based on \n", - "i) the arithmetic mean difference between the temperatures of the water and the wall of the tube\n", - "ii) the logarithmic mean difference between the temperatures of the water and the wall of the tube.\n", - "'''\n", - "\n", + " \n", "import math\n", "\n", + "# variables\n", "Cp = 4.178 # kJ/kg K for water\n", "q = 1838. # rate at which heat is transfered\n", "A = .1005 # heat transfer area\n", "dt1 = 80. - 24 # temperature diffference at hot end\n", "dt2 = 36.-24 # temperature difference at cold end\n", "\n", + "# Calculations and Results\n", "dtm = (56 + 12)/2.0\n", "h = q/(A*dtm)\n", "print \"Heat transfer coefficient, h = %.0f W/m**2 K\"%h\n", @@ -363,9 +380,10 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "density=984.1 #in kg/cubic meter\n", "v=3. #in m/s\n", "viscosity=485*10**-6; #in Pa-s\n", @@ -373,12 +391,15 @@ "cp=4178. #in J/kg K\n", "d=0.016 #in m\n", "\n", + "# Calculations and Results\n", "Re=(density*v*d)/viscosity;\n", "Pr=(cp*viscosity)/k;\n", "\n", + "#dittus boelter equation\n", "h=0.023*Re**0.8*Pr**0.3*(k/d);\n", "print \"heat transfer coefficient = %f W/sq meter K\"%(h)\n", "\n", + "#Sieder Tate equation\n", "viscosity_w=920*10**-6.\n", "h1=0.023*Re**0.8*Pr**(1./3)*(k/d)*(viscosity/viscosity_w)**0.14;\n", "print \"heat transfer coefficient = %f W/sq meter K\"%(h1)\n" @@ -409,14 +430,17 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "T_sun = 5973 #in degree C\n", "d = 1.5*10**13 #in cm\n", "R = 7.1*10**10; #in cm\n", "\n", + "# Calculations\n", "T_earth = ((R/(2*d))**0.5)*T_sun;\n", "\n", + "# Results\n", "print \"Temperature of earth = %f C\"%(T_earth-273) \n" ], "language": "python", @@ -444,14 +468,17 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "R=7*10**10; #in cm\n", "Ts=6000; #in K\n", "\n", + "# Calculations\n", "l=1.5*10**13; #in m\n", "To=((R**2/(4*l**2))**0.25)*Ts;\n", "\n", + "# Results\n", "print \"temperature of earth = %f K\"%(To)\n" ], "language": "python", @@ -479,14 +506,17 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "R=6.92*10**5 #in km\n", "l=14.97*10**7 #in km\n", "Ts=6200; #in K\n", "\n", + "# Calculations\n", "To=(R**2/l**2)**0.25*Ts;\n", "\n", + "# Results\n", "print \"Equilibrium temperature = %f K\"%(To)\n" ], "language": "python", @@ -514,15 +544,18 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "view_factor=0.5;\n", "R=6.92*10**5 #in km\n", "l=14.97*10**7 #in km\n", "Ts=6200; #in K\n", "\n", + "# Calculations\n", "To=(view_factor*(R**2/l**2))**0.25*Ts;\n", "\n", + "# Results\n", "print \"Equilibrium temperature = %f K\"%(To)\n", "\n", "\n" @@ -552,8 +585,9 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "view_factor=0.25;\n", "R=7.1*10**10 #in cm\n", "l=1.5*10**13 #in cm\n", @@ -561,10 +595,12 @@ "alpha=0.2;\n", "epsilon=0.1;\n", "\n", + "# Calculations\n", "ratio=alpha/epsilon;\n", "To=(ratio*view_factor*(R**2/l**2))**0.25*Ts;\n", "\n", "\n", + "# Results\n", "print \"Equilibrium temperature = %f K\"%(To)\n" ], "language": "python", @@ -592,15 +628,18 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "R=7*10**10; #in cm\n", "l=1.5*10**13; #in cm\n", "sigma=5.3*10**-5; #in erd/s(cm2)(K)4\n", "T=6000; #in K\n", "\n", + "# Calculations\n", "S=(R/l)**2*(sigma)*(T**4)*60;\n", "\n", + "# Results\n", "print \"solar constant = %f J/sq cm min\"%(S/10**7)\n" ], "language": "python", @@ -628,12 +667,14 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "F = 5000. #in kg/hr\n", "xF = 0.01\n", "xL = 0.02;\n", "\n", + "# Calculations and Results\n", "L = F*xF/xL;\n", "V = F-L;\n", "print \"L = %f Kg/hr V = %f kg/hr\"%(L,V)\n", @@ -682,15 +723,18 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "from numpy import *\n", + "# Variables\n", "b1 = 6000*125.79+3187.56*2691.5-3187.56*461.30; #data from previous problem\n", "b2 = 6000;\n", "A = array([[419.04, 2676.1],[1, 1]])\n", "\n", + "# Calculations and Results\n", "b = array([[b1],[b2]]);\n", "x = linalg.solve(A,b)\n", + "#x = x*b\n", "L = x[0];\n", "V = x[1];\n", "\n", @@ -727,11 +771,13 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", + "# Variables\n", "Hv=2635.3 #kJ/kg\n", "hL=313.93 #in kJ/kg\n", "\n", + "# Calculations and Results\n", "S=(2500*313.93+2500*2635.3-5000*125.79)/(2691.5-461.30);\n", "print \"steam flow rate = %f kg steam/hr\"%(S)\n", "\n", @@ -744,6 +790,7 @@ "print \"Area = %f sq meter\"%(A)\n", "print \"in this case a condensor and vaccum pump should be used\"\n", "\n", + "# Note : there is mistake in calculation in Book. Please calculate manually." ], "language": "python", "metadata": {}, diff --git a/Let_us_C/chapter-1.ipynb b/Let_us_C/chapter-1.ipynb index 5c48f867..215baac9 100644 --- a/Let_us_C/chapter-1.ipynb +++ b/Let_us_C/chapter-1.ipynb @@ -1,212 +1,206 @@ -{
- "metadata": {
- "name": "chapter-1.ipynb"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h1>Chapter 1: Getting Started<h1>"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>First C Program, Page number: 14<h3>\n",
- " "
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "p = 1000 #principle\n",
- "n = 3 # number of years\n",
- "r = 8.5 # rate of interest\n",
- "\n",
- "#Calculation\n",
- "si = p * n * r / 100 ; #formula for simple interest\n",
- "\n",
- "#Result\n",
- "print ( si )\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "255.0\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Simple Interest, Page number: 21<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Input from the user\n",
- "#p,n,r = raw_input(\"Enter values of p, n, r : \").split()\n",
- "p = 100 # principle\n",
- "n = 5 # number of years\n",
- "r = 15.5 # rate of interest\n",
- "\n",
- "#Calculation\n",
- "si = p * n * r / 100 ; #formula for simple interest\n",
- "\n",
- "#Result\n",
- "print ( si )\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "77.5\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Just for fun, Page number: 22<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Input from the user\n",
- "#num = raw_input(\"Enter a number : \")\n",
- "num = 11\n",
- "\n",
- "#Result\n",
- "print \"Now I am letting you on a secret...\" \n",
- "print \"You have just entered the number\", num \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Now I am letting you on a secret...\n",
- "You have just entered the number 11\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Example 1.1, Page number: 32<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Calculation\n",
- "i1 = 2 * 3 # operation *\n",
- "i2 = i1 / 4 # operation /\n",
- "i3 = 4 / 4 # operation /\n",
- "i4 = 5 / 8 # operation /\n",
- "i5 = i2 + i3 # operation +\n",
- "i6 = i5 + 8 # operation +\n",
- "i7 = i6 - 2 # operation -\n",
- "i8 = i7 + i4 # operation +\n",
- "i = i8\n",
- "\n",
- "#Result\n",
- "print \"i = \", i"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "i = 8\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Example 1.2, Page number: 33<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Calculation\n",
- "kk1 = 3 / 2# operation /\n",
- "kk2 = kk1 * 4 # operation *\n",
- "kk3 = 3 / 8 # operation /\n",
- "kk4 = kk2 + kk3 # operation +\n",
- "kk5 = kk4 + 3 # operation +\n",
- "kk = kk5\n",
- "\n",
- "#Result\n",
- "print \"kk = \", kk\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "kk = 7\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:67e127b30e1e4aca343f9987e4ae454c0b4254a7be37191ad1b156a6da5403fc" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h1>Chapter 1: Getting Started<h1>" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>First C Program, Page number: 14<h3>\n", + " " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "p = 1000 #principle\n", + "n = 3 # number of years\n", + "r = 8.5 # rate of interest\n", + "\n", + "#Calculation\n", + "si = p * n * r / 100 ; #formula for simple interest\n", + "\n", + "#Result\n", + "print ( si )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "255.0\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Simple Interest, Page number: 21<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "p = 100 # principle\n", + "n = 5 # number of years\n", + "r = 15.5 # rate of interest\n", + "\n", + "#Calculation\n", + "si = p * n * r / 100 ; #formula for simple interest\n", + "\n", + "#Result\n", + "print ( si )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "77.5\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Just for fun, Page number: 22<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "num = 11\n", + "\n", + "#Result\n", + "print \"Now I am letting you on a secret...\" \n", + "print \"You have just entered the number\", num \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Now I am letting you on a secret...\n", + "You have just entered the number 11\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Example 1.1, Page number: 32<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "i1 = 2 * 3 # operation *\n", + "i2 = i1 / 4 # operation /\n", + "i3 = 4 / 4 # operation /\n", + "i4 = 5 / 8 # operation /\n", + "i5 = i2 + i3 # operation +\n", + "i6 = i5 + 8 # operation +\n", + "i7 = i6 - 2 # operation -\n", + "i8 = i7 + i4 # operation +\n", + "i = i8\n", + "\n", + "#Result\n", + "print \"i = \", i" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i = 8\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Example 1.2, Page number: 33<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "kk1 = 3 / 2# operation /\n", + "kk2 = kk1 * 4 # operation *\n", + "kk3 = 3 / 8 # operation /\n", + "kk4 = kk2 + kk3 # operation +\n", + "kk5 = kk4 + 3 # operation +\n", + "kk = kk5\n", + "\n", + "#Result\n", + "print \"kk = \", kk\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "kk = 7\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Let_us_C/chapter-10.ipynb b/Let_us_C/chapter-10.ipynb index 93132187..7257e56a 100644 --- a/Let_us_C/chapter-10.ipynb +++ b/Let_us_C/chapter-10.ipynb @@ -1,483 +1,483 @@ -{
- "metadata": {
- "name": "chapter-10.ipynb"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h1>Chapter 10: Structures <h1>"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Arrays , Page number: 365<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "name = []\n",
- "price = []\n",
- "pages = []\n",
- "\n",
- "n =[\"A\",\"C\",\"F\"]\n",
- "p=[100.00,256.50,233.70]\n",
- "pg=[354,682,512]\n",
- "\n",
- "print \"Enter names, prices and no. of pages of 3 books \" \n",
- "\n",
- "for i in range(0,3):\n",
- " #n,p,pg = raw_input(\"\").split()\n",
- " print n[i],p[i],pg[i]\n",
- " name.append(n[i])\n",
- " price.append(p[i])\n",
- " pages.append(pg[i])\n",
- "\n",
- "print \"And this is what you entered\" \n",
- "\n",
- "for i in range(0,3):\n",
- " print name[i], price[i], pages[i] "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter names, prices and no. of pages of 3 books \n",
- "A 100.0 354\n",
- "C 256.5 682\n",
- "F 233.7 512\n",
- "And this is what you entered\n",
- "A 100.0 354\n",
- "C 256.5 682\n",
- "F 233.7 512\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Structure Example , Page number: 366<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from collections import namedtuple\n",
- "#Structure defintion\n",
- "struct_book = namedtuple(\"struct_book\", \"name price pages\")\n",
- "\n",
- "#Input from user\n",
- "print \"Enter names, prices & no. of pages of 3 books\" \n",
- "#b1n,b1p,b1pg = raw_input(\"\").split()\n",
- "#b2n,b2p,b2pg = raw_input(\"\").split()\n",
- "#b3n,b3p,b3pg = raw_input(\"\").split()\n",
- "n =[\"A\",\"C\",\"F\"]\n",
- "p=[100.00,256.50,233.70]\n",
- "pg=[354,682,512]\n",
- "print n[0],p[0],pg[0]\n",
- "print n[1],p[1],pg[1]\n",
- "print n[2],p[2],pg[2]\n",
- "#Structures for 3 books\n",
- "b1 = struct_book(n[0], p[0], pg[0])\n",
- "b2 = struct_book(n[1], p[1], pg[1])\n",
- "b3 = struct_book(n[2], p[2], pg[2])\n",
- "\n",
- "\n",
- "#Result\n",
- "print \"And this is what you entered\" \n",
- "print b1.name, b1.price, b1.pages \n",
- "print b2.name, b2.price, b2.pages \n",
- "print b3.name, b3.price, b3.pages \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter names, prices & no. of pages of 3 books\n",
- "A 100.0 354\n",
- "C 256.5 682\n",
- "F 233.7 512\n",
- "And this is what you entered\n",
- "A 100.0 354\n",
- "C 256.5 682\n",
- "F 233.7 512\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Memory Map of Structures , Page number: 370<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from collections import namedtuple\n",
- "#Structure defintion\n",
- "struct_book = namedtuple(\"struct_book\", \"name price pages\")\n",
- "\n",
- "#Structures for a book\n",
- "b1 = struct_book('B', 130.00, 550)\n",
- "\n",
- "#Result\n",
- "print \"Address of name = \", id(b1.name )\n",
- "print \"Address of price = \", id(b1.price )\n",
- "print \"Address of pages = \", id(b1.pages )"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Address of name = 31603728\n",
- "Address of price = 108997488\n",
- "Address of pages = 133808864\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Array of Structures , Page number: 371<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from collections import namedtuple\n",
- "#Structure defintion\n",
- "struct_book = namedtuple(\"struct_book\", \"name price pages\")\n",
- "\n",
- "#Array of structures\n",
- "b =[]\n",
- "\n",
- "n =[\"A\",\"C\",\"F\"]\n",
- "p=[100.00,256.50,233.70]\n",
- "pg=[354,682,512]\n",
- "\n",
- "#Storing data in the array\n",
- "for i in range(0,3):\n",
- " #bn, bp, bpg =raw_input( \"Enter name, price and pages: \" ).split()\n",
- " print \"Enter name, price and pages: \"\n",
- " print n[i],p[i],pg[i]\n",
- " b.append(struct_book(n[i], p[i], pg[i]))\n",
- "\n",
- "#Result\n",
- "for i in range(0,3):\n",
- " print b[i].name, b[i].price, b[i].pages \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter name, price and pages: \n",
- "A 100.0 354\n",
- "Enter name, price and pages: \n",
- "C 256.5 682\n",
- "Enter name, price and pages: \n",
- "F 233.7 512\n",
- "A 100.0 354\n",
- "C 256.5 682\n",
- "F 233.7 512\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Copying Structures , Page number: 374<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "assigned to another structure variable of the same type\n",
- "\n",
- "from collections import namedtuple\n",
- "#Structure defintion\n",
- "struct_employee = namedtuple(\"struct_employee\", \"name age salary\")\n",
- "\n",
- "#Structures for 3 employees\n",
- "e1 = struct_employee(\"Sanjay\", 30, 5500.50)\n",
- "e2 = struct_employee(\" \",0,0)\n",
- "e3 = struct_employee(\" \",0,0)\n",
- "\n",
- "#piece-meal copying \n",
- "import copy\n",
- "e2 = e2._replace(name = e1.name)\n",
- "e2 = e2._replace(age = e1.age)\n",
- "e2 = e2._replace(salary = e1.salary)\n",
- "\n",
- "\n",
- "#copying all elements at one go \n",
- "e3 = e2\n",
- "\n",
- "#Result\n",
- "print e1.name, e1.age, e1.salary \n",
- "print e2.name, e2.age, e2.salary \n",
- "print e3.name, e3.age, e3.salary \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sanjay 30 5500.5\n",
- "Sanjay 30 5500.5\n",
- "Sanjay 30 5500.5\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Nested Structures , Page number: 375<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from collections import namedtuple\n",
- "#Structure defintions\n",
- "struct_address = namedtuple(\"struct_address\", \"phone city pin\")\n",
- "struct_emp = namedtuple(\"struct_emp\", \"name struct_address\") #nested structures\n",
- "\n",
- "#Structures for employee\n",
- "a = struct_address(\"531046\", \"nagpur\", 10)\n",
- "e = struct_emp(\"jeru\",a) #nested structure\n",
- "\n",
- "#Result\n",
- "print \"name = %s phone = %s\" %( e.name, e.struct_address.phone )\n",
- "print \"city = %s pin = %d\" %( e.struct_address.city, e.struct_address.pin )\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "name = jeru phone = 531046\n",
- "city = nagpur pin = 10\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Passing Individual Structure Elements to Functions, Page number: 377<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from collections import namedtuple\n",
- "#Structure defintions\n",
- "struct_book = namedtuple(\"struct_book\", \"name author callno\")\n",
- "\n",
- "#Function definition\n",
- "def display (s,t,n):\n",
- " print s, t, n \n",
- " \n",
- "#Structures for book\n",
- "b1 = struct_book(\"Let us C\", \"YPK\", 101)\n",
- "\n",
- "\n",
- "display ( b1.name, b1.author, b1.callno ) #function call\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Let us C YPK 101\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Passing Structure to a Function , Page number: 378<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from collections import namedtuple\n",
- "#Structure defintions\n",
- "struct_book = namedtuple(\"struct_book\", \"name author callno\")\n",
- "\n",
- "#Function definition\n",
- "def display (b):\n",
- " print b.name, b.author, b.callno \n",
- " \n",
- "#Structures for book\n",
- "b1 = struct_book(\"Let us C\", \"YPK\", 101)\n",
- "\n",
- "\n",
- "display ( b1) #function call\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Let us C YPK 101\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Structure Pointers , Page number: 379<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from collections import namedtuple\n",
- "#Structure defintions\n",
- "struct_book = namedtuple(\"struct_book\", \"name author callno\")\n",
- "\n",
- "#Structure for book\n",
- "b1 = struct_book(\"Let us C\", \"YPK\", 101)\n",
- "ptr = id(b1) #structure pointer\n",
- "\n",
- "#Result\n",
- "print b1.name, b1.author, b1.callno \n",
- "print b1.name, b1.author, b1.callno \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Let us C YPK 101\n",
- "Let us C YPK 101\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Passing Address of a Structure Variable , Page number: 380<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#function definition\n",
- "def display (b):\n",
- " print b.name, b.author, b.callno \n",
- " \n",
- "from collections import namedtuple\n",
- "#Structure defintions\n",
- "struct_book = namedtuple(\"struct_book\", \"name author callno\")\n",
- "\n",
- "#Structure for book\n",
- "b1 = struct_book(\"Let us C\", \"YPK\", 101)\n",
- "\n",
- "#function call\n",
- "display ( b1 ) \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Let us C YPK 101\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:adc18fea588596d0bfa5f1f11f3697194c0b52d2d9eb299f10c4a99dfea56e31" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h1>Chapter 10: Structures <h1>" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Arrays , Page number: 365<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "name = []\n", + "price = []\n", + "pages = []\n", + "\n", + "n =[\"A\",\"C\",\"F\"]\n", + "p=[100.00,256.50,233.70]\n", + "pg=[354,682,512]\n", + "\n", + "print \"Enter names, prices and no. of pages of 3 books \" \n", + "\n", + "for i in range(0,3):\n", + " #n,p,pg = raw_input(\"\").split()\n", + " print n[i],p[i],pg[i]\n", + " name.append(n[i])\n", + " price.append(p[i])\n", + " pages.append(pg[i])\n", + "\n", + "print \"And this is what you entered\" \n", + "\n", + "for i in range(0,3):\n", + " print name[i], price[i], pages[i] " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter names, prices and no. of pages of 3 books \n", + "A 100.0 354\n", + "C 256.5 682\n", + "F 233.7 512\n", + "And this is what you entered\n", + "A 100.0 354\n", + "C 256.5 682\n", + "F 233.7 512\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Structure Example , Page number: 366<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from collections import namedtuple\n", + "#Structure defintion\n", + "struct_book = namedtuple(\"struct_book\", \"name price pages\")\n", + "\n", + "#Input from user\n", + "print \"Enter names, prices & no. of pages of 3 books\" \n", + "#b1n,b1p,b1pg = raw_input(\"\").split()\n", + "#b2n,b2p,b2pg = raw_input(\"\").split()\n", + "#b3n,b3p,b3pg = raw_input(\"\").split()\n", + "n =[\"A\",\"C\",\"F\"]\n", + "p=[100.00,256.50,233.70]\n", + "pg=[354,682,512]\n", + "print n[0],p[0],pg[0]\n", + "print n[1],p[1],pg[1]\n", + "print n[2],p[2],pg[2]\n", + "#Structures for 3 books\n", + "b1 = struct_book(n[0], p[0], pg[0])\n", + "b2 = struct_book(n[1], p[1], pg[1])\n", + "b3 = struct_book(n[2], p[2], pg[2])\n", + "\n", + "\n", + "#Result\n", + "print \"And this is what you entered\" \n", + "print b1.name, b1.price, b1.pages \n", + "print b2.name, b2.price, b2.pages \n", + "print b3.name, b3.price, b3.pages \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter names, prices & no. of pages of 3 books\n", + "A 100.0 354\n", + "C 256.5 682\n", + "F 233.7 512\n", + "And this is what you entered\n", + "A 100.0 354\n", + "C 256.5 682\n", + "F 233.7 512\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Memory Map of Structures , Page number: 370<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from collections import namedtuple\n", + "#Structure defintion\n", + "struct_book = namedtuple(\"struct_book\", \"name price pages\")\n", + "\n", + "#Structures for a book\n", + "b1 = struct_book('B', 130.00, 550)\n", + "\n", + "#Result\n", + "print \"Address of name = \", id(b1.name )\n", + "print \"Address of price = \", id(b1.price )\n", + "print \"Address of pages = \", id(b1.pages )" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Address of name = 31603728\n", + "Address of price = 108997488\n", + "Address of pages = 133808864\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Array of Structures , Page number: 371<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from collections import namedtuple\n", + "#Structure defintion\n", + "struct_book = namedtuple(\"struct_book\", \"name price pages\")\n", + "\n", + "#Array of structures\n", + "b =[]\n", + "\n", + "n =[\"A\",\"C\",\"F\"]\n", + "p=[100.00,256.50,233.70]\n", + "pg=[354,682,512]\n", + "\n", + "#Storing data in the array\n", + "for i in range(0,3):\n", + " #bn, bp, bpg =raw_input( \"Enter name, price and pages: \" ).split()\n", + " print \"Enter name, price and pages: \"\n", + " print n[i],p[i],pg[i]\n", + " b.append(struct_book(n[i], p[i], pg[i]))\n", + "\n", + "#Result\n", + "for i in range(0,3):\n", + " print b[i].name, b[i].price, b[i].pages \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter name, price and pages: \n", + "A 100.0 354\n", + "Enter name, price and pages: \n", + "C 256.5 682\n", + "Enter name, price and pages: \n", + "F 233.7 512\n", + "A 100.0 354\n", + "C 256.5 682\n", + "F 233.7 512\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Copying Structures , Page number: 374<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "from collections import namedtuple\n", + "#Structure defintion\n", + "struct_employee = namedtuple(\"struct_employee\", \"name age salary\")\n", + "\n", + "#Structures for 3 employees\n", + "e1 = struct_employee(\"Sanjay\", 30, 5500.50)\n", + "e2 = struct_employee(\" \",0,0)\n", + "e3 = struct_employee(\" \",0,0)\n", + "\n", + "#piece-meal copying \n", + "import copy\n", + "e2 = e2._replace(name = e1.name)\n", + "e2 = e2._replace(age = e1.age)\n", + "e2 = e2._replace(salary = e1.salary)\n", + "\n", + "\n", + "#copying all elements at one go \n", + "e3 = e2\n", + "\n", + "#Result\n", + "print e1.name, e1.age, e1.salary \n", + "print e2.name, e2.age, e2.salary \n", + "print e3.name, e3.age, e3.salary \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sanjay 30 5500.5\n", + "Sanjay 30 5500.5\n", + "Sanjay 30 5500.5\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Nested Structures , Page number: 375<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from collections import namedtuple\n", + "#Structure defintions\n", + "struct_address = namedtuple(\"struct_address\", \"phone city pin\")\n", + "struct_emp = namedtuple(\"struct_emp\", \"name struct_address\") #nested structures\n", + "\n", + "#Structures for employee\n", + "a = struct_address(\"531046\", \"nagpur\", 10)\n", + "e = struct_emp(\"jeru\",a) #nested structure\n", + "\n", + "#Result\n", + "print \"name = %s phone = %s\" %( e.name, e.struct_address.phone )\n", + "print \"city = %s pin = %d\" %( e.struct_address.city, e.struct_address.pin )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "name = jeru phone = 531046\n", + "city = nagpur pin = 10\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Passing Individual Structure Elements to Functions, Page number: 377<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from collections import namedtuple\n", + "#Structure defintions\n", + "struct_book = namedtuple(\"struct_book\", \"name author callno\")\n", + "\n", + "#Function definition\n", + "def display (s,t,n):\n", + " print s, t, n \n", + " \n", + "#Structures for book\n", + "b1 = struct_book(\"Let us C\", \"YPK\", 101)\n", + "\n", + "\n", + "display ( b1.name, b1.author, b1.callno ) #function call\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Let us C YPK 101\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Passing Structure to a Function , Page number: 378<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from collections import namedtuple\n", + "#Structure defintions\n", + "struct_book = namedtuple(\"struct_book\", \"name author callno\")\n", + "\n", + "#Function definition\n", + "def display (b):\n", + " print b.name, b.author, b.callno \n", + " \n", + "#Structures for book\n", + "b1 = struct_book(\"Let us C\", \"YPK\", 101)\n", + "\n", + "\n", + "display ( b1) #function call\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Let us C YPK 101\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Structure Pointers , Page number: 379<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from collections import namedtuple\n", + "#Structure defintions\n", + "struct_book = namedtuple(\"struct_book\", \"name author callno\")\n", + "\n", + "#Structure for book\n", + "b1 = struct_book(\"Let us C\", \"YPK\", 101)\n", + "ptr = id(b1) #structure pointer\n", + "\n", + "#Result\n", + "print b1.name, b1.author, b1.callno \n", + "print b1.name, b1.author, b1.callno \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Let us C YPK 101\n", + "Let us C YPK 101\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Passing Address of a Structure Variable , Page number: 380<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#function definition\n", + "def display (b):\n", + " print b.name, b.author, b.callno \n", + " \n", + "from collections import namedtuple\n", + "#Structure defintions\n", + "struct_book = namedtuple(\"struct_book\", \"name author callno\")\n", + "\n", + "#Structure for book\n", + "b1 = struct_book(\"Let us C\", \"YPK\", 101)\n", + "\n", + "#function call\n", + "display ( b1 ) \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Let us C YPK 101\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Let_us_C/chapter-11.ipynb b/Let_us_C/chapter-11.ipynb index 6e6a2bf4..697d86a1 100644 --- a/Let_us_C/chapter-11.ipynb +++ b/Let_us_C/chapter-11.ipynb @@ -1,373 +1,365 @@ -{
- "metadata": {
- "name": "chapter-11.ipynb"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h1>Chapter 11: Console Input/Output<h1>"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Printf Example, Page number: 397<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "avg = 346 \n",
- "per = 69.2\n",
- "\n",
- "#Result\n",
- "print \"Average = %d\\nPercentage = %f\" %(avg, per )\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Average = 346\n",
- "Percentage = 69.200000\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Format Specifications, Page number: 399<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "weight = 63\n",
- "\n",
- "#Result\n",
- "print \"weight is %d kg\" %( weight ) \n",
- "print \"weight is %2d kg\"%( weight ) \n",
- "print \"weight is %4d kg\" %( weight )\n",
- "print \"weight is %6d kg\" %(weight ) \n",
- "print \"weight is %-6d kg\" %( weight )\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "weight is 63 kg\n",
- "weight is 63 kg\n",
- "weight is 63 kg\n",
- "weight is 63 kg\n",
- "weight is 63 kg\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>String Format Specifiers, Page number: 400<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "firstname1 = \"Sandy\" \n",
- "surname1 = \"Malya\" \n",
- "firstname2 = \"AjayKumar\" \n",
- "surname2 = \"Gurubaxani\" \n",
- "\n",
- "#Result\n",
- "print \"%20s%20s\" %( firstname1, surname1 )\n",
- "print \"%20s%20s\" %(firstname2, surname2 ) \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Sandy Malya\n",
- " AjayKumar Gurubaxani\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Escape Sequences, Page number: 401<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Result\n",
- "print \"You\\tmust\\tbe\\tcrazy\\nto\\thate\\tthis\\tbook\" \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "You\tmust\tbe\tcrazy\n",
- "to\thate\tthis\tbook\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Format Conversions, Page number: 403<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "ch = 'z' \n",
- "i = 125 \n",
- "a = 12.55 \n",
- "s = \"hello there !\"\n",
- "\n",
- "#Result\n",
- "print \"%c %d %f\" %( ch, ord(ch), ord(ch )) \n",
- "print \"%s %d %f\"%( s, ord(s[1]), ord(s[1]) )\n",
- "print \"%c %d %f\"%(i ,i, i ) \n",
- "print \"%f %d\\n\"%( a, a )\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "z 122 122.000000\n",
- "hello there ! 101 101.000000\n",
- "} 125 125.000000\n",
- "12.550000 12\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Sprintf Function, Page number: 404<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "i = 10 \n",
- "ch = 'A'\n",
- "a = 3.14 \n",
- "\n",
- "\n",
- "#Result\n",
- "print \"%d %c %f\" %(i, ch, a ) \n",
- "str = \"%d %c %f\" %(i, ch, a ) #sprintf\n",
- "print \"%s\" %(str )\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10 A 3.140000\n",
- "10 A 3.140000\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Unformatted Input, Page number: 406<h3>\n"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import msvcrt\n",
- "\n",
- "print \"Press any key to continue\" \n",
- "#msvcrt.getch( ) # will not echo the character \n",
- "print \"Type any character\" \n",
- "#ch = msvcrt.getche( ) # will echo the character typed \n",
- "ch = 'A'\n",
- "print ch\n",
- "#ch = input(\"Type any character\")#getchar( ) will echo character, must be followed by enter key \n",
- "print \"Type any character\"\n",
- "ch = 8\n",
- "print ch\n",
- "#ch = input( \"Continue Y/N\" ) #fgetchar( ) will echo character, must be followed by enter key\n",
- "print \"Continue Y/N\" \n",
- "ch = 'N'\n",
- "print ch\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Press any key to continue\n",
- "Type any character\n",
- "A\n",
- "Type any character\n",
- "8\n",
- "Continue Y/N\n",
- "N\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Unformatted Output, Page number: 407<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "ch = 'A'\n",
- "\n",
- "#Result\n",
- "print ch #putch\n",
- "print ch #putchar\n",
- "print ch #fputchar\n",
- "print 'Z' #putch\n",
- "print 'Z' #putchar\n",
- "print 'Z' #fputchar\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "A\n",
- "A\n",
- "A\n",
- "Z\n",
- "Z\n",
- "Z\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Unformatted String Input/Output, Page number: 408<h3>\n"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Input from user\n",
- "#footballer = input(\"Enter name\" ) # puts(\"Enter name \") ; gets(footballer)\n",
- "print \"Enter name\"\n",
- "footballer = \"Jonty Rhodes\"\n",
- "print footballer\n",
- "\n",
- "#Result\n",
- "print \"Happy footballing!\" \n",
- "print footballer "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter name\n",
- "Jonty Rhodes\n",
- "Happy footballing!\n",
- "Jonty Rhodes\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:2f4d0660b7234129c8e49912c5b11a0b5ef4cb891c3d12ca4bfa31d6ee648bf9" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h1>Chapter 11: Console Input/Output<h1>" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Printf Example, Page number: 397<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "avg = 346 \n", + "per = 69.2\n", + "\n", + "#Result\n", + "print \"Average = %d\\nPercentage = %f\" %(avg, per )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average = 346\n", + "Percentage = 69.200000\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Format Specifications, Page number: 399<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "weight = 63\n", + "\n", + "#Result\n", + "print \"weight is %d kg\" %( weight ) \n", + "print \"weight is %2d kg\"%( weight ) \n", + "print \"weight is %4d kg\" %( weight )\n", + "print \"weight is %6d kg\" %(weight ) \n", + "print \"weight is %-6d kg\" %( weight )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "weight is 63 kg\n", + "weight is 63 kg\n", + "weight is 63 kg\n", + "weight is 63 kg\n", + "weight is 63 kg\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>String Format Specifiers, Page number: 400<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "firstname1 = \"Sandy\" \n", + "surname1 = \"Malya\" \n", + "firstname2 = \"AjayKumar\" \n", + "surname2 = \"Gurubaxani\" \n", + "\n", + "#Result\n", + "print \"%20s%20s\" %( firstname1, surname1 )\n", + "print \"%20s%20s\" %(firstname2, surname2 ) \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Sandy Malya\n", + " AjayKumar Gurubaxani\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Escape Sequences, Page number: 401<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"You\\tmust\\tbe\\tcrazy\\nto\\thate\\tthis\\tbook\" \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "You\tmust\tbe\tcrazy\n", + "to\thate\tthis\tbook\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Format Conversions, Page number: 403<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "ch = 'z' \n", + "i = 125 \n", + "a = 12.55 \n", + "s = \"hello there !\"\n", + "\n", + "#Result\n", + "print \"%c %d %f\" %( ch, ord(ch), ord(ch )) \n", + "print \"%s %d %f\"%( s, ord(s[1]), ord(s[1]) )\n", + "print \"%c %d %f\"%(i ,i, i ) \n", + "print \"%f %d\\n\"%( a, a )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "z 122 122.000000\n", + "hello there ! 101 101.000000\n", + "} 125 125.000000\n", + "12.550000 12\n", + "\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Sprintf Function, Page number: 404<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "i = 10 \n", + "ch = 'A'\n", + "a = 3.14 \n", + "\n", + "\n", + "#Result\n", + "print \"%d %c %f\" %(i, ch, a ) \n", + "str = \"%d %c %f\" %(i, ch, a ) #sprintf\n", + "print \"%s\" %(str )\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "10 A 3.140000\n", + "10 A 3.140000\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Unformatted Input, Page number: 406<h3>\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import msvcrt\n", + "\n", + "print \"Press any key to continue\" \n", + "#msvcrt.getch( ) # will not echo the character \n", + "print \"Type any character\" \n", + "#ch = msvcrt.getche( ) # will echo the character typed \n", + "ch = 'A'\n", + "print ch\n", + "#ch = input(\"Type any character\")#getchar( ) will echo character, must be followed by enter key \n", + "print \"Type any character\"\n", + "ch = 8\n", + "print ch\n", + "#ch = input( \"Continue Y/N\" ) #fgetchar( ) will echo character, must be followed by enter key\n", + "print \"Continue Y/N\" \n", + "ch = 'N'\n", + "print ch\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Press any key to continue\n", + "Type any character\n", + "A\n", + "Type any character\n", + "8\n", + "Continue Y/N\n", + "N\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Unformatted Output, Page number: 407<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "ch = 'A'\n", + "\n", + "#Result\n", + "print ch #putch\n", + "print ch #putchar\n", + "print ch #fputchar\n", + "print 'Z' #putch\n", + "print 'Z' #putchar\n", + "print 'Z' #fputchar\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "A\n", + "A\n", + "A\n", + "Z\n", + "Z\n", + "Z\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Unformatted String Input/Output, Page number: 408<h3>\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter name\"\n", + "footballer = \"Jonty Rhodes\"\n", + "print footballer\n", + "\n", + "#Result\n", + "print \"Happy footballing!\" \n", + "print footballer " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter name\n", + "Jonty Rhodes\n", + "Happy footballing!\n", + "Jonty Rhodes\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Let_us_C/chapter-15.ipynb b/Let_us_C/chapter-15.ipynb index 993f6a9b..087a08d0 100644 --- a/Let_us_C/chapter-15.ipynb +++ b/Let_us_C/chapter-15.ipynb @@ -1,602 +1,603 @@ -{
- "metadata": {
- "name": "chapter-15.ipynb"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h1>Chapter 15: Miscellaneous Features <h1>"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Enumerated Data Type , Page number: 508<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def enum(**enums):\n",
- " return type('Enum', (), enums)\n",
- "#Enum declaration\n",
- "emp_dept = enum(assembly = 0, manufacturing = 1,accounts = 2, stores = 3)\n",
- "\n",
- "from collections import namedtuple\n",
- "#Structure declaration\n",
- "struct_employee = namedtuple(\"struct_employee\", \"name age bs emp_dept\")\n",
- "\n",
- "\n",
- "#Structure for employee\n",
- "department = emp_dept.manufacturing\n",
- "e = struct_employee(\"Lothar Mattheus\",28,5575.50,department)\n",
- "\n",
- "#Result\n",
- "print \"Name = \",e.name\n",
- "print \"Age = \",e.age\n",
- "print \"Basic salary = \",e.bs\n",
- "print \"Dept = \",e.emp_dept\n",
- "\n",
- "if(e.emp_dept == 2):\n",
- " print \"%s is an accountant\" %(e.name)\n",
- "else:\n",
- " print \"%s is not an accountant\" %(e.name)\n",
- " \n",
- " \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Name = Lothar Mattheus\n",
- "Age = 28\n",
- "Basic salary = 5575.5\n",
- "Dept = 1\n",
- "Lothar Mattheus is not an accountant\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Are Enums Necessary, Page number: 510<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#macro definition\n",
- "ASSEMBLY = 0\n",
- "MANUFACTURING = 1\n",
- "ACCOUNTS = 2\n",
- "STORES = 3\n",
- "\n",
- "from collections import namedtuple\n",
- "#Structure declaration\n",
- "struct_employee = namedtuple(\"struct_employee\", \"name age bs department\")\n",
- "\n",
- "#Structure for employee\n",
- "e = struct_employee(\"Lothar Mattheus\",28,5575.50,MANUFACTURING)\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 2
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Division Without Typecasting , Page number: 513<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "x=6\n",
- "y=4\n",
- "\n",
- "#Calculation\n",
- "a = int( x/y) \n",
- "\n",
- "#Result\n",
- "print \"Value of a = %f\" %(a)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Value of a = 1.000000\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Division With Typecasting , Page number: 513<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "x=6\n",
- "y=4\n",
- "\n",
- "#Calculation\n",
- "a = float( x)/y\n",
- "\n",
- "#Result\n",
- "print \"Value of a = %f\" %(a)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Value of a = 1.500000\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Type Casting , Page number: 514<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "a=6.35\n",
- "\n",
- "#Result\n",
- "print \"Value of a on typecasting = %d\" %(int(a))\n",
- "print \"Value of a = %f\"%(a)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Value of a on typecasting = 6\n",
- "Value of a = 6.350000\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Bit Fields , Page number: 516<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from ctypes import *\n",
- "import ctypes\n",
- "import math\n",
- "\n",
- "#macro definition\n",
- "MALE = 0\n",
- "FEMALE = 1\n",
- "SINGLE = 0\n",
- "MARRIED = 1\n",
- "DIVORCED = 2\n",
- "WIDOWED = 3\n",
- "\n",
- "#Structure declaration\n",
- "class employee(Structure):\n",
- " _fields_ = [(\"gender\", c_int, 1),(\"mar_stat\", c_int, 3),(\"hobby\", c_int, 3),(\"scheme\", c_int, 4)]\n",
- " _sizeof_ = 2\n",
- "#Structure for employee\n",
- "e = employee()\n",
- "e.gender = MALE\n",
- "e.mar_stat = DIVORCED\n",
- "e.hobby = 5\n",
- "e.scheme =9\n",
- "\n",
- "#Result\n",
- "print \"Gender = \",e.gender\n",
- "print \"Marital status = \",e.mar_stat\n",
- "print \"Bytes occupied by e = \",sizeof(e)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Gender = 0\n",
- "Marital status = 2\n",
- "Bytes occupied by e = 4\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Address of a Function , Page number: 517<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Function definition\n",
- "def display():\n",
- " print \"Long live viruses!!\"\n",
- "\n",
- "#Result\n",
- "print \"Address of function display is \",id(display)\n",
- "display() #function call\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Address of function display is 133993192\n",
- "Long live viruses!!\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Invoking a Function Using Pointer, Page number: 518<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Function definition\n",
- "def display():\n",
- " print \"Long live viruses!!\"\n",
- "\n",
- "func_ptr = id(display) #assigning address of function\n",
- "print \"Address of function display is \",func_ptr\n",
- "display() #function call\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Address of function display is 133993080\n",
- "Long live viruses!!\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Functions Returning Pointers , Page number: 520<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Function definition\n",
- "def fun():\n",
- " i = 20\n",
- " return (i)\n",
- "\n",
- "#Result\n",
- "p =fun() #function call\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 11
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>String Copy , Page number: 520<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Function definition\n",
- "def copy(t,s):\n",
- " i = 0\n",
- " while ( s[i] != '\\0' ):\n",
- " t = t + s[i]\n",
- " i = i + 1\n",
- " return t\n",
- "\n",
- "#Variable declaration\n",
- "source = \"Jaded\\0\" \n",
- "target = ''\n",
- "string = copy( target, source ) # function call\n",
- "\n",
- "#Result\n",
- "print string\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Jaded\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Findmax Function , Page number: 522<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "to find out max value from a set of values\n",
- "\n",
- "#function declaration\n",
- "def findmax(*arg):\n",
- " maxi = arg[1]\n",
- " for count in range(2,arg[0]):\n",
- " num = arg[count]\n",
- " if (num > maxi):\n",
- " maxi = num\n",
- " return maxi\n",
- "\n",
- "maxi = findmax(5,23,15,1,92,50)#function call \n",
- "print \"maximum = \",maxi\n",
- "\n",
- "maxi = findmax(3,100,300,29)#function call \n",
- "print \"maximum = \",maxi\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "maximum = 92\n",
- "maximum = 300\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Display Function, Page number: 524<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#function declaration\n",
- "def display(*arg):\n",
- " if(arg[0] == 1): #case int\n",
- " for j in range(2,arg[1]+2):\n",
- " i = arg[j]\n",
- " print \"%d\"%(i)\n",
- " elif(arg[0] == 2): #case char\n",
- " for j in range(2,arg[1]+2):\n",
- " i = arg[j]\n",
- " print \"%c\"%(i)\n",
- " elif(arg[0] == 3): #case double\n",
- " for j in range(2,arg[1]+2):\n",
- " i = arg[j]\n",
- " print \"%lf\"%(i)\n",
- " \n",
- "#function calls\n",
- "display(1,2,5,6)\n",
- "display(2,4,'A','a','b','c')\n",
- "display(3,3,2.5,299.3,-1.0)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n",
- "6\n",
- "A\n",
- "a\n",
- "b\n",
- "c\n",
- "2.500000\n",
- "299.300000\n",
- "-1.000000\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Union Demo , Page number: 526<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from ctypes import *\n",
- "\n",
- "#union declaration\n",
- "class union_a(Union):\n",
- " _fields_ = [(\"i\", c_int),\n",
- " (\"ch\", ((c_char * 1)*2))]\n",
- "\n",
- "key = union_a()\n",
- "key.i = 512\n",
- "print \"key.i = \",key.i\n",
- "print \"key.ch[0] = \",(key.ch[0][0])\n",
- "print \"key.ch[1] = \",(key.ch[1][0])\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": []
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Union Example , Page number: 530<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from ctypes import *\n",
- "\n",
- "#Union declaration\n",
- "class union_a(Union):\n",
- " _fields_ = [(\"i\", c_int),\n",
- " (\"ch\", ((c_char * 1)*2))]\n",
- "\n",
- "key = union_a()\n",
- "key.i = 512\n",
- "print \"key.i = \",key.i\n",
- "print \"key.ch[0] = \",(key.ch[0][0])\n",
- "print \"key.ch[1] = \",(key.ch[1][0])\n",
- "\n",
- "key.ch[0][0] = 50 #assign new value to key.ch[0]\n",
- "print\"key.i = \",key.i\n",
- "print\"key.ch[0] = \",(key.ch[0][0])\n",
- "print\"key.ch[1] = \",(key.ch[1][0])\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": []
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Union of Structures , Page number: 531<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from ctypes import *\n",
- "\n",
- "#Structure declarations\n",
- "class a(Structure):\n",
- " _fields_ = [(\"i\", c_int),\n",
- " (\"c\", ((c_char * 1)*2))]\n",
- "\n",
- "class b(Structure):\n",
- " _fields_ = [(\"j\", c_int),\n",
- " (\"d\", ((c_char * 1)*2))]\n",
- " \n",
- "#Union declaration\n",
- "class union_z(Union):\n",
- " _fields_ = [(\"key\", a),\n",
- " (\"data\", b )]\n",
- "\n",
- "strange = union_z()\n",
- "strange.key.i = 512\n",
- "strange.data.d[0][0] = 0\n",
- "strange.data.d[1][0] = 32\n",
- "\n",
- "print strange.key.i\n",
- "print strange.data.j\n",
- "print strange.key.c[0][0]\n",
- "print strange.data.d[0][0]\n",
- "print strange.key.c[1][0]\n",
- "print strange.data.d[1][0]\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:d98d61d8802af6f3fda8e30c6e47e6355ba4d55d204c760c90ae2fa05295236c" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h1>Chapter 15: Miscellaneous Features <h1>" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Enumerated Data Type , Page number: 508<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "def enum(**enums):\n", + " return type('Enum', (), enums)\n", + "#Enum declaration\n", + "emp_dept = enum(assembly = 0, manufacturing = 1,accounts = 2, stores = 3)\n", + "\n", + "from collections import namedtuple\n", + "#Structure declaration\n", + "struct_employee = namedtuple(\"struct_employee\", \"name age bs emp_dept\")\n", + "\n", + "\n", + "#Structure for employee\n", + "department = emp_dept.manufacturing\n", + "e = struct_employee(\"Lothar Mattheus\",28,5575.50,department)\n", + "\n", + "#Result\n", + "print \"Name = \",e.name\n", + "print \"Age = \",e.age\n", + "print \"Basic salary = \",e.bs\n", + "print \"Dept = \",e.emp_dept\n", + "\n", + "if(e.emp_dept == 2):\n", + " print \"%s is an accountant\" %(e.name)\n", + "else:\n", + " print \"%s is not an accountant\" %(e.name)\n", + " \n", + " \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name = Lothar Mattheus\n", + "Age = 28\n", + "Basic salary = 5575.5\n", + "Dept = 1\n", + "Lothar Mattheus is not an accountant\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Are Enums Necessary, Page number: 510<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#macro definition\n", + "ASSEMBLY = 0\n", + "MANUFACTURING = 1\n", + "ACCOUNTS = 2\n", + "STORES = 3\n", + "\n", + "from collections import namedtuple\n", + "#Structure declaration\n", + "struct_employee = namedtuple(\"struct_employee\", \"name age bs department\")\n", + "\n", + "#Structure for employee\n", + "e = struct_employee(\"Lothar Mattheus\",28,5575.50,MANUFACTURING)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Division Without Typecasting , Page number: 513<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "x=6\n", + "y=4\n", + "\n", + "#Calculation\n", + "a = int( x/y) \n", + "\n", + "#Result\n", + "print \"Value of a = %f\" %(a)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of a = 1.000000\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Division With Typecasting , Page number: 513<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "x=6\n", + "y=4\n", + "\n", + "#Calculation\n", + "a = float( x)/y\n", + "\n", + "#Result\n", + "print \"Value of a = %f\" %(a)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of a = 1.500000\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Type Casting , Page number: 514<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "a=6.35\n", + "\n", + "#Result\n", + "print \"Value of a on typecasting = %d\" %(int(a))\n", + "print \"Value of a = %f\"%(a)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of a on typecasting = 6\n", + "Value of a = 6.350000\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Bit Fields , Page number: 516<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from ctypes import *\n", + "import ctypes\n", + "import math\n", + "\n", + "#macro definition\n", + "MALE = 0\n", + "FEMALE = 1\n", + "SINGLE = 0\n", + "MARRIED = 1\n", + "DIVORCED = 2\n", + "WIDOWED = 3\n", + "\n", + "#Structure declaration\n", + "class employee(Structure):\n", + " _fields_ = [(\"gender\", c_int, 1),(\"mar_stat\", c_int, 3),(\"hobby\", c_int, 3),(\"scheme\", c_int, 4)]\n", + " _sizeof_ = 2\n", + "#Structure for employee\n", + "e = employee()\n", + "e.gender = MALE\n", + "e.mar_stat = DIVORCED\n", + "e.hobby = 5\n", + "e.scheme =9\n", + "\n", + "#Result\n", + "print \"Gender = \",e.gender\n", + "print \"Marital status = \",e.mar_stat\n", + "print \"Bytes occupied by e = \",sizeof(e)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Gender = 0\n", + "Marital status = 2\n", + "Bytes occupied by e = 4\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Address of a Function , Page number: 517<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Function definition\n", + "def display():\n", + " print \"Long live viruses!!\"\n", + "\n", + "#Result\n", + "print \"Address of function display is \",id(display)\n", + "display() #function call\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Address of function display is 133993192\n", + "Long live viruses!!\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Invoking a Function Using Pointer, Page number: 518<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Function definition\n", + "def display():\n", + " print \"Long live viruses!!\"\n", + "\n", + "func_ptr = id(display) #assigning address of function\n", + "print \"Address of function display is \",func_ptr\n", + "display() #function call\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Address of function display is 133993080\n", + "Long live viruses!!\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Functions Returning Pointers , Page number: 520<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Function definition\n", + "def fun():\n", + " i = 20\n", + " return (i)\n", + "\n", + "#Result\n", + "p =fun() #function call\n" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>String Copy , Page number: 520<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Function definition\n", + "def copy(t,s):\n", + " i = 0\n", + " while ( s[i] != '\\0' ):\n", + " t = t + s[i]\n", + " i = i + 1\n", + " return t\n", + "\n", + "#Variable declaration\n", + "source = \"Jaded\\0\" \n", + "target = ''\n", + "string = copy( target, source ) # function call\n", + "\n", + "#Result\n", + "print string\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Jaded\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Findmax Function , Page number: 522<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#function declaration\n", + "def findmax(*arg):\n", + " maxi = arg[1]\n", + " for count in range(2,arg[0]):\n", + " num = arg[count]\n", + " if (num > maxi):\n", + " maxi = num\n", + " return maxi\n", + "\n", + "maxi = findmax(5,23,15,1,92,50)#function call \n", + "print \"maximum = \",maxi\n", + "\n", + "maxi = findmax(3,100,300,29)#function call \n", + "print \"maximum = \",maxi\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "maximum = 92\n", + "maximum = 300\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Display Function, Page number: 524<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#function declaration\n", + "def display(*arg):\n", + " if(arg[0] == 1): #case int\n", + " for j in range(2,arg[1]+2):\n", + " i = arg[j]\n", + " print \"%d\"%(i)\n", + " elif(arg[0] == 2): #case char\n", + " for j in range(2,arg[1]+2):\n", + " i = arg[j]\n", + " print \"%c\"%(i)\n", + " elif(arg[0] == 3): #case double\n", + " for j in range(2,arg[1]+2):\n", + " i = arg[j]\n", + " print \"%lf\"%(i)\n", + " \n", + "#function calls\n", + "display(1,2,5,6)\n", + "display(2,4,'A','a','b','c')\n", + "display(3,3,2.5,299.3,-1.0)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n", + "6\n", + "A\n", + "a\n", + "b\n", + "c\n", + "2.500000\n", + "299.300000\n", + "-1.000000\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Union Demo , Page number: 526<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from ctypes import *\n", + "\n", + "#union declaration\n", + "class union_a(Union):\n", + " _fields_ = [(\"i\", c_int),\n", + " (\"ch\", ((c_char * 1)*2))]\n", + "\n", + "key = union_a()\n", + "key.i = 512\n", + "print \"key.i = \",key.i\n", + "print \"key.ch[0] = \",(key.ch[0][0])\n", + "print \"key.ch[1] = \",(key.ch[1][0])\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Union Example , Page number: 530<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from ctypes import *\n", + "\n", + "#Union declaration\n", + "class union_a(Union):\n", + " _fields_ = [(\"i\", c_int),\n", + " (\"ch\", ((c_char * 1)*2))]\n", + "\n", + "key = union_a()\n", + "key.i = 512\n", + "print \"key.i = \",key.i\n", + "print \"key.ch[0] = \",(key.ch[0][0])\n", + "print \"key.ch[1] = \",(key.ch[1][0])\n", + "\n", + "key.ch[0][0] = 50 #assign new value to key.ch[0]\n", + "print\"key.i = \",key.i\n", + "print\"key.ch[0] = \",(key.ch[0][0])\n", + "print\"key.ch[1] = \",(key.ch[1][0])\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Union of Structures , Page number: 531<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from ctypes import *\n", + "\n", + "#Structure declarations\n", + "class a(Structure):\n", + " _fields_ = [(\"i\", c_int),\n", + " (\"c\", ((c_char * 1)*2))]\n", + "\n", + "class b(Structure):\n", + " _fields_ = [(\"j\", c_int),\n", + " (\"d\", ((c_char * 1)*2))]\n", + " \n", + "#Union declaration\n", + "class union_z(Union):\n", + " _fields_ = [(\"key\", a),\n", + " (\"data\", b )]\n", + "\n", + "strange = union_z()\n", + "strange.key.i = 512\n", + "strange.data.d[0][0] = 0\n", + "strange.data.d[1][0] = 32\n", + "\n", + "print strange.key.i\n", + "print strange.data.j\n", + "print strange.key.c[0][0]\n", + "print strange.data.d[0][0]\n", + "print strange.key.c[1][0]\n", + "print strange.data.d[1][0]\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Let_us_C/chapter-2.ipynb b/Let_us_C/chapter-2.ipynb index e2379edc..b7409b44 100644 --- a/Let_us_C/chapter-2.ipynb +++ b/Let_us_C/chapter-2.ipynb @@ -1,554 +1,523 @@ -{
- "metadata": {
- "name": "chapter-2.ipynb"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h1>Chapter 2: The Decision Control Structure <h1>"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>If Demo , Page number: 52<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#taking in input from the user\n",
- "#num = raw_input(\"Enter a number less than 10: \")\n",
- "print \"Enter a number less than 10: \"\n",
- "num = 8\n",
- "print num\n",
- "\n",
- "#if statement\n",
- "if num <= 10:\n",
- " print(\"What an obedient servant you are !\") #display result\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a number less than 10: \n",
- "8\n",
- "What an obedient servant you are !\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Example 2.1 , Page number: 53<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "dis = 0 #Initial Discount (%0)\n",
- "\n",
- "#Input from the user\n",
- "#qty,rate = raw_input(\"Enter quantity and rate: \").split()\n",
- "print \"Enter quantity and rate: \"\n",
- "qty = 1200 # Quantity of item\n",
- "rate = 15.50 # Rate of item (Rs)\n",
- "print qty , rate\n",
- "\n",
- "#discount of 10% if quantity > 1000\n",
- "if qty > 1000:\n",
- " dis = 10\n",
- "\n",
- "#Calculation\n",
- "tot = (qty * rate) - (qty * rate * dis / 100 ) # total expenses (Rs)\n",
- "\n",
- "#Result\n",
- "print \"Total expenses = Rs. \", tot \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter quantity and rate: \n",
- "1200 15.5\n",
- "Total expenses = Rs. 16740.0\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Example 2.2, Page number: 57<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "If the number of years for which the employee has served the organization is greater than 3 then a bonus of Rs. 2500/- is given to the employee.\n",
- "\n",
- "#input from user\n",
- "#cy,yoj = raw_input(\"Enter current year and year of joining: \").split() \n",
- "print \"Enter current year and year of joining: \"\n",
- "cy = 2013 # Current year\n",
- "yoj = 1990 # Year of joining\n",
- "print cy, yoj \n",
- "#Calculation\n",
- "yr_of_ser = cy - yoj # number of years of service\n",
- "\n",
- "#Assign bonus if years of service > 3\n",
- "if yr_of_ser > 3:\n",
- " bonus = 2500 # Bonus of Rs. 2500\n",
- " print \"Bonus = Rs.\", bonus #display result\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter current year and year of joining: \n",
- "2013 1990\n",
- "Bonus = Rs. 2500\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Example 2.3 , Page number: 58<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary and\n",
- "DA = 90% of basic salary. If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary.\n",
- "\n",
- "#input from user\n",
- "#bs = raw_input(\"Enter basic salary: \")\n",
- "print \"Enter basic salary: \"\n",
- "bs = 2561.1 #Basic salary (Rs)\n",
- "print bs\n",
- "\n",
- "#Calculation\n",
- "if bs < 1500: # if basic salary is less than Rs.1500\n",
- " hra = bs * 10 / 100 # HRA (Rs)\n",
- " da = bs * 90 / 100 #DA (Rs)\n",
- "else: #if basic salary is greater than or equal to Rs.1500\n",
- " hra = 500 # HRA (Rs)\n",
- " da = bs * 98 / 100 # DA (Rs)\n",
- "\n",
- "gs = bs + hra + da # gross salary (Rs)\n",
- "\n",
- "#Result\n",
- "print \"gross salary = Rs. \", gs \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter basic salary: \n",
- "2561.1\n",
- "gross salary = Rs. 5570.978\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Nested If-else , Page number: 61<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#input from user\n",
- "#i = raw_input(\"Enter either 1 or 2: \")\n",
- "print \"Enter either 1 or 2: \"\n",
- "i = 1\n",
- "print i\n",
- "\n",
- "#nested if-else\n",
- "if i == 1 :\n",
- " print \"You would go to heaven !\" \n",
- "else:\n",
- " if i == 2 :\n",
- " print \"Hell was created with you in mind\" \n",
- " else:\n",
- " print \"How about mother earth !\" "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter either 1 or 2: \n",
- "1\n",
- "You would go to heaven !\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Example 2.4 (Method 1), Page number: 64<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "Percentage above or equal to 60 - First division\n",
- "Percentage between 50 and 59 - Second division\n",
- "Percentage between 40 and 49 - Third division\n",
- "Percentage less than 40 - Fail\n",
- "Write a program to calculate the division obtained by the student.\n",
- "\n",
- "#input from user\n",
- "#m1,m2,m3,m4,m5 = raw_input(\"Enter marks in five subjects: \").split() \n",
- "print \"Enter marks in five subjects: \"\n",
- "m1 = 88 #Marks in 1st subject\n",
- "m2 = 92 #Marks in 2nd subject\n",
- "m3 = 87 #Marks in 3rd subject\n",
- "m4 = 66 #Marks in 4th subject\n",
- "m5 = 56 #Marks in 5th subject\n",
- "print m1,m2,m3,m4,m5\n",
- "\n",
- "#Calculation\n",
- "per = ( m1 + m2 + m3 + m4 + m5 ) / 5 #Percentage\n",
- "\n",
- "#check for different cases and display appropriate result\n",
- "if per >= 60:\n",
- " print \"First division\"\n",
- "else:\n",
- " if per >= 50:\n",
- " print \"Second division\"\n",
- " else:\n",
- " if per >= 40:\n",
- " print \"Third division\"\n",
- " else:\n",
- " print \"Fail\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Enter marks in five subjects: \n",
- "88 92 87 66 56\n",
- "First division\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Example 2.4 (Method 2), Page number: 65<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#input from user\n",
- "#m1,m2,m3,m4,m5 = raw_input(\"Enter marks in five subjects: \").split() \n",
- "print \"Enter marks in five subjects: \"\n",
- "m1 = 88 #Marks in 1st subject\n",
- "m2 = 92 #Marks in 2nd subject\n",
- "m3 = 87 #Marks in 3rd subject\n",
- "m4 = 66 #Marks in 4th subject\n",
- "m5 = 56 #Marks in 5th subject\n",
- "print m1,m2,m3,m4,m5\n",
- "\n",
- "#Calculation\n",
- "per = ( m1 + m2 + m3 + m4 + m5 ) / 5 #Percentage\n",
- "\n",
- "#check for different cases and display appropriate result\n",
- "if per >= 60:\n",
- " print \"First division\"\n",
- "\n",
- "if (per >= 50) and (per <60):\n",
- " print\"Second division\"\n",
- "\n",
- "if (per >= 40) and (per <50):\n",
- " print\"Third division\"\n",
- "\n",
- "if per < 40 :\n",
- " print\"Fail\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter marks in five subjects: \n",
- "88 92 87 66 56\n",
- "First division\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Example 2.4 (Method 3), Page number: 67<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#input from user\n",
- "#m1,m2,m3,m4,m5 = raw_input(\"Enter marks in five subjects: \").split() \n",
- "print \"Enter marks in five subjects: \"\n",
- "m1 = 88 #Marks in 1st subject\n",
- "m2 = 92 #Marks in 2nd subject\n",
- "m3 = 87 #Marks in 3rd subject\n",
- "m4 = 66 #Marks in 4th subject\n",
- "m5 = 56 #Marks in 5th subject\n",
- "print m1,m2,m3,m4,m5\n",
- "\n",
- "#Calculation\n",
- "per = ( m1 + m2 + m3 + m4 + m5 ) / 5 #Percentage\n",
- "\n",
- "#check for different cases and display appropriate result\n",
- "if per >= 60:\n",
- " print\"First division\"\n",
- "elif per >= 50:\n",
- " print\"Second division\"\n",
- "elif per >= 40:\n",
- " print\"Third division\"\n",
- "else:\n",
- " print\"Fail\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter marks in five subjects: \n",
- "88 92 87 66 56\n",
- "First division\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Example 2.5 (Method 1) , Page number: 68<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\u2212 If the driver is married.\n",
- "\u2212 If the driver is unmarried, male & above 30 years of age.\n",
- "\u2212 If the driver is unmarried, female & above 25 years of age.\n",
- "In all other cases the driver is not insured.\n",
- "\n",
- "#input from user\n",
- "#age,sex,ms = raw_input(\"Enter age, sex, marital status: \").split() # Age , sex and marital status of the driver\n",
- "print \"Enter age, sex, marital status: \"\n",
- "age = 43 # Age of driver (years)\n",
- "sex = 'M'\n",
- "ms = 'M'\n",
- "print age,sex,ms\n",
- "#check for different cases and display appropriate result\n",
- "if ms == 'M':\n",
- " print(\"Driver is insured\")\n",
- "else:\n",
- " if sex == 'M':\n",
- " if age > 30:\n",
- " print (\"Driver is insured\")\n",
- " else:\n",
- " print (\"Driver is not insured\")\n",
- " else:\n",
- " if age > 25:\n",
- " print (\"Driver is insured\")\n",
- " else:\n",
- " print (\"Driver is not insured\")\n",
- " \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter age, sex, marital status: \n",
- "43 M M\n",
- "Driver is insured\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Example 2.5 (Method 2) , Page number: 69<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#input from user\n",
- "#age,sex,ms = raw_input(\"Enter age, sex, marital status: \").split() # Age , sex and marital status of the driver\n",
- "print \"Enter age, sex, marital status: \"\n",
- "age = 43 # Age of driver (years)\n",
- "sex = 'M'\n",
- "ms = 'M'\n",
- "print age,sex,ms\n",
- "\n",
- "#check for different cases and display appropriate result\n",
- "if ((ms == 'M') or (ms == 'U' and sex == 'M' and age > 30) or (ms == 'U' and sex == 'F' and age >25) ) :\n",
- " print\"Driver is insured\"\n",
- "else:\n",
- " print\"Driver is not insured\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter age, sex, marital status: \n",
- "43 M M\n",
- "Driver is insured\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Example 2.6, Page number: 71<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Input gender( m/f), years of service and qualification from the user\n",
- "#g,yos,qual = raw_input(\"Enter Gender, Years of Service and Qualifications ( 0 = G, 1 = PG ):\").split()\n",
- "print \"Enter Gender, Years of Service and Qualifications ( 0 = G, 1 = PG ):\"\n",
- "g = 'f'\n",
- "yos = 8 # Years of service(years)\n",
- "qual = 1 # Qualification ( 0=G, 1=PG)\n",
- "print g,yos,qual\n",
- "\n",
- "# Assign salary depending upon the conditions\n",
- "if (g == 'm') and (yos >= 10) and (qual == 1):\n",
- " sal = 15000 #salary\n",
- "elif ((g == 'm' and yos >= 10 and qual == 0) or ( g == 'm' and yos < 10 and qual == 1 )):\n",
- " sal = 10000 #salary\n",
- "elif ( g == 'm' and yos < 10 and qual == 0 ):\n",
- " sal = 7000 #salary\n",
- "elif ( g == 'f' and yos >= 10 and qual == 1 ):\n",
- " sal = 12000 #salary\n",
- "elif ( g == 'f' and yos >= 10 and qual == 0 ):\n",
- " sal = 9000 #salary\n",
- "elif ( g == 'f' and yos < 10 and qual == 1 ):\n",
- " sal = 10000 #salary\n",
- "elif ( g == 'f' and yos < 10 and qual == 0 ):\n",
- " sal = 6000 #salary\n",
- "\n",
- "#Result\n",
- "print \"Salary of Employee = \", sal "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter Gender, Years of Service and Qualifications ( 0 = G, 1 = PG ):\n",
- "f 8 1\n",
- "Salary of Employee = 10000\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:2995e92c707106426a9edd38d59fc05e81394353c5d1739975459edb98accea9" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h1>Chapter 2: The Decision Control Structure <h1>" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>If Demo , Page number: 52<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter a number less than 10: \"\n", + "num = 8\n", + "print num\n", + "\n", + "#if statement\n", + "if num <= 10:\n", + " print(\"What an obedient servant you are !\") #display result\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a number less than 10: \n", + "8\n", + "What an obedient servant you are !\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Example 2.1 , Page number: 53<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "dis = 0 #Initial Discount (%0)\n", + "\n", + "#Input from the user\n", + "#qty,rate = raw_input(\"Enter quantity and rate: \").split()\n", + "print \"Enter quantity and rate: \"\n", + "qty = 1200 # Quantity of item\n", + "rate = 15.50 # Rate of item (Rs)\n", + "print qty , rate\n", + "\n", + "#discount of 10% if quantity > 1000\n", + "if qty > 1000:\n", + " dis = 10\n", + "\n", + "#Calculation\n", + "tot = (qty * rate) - (qty * rate * dis / 100 ) # total expenses (Rs)\n", + "\n", + "#Result\n", + "print \"Total expenses = Rs. \", tot \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter quantity and rate: \n", + "1200 15.5\n", + "Total expenses = Rs. 16740.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Example 2.2, Page number: 57<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#cy,yoj = raw_input(\"Enter current year and year of joining: \").split() \n", + "print \"Enter current year and year of joining: \"\n", + "cy = 2013 # Current year\n", + "yoj = 1990 # Year of joining\n", + "print cy, yoj \n", + "#Calculation\n", + "yr_of_ser = cy - yoj # number of years of service\n", + "\n", + "#Assign bonus if years of service > 3\n", + "if yr_of_ser > 3:\n", + " bonus = 2500 # Bonus of Rs. 2500\n", + " print \"Bonus = Rs.\", bonus #display result\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter current year and year of joining: \n", + "2013 1990\n", + "Bonus = Rs. 2500\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Example 2.3 , Page number: 58<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter basic salary: \"\n", + "bs = 2561.1 #Basic salary (Rs)\n", + "print bs\n", + "\n", + "#Calculation\n", + "if bs < 1500: # if basic salary is less than Rs.1500\n", + " hra = bs * 10 / 100 # HRA (Rs)\n", + " da = bs * 90 / 100 #DA (Rs)\n", + "else: #if basic salary is greater than or equal to Rs.1500\n", + " hra = 500 # HRA (Rs)\n", + " da = bs * 98 / 100 # DA (Rs)\n", + "\n", + "gs = bs + hra + da # gross salary (Rs)\n", + "\n", + "#Result\n", + "print \"gross salary = Rs. \", gs \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter basic salary: \n", + "2561.1\n", + "gross salary = Rs. 5570.978\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Nested If-else , Page number: 61<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter either 1 or 2: \"\n", + "i = 1\n", + "print i\n", + "\n", + "#nested if-else\n", + "if i == 1 :\n", + " print \"You would go to heaven !\" \n", + "else:\n", + " if i == 2 :\n", + " print \"Hell was created with you in mind\" \n", + " else:\n", + " print \"How about mother earth !\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter either 1 or 2: \n", + "1\n", + "You would go to heaven !\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Example 2.4 (Method 1), Page number: 64<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter marks in five subjects: \"\n", + "m1 = 88 #Marks in 1st subject\n", + "m2 = 92 #Marks in 2nd subject\n", + "m3 = 87 #Marks in 3rd subject\n", + "m4 = 66 #Marks in 4th subject\n", + "m5 = 56 #Marks in 5th subject\n", + "print m1,m2,m3,m4,m5\n", + "\n", + "#Calculation\n", + "per = ( m1 + m2 + m3 + m4 + m5 ) / 5 #Percentage\n", + "\n", + "#check for different cases and display appropriate result\n", + "if per >= 60:\n", + " print \"First division\"\n", + "else:\n", + " if per >= 50:\n", + " print \"Second division\"\n", + " else:\n", + " if per >= 40:\n", + " print \"Third division\"\n", + " else:\n", + " print \"Fail\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Enter marks in five subjects: \n", + "88 92 87 66 56\n", + "First division\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Example 2.4 (Method 2), Page number: 65<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter marks in five subjects: \"\n", + "m1 = 88 #Marks in 1st subject\n", + "m2 = 92 #Marks in 2nd subject\n", + "m3 = 87 #Marks in 3rd subject\n", + "m4 = 66 #Marks in 4th subject\n", + "m5 = 56 #Marks in 5th subject\n", + "print m1,m2,m3,m4,m5\n", + "\n", + "#Calculation\n", + "per = ( m1 + m2 + m3 + m4 + m5 ) / 5 #Percentage\n", + "\n", + "#check for different cases and display appropriate result\n", + "if per >= 60:\n", + " print \"First division\"\n", + "\n", + "if (per >= 50) and (per <60):\n", + " print\"Second division\"\n", + "\n", + "if (per >= 40) and (per <50):\n", + " print\"Third division\"\n", + "\n", + "if per < 40 :\n", + " print\"Fail\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter marks in five subjects: \n", + "88 92 87 66 56\n", + "First division\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Example 2.4 (Method 3), Page number: 67<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter marks in five subjects: \"\n", + "m1 = 88 #Marks in 1st subject\n", + "m2 = 92 #Marks in 2nd subject\n", + "m3 = 87 #Marks in 3rd subject\n", + "m4 = 66 #Marks in 4th subject\n", + "m5 = 56 #Marks in 5th subject\n", + "print m1,m2,m3,m4,m5\n", + "\n", + "#Calculation\n", + "per = ( m1 + m2 + m3 + m4 + m5 ) / 5 #Percentage\n", + "\n", + "#check for different cases and display appropriate result\n", + "if per >= 60:\n", + " print\"First division\"\n", + "elif per >= 50:\n", + " print\"Second division\"\n", + "elif per >= 40:\n", + " print\"Third division\"\n", + "else:\n", + " print\"Fail\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter marks in five subjects: \n", + "88 92 87 66 56\n", + "First division\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Example 2.5 (Method 1) , Page number: 68<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter age, sex, marital status: \"\n", + "age = 43 # Age of driver (years)\n", + "sex = 'M'\n", + "ms = 'M'\n", + "print age,sex,ms\n", + "#check for different cases and display appropriate result\n", + "if ms == 'M':\n", + " print(\"Driver is insured\")\n", + "else:\n", + " if sex == 'M':\n", + " if age > 30:\n", + " print (\"Driver is insured\")\n", + " else:\n", + " print (\"Driver is not insured\")\n", + " else:\n", + " if age > 25:\n", + " print (\"Driver is insured\")\n", + " else:\n", + " print (\"Driver is not insured\")\n", + " \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter age, sex, marital status: \n", + "43 M M\n", + "Driver is insured\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Example 2.5 (Method 2) , Page number: 69<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter age, sex, marital status: \"\n", + "age = 43 # Age of driver (years)\n", + "sex = 'M'\n", + "ms = 'M'\n", + "print age,sex,ms\n", + "\n", + "#check for different cases and display appropriate result\n", + "if ((ms == 'M') or (ms == 'U' and sex == 'M' and age > 30) or (ms == 'U' and sex == 'F' and age >25) ) :\n", + " print\"Driver is insured\"\n", + "else:\n", + " print\"Driver is not insured\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter age, sex, marital status: \n", + "43 M M\n", + "Driver is insured\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Example 2.6, Page number: 71<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter Gender, Years of Service and Qualifications ( 0 = G, 1 = PG ):\"\n", + "g = 'f'\n", + "yos = 8 # Years of service(years)\n", + "qual = 1 # Qualification ( 0=G, 1=PG)\n", + "print g,yos,qual\n", + "\n", + "# Assign salary depending upon the conditions\n", + "if (g == 'm') and (yos >= 10) and (qual == 1):\n", + " sal = 15000 #salary\n", + "elif ((g == 'm' and yos >= 10 and qual == 0) or ( g == 'm' and yos < 10 and qual == 1 )):\n", + " sal = 10000 #salary\n", + "elif ( g == 'm' and yos < 10 and qual == 0 ):\n", + " sal = 7000 #salary\n", + "elif ( g == 'f' and yos >= 10 and qual == 1 ):\n", + " sal = 12000 #salary\n", + "elif ( g == 'f' and yos >= 10 and qual == 0 ):\n", + " sal = 9000 #salary\n", + "elif ( g == 'f' and yos < 10 and qual == 1 ):\n", + " sal = 10000 #salary\n", + "elif ( g == 'f' and yos < 10 and qual == 0 ):\n", + " sal = 6000 #salary\n", + "\n", + "#Result\n", + "print \"Salary of Employee = \", sal " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Gender, Years of Service and Qualifications ( 0 = G, 1 = PG ):\n", + "f 8 1\n", + "Salary of Employee = 10000\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Let_us_C/chapter-4.ipynb b/Let_us_C/chapter-4.ipynb index 75a56ab9..fcd96271 100644 --- a/Let_us_C/chapter-4.ipynb +++ b/Let_us_C/chapter-4.ipynb @@ -1,349 +1,345 @@ -{
- "metadata": {
- "name": "chapter-4.ipynb"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h1>Chapter 4: The Case Control Structure<h1>"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Switch - Case, Page number: 137<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "i = 2\n",
- "\n",
- "#Switch case statements\n",
- "if i == 1: # case 1\n",
- " print \"I am in case 1\"\n",
- "else:\n",
- " print \"I am in case 2\"# case 2\n",
- " print \"I am in case 3\"#case 3\n",
- " print \"I am in default\"# default\n",
- " \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "I am in case 2\n",
- "I am in case 3\n",
- "I am in default\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Switch - Case, Page number: 138<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "i = 2\n",
- "\n",
- "#Switch case statements\n",
- "if i == 1: # case 1\n",
- " print \"I am in case 1\"\n",
- "elif i == 2: # case 2\n",
- " print \"I am in case 2\"\n",
- "elif i == 3: #case 3\n",
- " print \"I am in case 3\"\n",
- "else: # default\n",
- " print \"I am in default\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "I am in case 2\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>The Tips and Traps a), Page number: 140<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "i = 22\n",
- "\n",
- "#Switch case statements\n",
- "if i == 121: # case 121\n",
- " print \"I am in case 121\"\n",
- "elif i == 7: # case 7\n",
- " print \"I am in case 7\"\n",
- "elif i == 22: #case 22\n",
- " print \"I am in case 22\"\n",
- "else: # default\n",
- " print \"I am in default\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "I am in case 22\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>The Tips and Traps b), Page number: 140<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "c = 'x'\n",
- "\n",
- "#Switch case statements\n",
- "if c == 'v': # case 'v'\n",
- " print \"I am in case v\"\n",
- "elif c == 'a': # case 'a'\n",
- " print \"I am in case a\"\n",
- "elif c == 'x': #case 'x'\n",
- " print \"I am in case x\"\n",
- "else: # default\n",
- " print \"I am in default\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "I am in case x\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>The Tips and Traps c), Page number: 141<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Input from user\n",
- "#ch = raw_input(\"Enter any of the alphabet a, b, or c : \")\n",
- "ch = 'a'\n",
- "\n",
- "#Switch case statements\n",
- "if ch == 'a' or ch == 'A' : # case 'a' and case 'A'\n",
- " print \"a as in ashar\"\n",
- "elif ch == 'b'or ch == 'B': # case 'b' and case 'B'\n",
- " print \"b as in brain\"\n",
- "elif ch == 'c'or ch == 'C': # case 'c' and case 'C'\n",
- " print \"c as in cookie\"\n",
- "else: # default\n",
- " print (\"wish you knew what are alphabets\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a as in ashar\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>The Tips and Traps e) , Page number: 143<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "case or the other. If it doesn\u2019t,the compiler won\u2019t report an error.\n",
- "\n",
- "#Input from user\n",
- "#i = raw_input(\"Enter value of i \")\n",
- "i = 1\n",
- "\n",
- "#Switch case statements\n",
- "#print \"Hello\"\n",
- "if i == 1 : # case 1\n",
- " j = 10\n",
- "elif i == 2 :# case 2\n",
- " j = 20\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 3
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Goto , Page number: 146<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Input from user\n",
- "#goals = raw_input(\"Enter the number of goals scored against India: \")\n",
- "goals = 3\n",
- "\n",
- "if goals <= 5 : #goto\n",
- " print \"To err is human!\" #label sos\n",
- "else:\n",
- " print \"About time soccer players learnt C\" \n",
- " print \"and said goodbye! adieu! to soccer\" \n",
- " \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "To err is human!\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Goto , Page number: 148<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "when we want to take the control out of the loop that is contained in\n",
- "\n",
- "\n",
- "#nested for loops\n",
- "for i in range(1,4):\n",
- " for j in range(1,4):\n",
- " for k in range(1,4):\n",
- " if ( i == 3 and j == 3 and k == 3 ): #goto\n",
- " print \"Out of the loop at last!\" # label out\n",
- " break\n",
- " else:\n",
- " print i, j, k "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1 1 1\n",
- "1 1 2\n",
- "1 1 3\n",
- "1 2 1\n",
- "1 2 2\n",
- "1 2 3\n",
- "1 3 1\n",
- "1 3 2\n",
- "1 3 3\n",
- "2 1 1\n",
- "2 1 2\n",
- "2 1 3\n",
- "2 2 1\n",
- "2 2 2\n",
- "2 2 3\n",
- "2 3 1\n",
- "2 3 2\n",
- "2 3 3\n",
- "3 1 1\n",
- "3 1 2\n",
- "3 1 3\n",
- "3 2 1\n",
- "3 2 2\n",
- "3 2 3\n",
- "3 3 1\n",
- "3 3 2\n",
- "Out of the loop at last!\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:7c22324d39011030a3b150073070e5711999d5a4173c27c085bd0e0ed1d76d18" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h1>Chapter 4: The Case Control Structure<h1>" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Switch - Case, Page number: 137<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "i = 2\n", + "\n", + "#Switch case statements\n", + "if i == 1: # case 1\n", + " print \"I am in case 1\"\n", + "else:\n", + " print \"I am in case 2\"# case 2\n", + " print \"I am in case 3\"#case 3\n", + " print \"I am in default\"# default\n", + " \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "I am in case 2\n", + "I am in case 3\n", + "I am in default\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Switch - Case, Page number: 138<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "i = 2\n", + "\n", + "#Switch case statements\n", + "if i == 1: # case 1\n", + " print \"I am in case 1\"\n", + "elif i == 2: # case 2\n", + " print \"I am in case 2\"\n", + "elif i == 3: #case 3\n", + " print \"I am in case 3\"\n", + "else: # default\n", + " print \"I am in default\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "I am in case 2\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>The Tips and Traps a), Page number: 140<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "i = 22\n", + "\n", + "#Switch case statements\n", + "if i == 121: # case 121\n", + " print \"I am in case 121\"\n", + "elif i == 7: # case 7\n", + " print \"I am in case 7\"\n", + "elif i == 22: #case 22\n", + " print \"I am in case 22\"\n", + "else: # default\n", + " print \"I am in default\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "I am in case 22\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>The Tips and Traps b), Page number: 140<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "c = 'x'\n", + "\n", + "#Switch case statements\n", + "if c == 'v': # case 'v'\n", + " print \"I am in case v\"\n", + "elif c == 'a': # case 'a'\n", + " print \"I am in case a\"\n", + "elif c == 'x': #case 'x'\n", + " print \"I am in case x\"\n", + "else: # default\n", + " print \"I am in default\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "I am in case x\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>The Tips and Traps c), Page number: 141<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "ch = 'a'\n", + "\n", + "#Switch case statements\n", + "if ch == 'a' or ch == 'A' : # case 'a' and case 'A'\n", + " print \"a as in ashar\"\n", + "elif ch == 'b'or ch == 'B': # case 'b' and case 'B'\n", + " print \"b as in brain\"\n", + "elif ch == 'c'or ch == 'C': # case 'c' and case 'C'\n", + " print \"c as in cookie\"\n", + "else: # default\n", + " print (\"wish you knew what are alphabets\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a as in ashar\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>The Tips and Traps e) , Page number: 143<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#Input from user\n", + "#i = raw_input(\"Enter value of i \")\n", + "i = 1\n", + "\n", + "#Switch case statements\n", + "#print \"Hello\"\n", + "if i == 1 : # case 1\n", + " j = 10\n", + "elif i == 2 :# case 2\n", + " j = 20\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Goto , Page number: 146<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "goals = 3\n", + "\n", + "if goals <= 5 : #goto\n", + " print \"To err is human!\" #label sos\n", + "else:\n", + " print \"About time soccer players learnt C\" \n", + " print \"and said goodbye! adieu! to soccer\" \n", + " \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "To err is human!\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Goto , Page number: 148<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#nested for loops\n", + "for i in range(1,4):\n", + " for j in range(1,4):\n", + " for k in range(1,4):\n", + " if ( i == 3 and j == 3 and k == 3 ): #goto\n", + " print \"Out of the loop at last!\" # label out\n", + " break\n", + " else:\n", + " print i, j, k " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1 1 1\n", + "1 1 2\n", + "1 1 3\n", + "1 2 1\n", + "1 2 2\n", + "1 2 3\n", + "1 3 1\n", + "1 3 2\n", + "1 3 3\n", + "2 1 1\n", + "2 1 2\n", + "2 1 3\n", + "2 2 1\n", + "2 2 2\n", + "2 2 3\n", + "2 3 1\n", + "2 3 2\n", + "2 3 3\n", + "3 1 1\n", + "3 1 2\n", + "3 1 3\n", + "3 2 1\n", + "3 2 2\n", + "3 2 3\n", + "3 3 1\n", + "3 3 2\n", + "Out of the loop at last!\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Let_us_C/chapter-5.ipynb b/Let_us_C/chapter-5.ipynb index 76227dd0..2055e966 100644 --- a/Let_us_C/chapter-5.ipynb +++ b/Let_us_C/chapter-5.ipynb @@ -1,777 +1,772 @@ -{
- "metadata": {
- "name": "chapter-5.ipynb"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h1>Chapter 5: Functions & Pointers <h1>"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Message Function, Page number: 159<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# function definition\n",
- "def message():\n",
- " print \"Smile, and the world smiles with you...\" \n",
- "\n",
- "message() #function call\n",
- "print \"Cry, and you stop the monotony!\" \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Smile, and the world smiles with you...\n",
- "Cry, and you stop the monotony!\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Calling More Than One Funnction , Page number: 159<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# function definitions\n",
- "def italy():\n",
- " print \"I am in italy\" \n",
- " \n",
- "def brazil():\n",
- " print \"I am in brazil\" \n",
- "\n",
- "def argentina():\n",
- " print \"I am in argentina\" \n",
- " \n",
- "\n",
- "print \"I am in main\" \n",
- "#function calls\n",
- "italy()\n",
- "brazil()\n",
- "argentina()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "I am in main\n",
- "I am in italy\n",
- "I am in brazil\n",
- "I am in argentina\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Function Calling Function, Page number: 161<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# function definitions\n",
- "def argentina():\n",
- " print \"I am in argentina\" \n",
- "\n",
- "def brazil():\n",
- " print \"I am in brazil\" \n",
- " argentina() #function call\n",
- "\n",
- "def italy():\n",
- " print \"I am in italy\" \n",
- " brazil() #function call\n",
- " print \"I am back in italy\" \n",
- " \n",
- "print \"I am in main\" \n",
- "#function call\n",
- "italy()\n",
- "print \"I am finally back in main\" "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "I am in main\n",
- "I am in italy\n",
- "I am in brazil\n",
- "I am in argentina\n",
- "I am back in italy\n",
- "I am finally back in main\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Calsum Function , Page number: 166<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# function definition\n",
- "def calsum ( x, y, z ):\n",
- " d = x + y + z\n",
- " return d\n",
- "\n",
- "#Input from user\n",
- "#a,b,c = raw_input (\"Enter any three numbers: \").split()\n",
- "print \"Enter any three numbers: \"\n",
- "a = 10\n",
- "b = 20\n",
- "c = 30\n",
- "print a,b,c\n",
- "\n",
- "#function call\n",
- "s = calsum(a,b,c) \n",
- "\n",
- "#Result\n",
- "print \"Sum = \", s \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter any three numbers: \n",
- "10 20 30\n",
- "Sum = 60\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Return Statement , Page number: 169<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "statements that may be present in a function.\n",
- "Also, the return statement need not always be present at the end of the called\n",
- "\n",
- "# function definition\n",
- "def fun():\n",
- " #Input from user\n",
- " #ch = raw_input (\"Enter any alphabet: \")\n",
- " print \"Enter any alphabet: \"\n",
- " ch = 'a'\n",
- " print ch\n",
- " ch = ord(ch)\n",
- " if ch >= 65 and ch <= 90:\n",
- " return ascii(ch)\n",
- " else:\n",
- " return ascii( ch + 32 )\n",
- "\n",
- "#function call\n",
- "ch = fun()\n",
- "\n",
- "#Result\n",
- "print ch\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": []
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Formal Arguments, Page number: 170<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "changed in the called function, the corresponding\n",
- "\n",
- "# function definition\n",
- "def fun(b):\n",
- " b = 60\n",
- " print b \n",
- "\n",
- "a = 30\n",
- "fun(a) #function call\n",
- "print a"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "60\n",
- "30\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Scope Rule of Functions , Page number: 171<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# function definition\n",
- "def display(j):\n",
- " k = 35\n",
- " print j\n",
- " print k\n",
- "\n",
- "i = 20 \n",
- "display(i) #function call\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "20\n",
- "35\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Square Function , Page number: 176<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# function definition\n",
- "def square(x):\n",
- " y = x * x\n",
- " return y\n",
- "\n",
- "#Input from user\n",
- "#a = raw_input(\"Enter any number: \")\n",
- "print \"Enter any number: \"\n",
- "a = 4.5\n",
- "print a\n",
- "\n",
- "b = square(a) #function call\n",
- "\n",
- "#Result\n",
- "print \"Square of %f is %f\" %( a, b )\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter any number: \n",
- "4.5\n",
- "Square of 4.500000 is 20.250000\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Void Function , Page number: 177<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# function definition\n",
- "def gospel(): # void function\n",
- " print \"Viruses are electronic bandits...\" \n",
- " print \"who eat nuggets of information...\" \n",
- " print \"and chunks of bytes...\" \n",
- " print \"when you least expect...\" \n",
- "\n",
- "gospel() # function call"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Viruses are electronic bandits...\n",
- "who eat nuggets of information...\n",
- "and chunks of bytes...\n",
- "when you least expect...\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Address of a Variable , Page number: 180<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "i = 3\n",
- "\n",
- "#Result\n",
- "print \"Address of i = \" , id(i) #printing address\n",
- "print \"Value of i = \", i \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Address of i = 30301288\n",
- "Value of i = 3\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Pointer Relations , Page number: 182<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "i = 3 \n",
- "j = id(i) # address of variable 'i'\n",
- "\n",
- "#Result\n",
- "print \"Address of i = \", id(i) \n",
- "print \"Address of i = \", j \n",
- "print \"Address of j = \", id(j)\n",
- "print \"Value of j = \", j \n",
- "print \"Value of i = \", i \n",
- "print \"Value of i = \", i \n",
- "print \"Value of i = \", i \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Address of i = 30301288\n",
- "Address of i = 30301288\n",
- "Address of j = 134133200\n",
- "Value of j = 30301288\n",
- "Value of i = 3\n",
- "Value of i = 3\n",
- "Value of i = 3\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Pointer to Another Pointer , Page number: 184<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "i = 3\n",
- "j = id(i) # address of i\n",
- "k = id(j) # address of j\n",
- "\n",
- "#Result\n",
- "print \"Address of i = \", id(i) \n",
- "print \"Address of i = \", j \n",
- "print \"Address of i = \", j \n",
- "print \"Address of j = \", id(j) \n",
- "print \"Address of j = \", k \n",
- "print \"Address of k = \", id(k)\n",
- "print \"Value of j = \", j \n",
- "print \"Value of k = \", k \n",
- "print \"Value of i = \", i \n",
- "print \"Value of i = \", i \n",
- "print \"Value of i = \", i \n",
- "print \"Value of i = \", i "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Address of i = 30301288\n",
- "Address of i = 30301288\n",
- "Address of i = 30301288\n",
- "Address of j = 134132944\n",
- "Address of j = 134132944\n",
- "Address of k = 134133200\n",
- "Value of j = 30301288\n",
- "Value of k = 134132944\n",
- "Value of i = 3\n",
- "Value of i = 3\n",
- "Value of i = 3\n",
- "Value of i = 3\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Call By Value , Page number: 186<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# function definition\n",
- "def swapv (x,y):\n",
- " x,y=y,x\n",
- " print \"x = %d y = %d\" %( x, y )\n",
- "\n",
- "#Variable declaration\n",
- "a = 10\n",
- "b = 20\n",
- "\n",
- "swapv ( a, b ) # function call\n",
- "\n",
- "#Result\n",
- "print \"a = %d b = %d\" %( a, b )\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = 20 y = 10\n",
- "a = 10 b = 20\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Call By Reference , Page number: 187<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# function definition\n",
- "def swapv (a,b):\n",
- " a,b=b,a\n",
- " return a,b\n",
- "\n",
- "#Variable declaration\n",
- "a = 10\n",
- "b = 20\n",
- "\n",
- "a,b = swapv ( a, b ) # function call\n",
- "\n",
- "#Result\n",
- "print \"a = %d b = %d\" %( a, b )"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a = 20 b = 10\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Area And Perimeter of a Circle , Page number: 188<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Input from user\n",
- "#radius = raw_input(\"Enter radius of a circle: \" )\n",
- "print \"Enter radius of a circle: \"\n",
- "radius = 5\n",
- "print radius\n",
- "\n",
- "#Function definition\n",
- "def areaperi ( r ):\n",
- " a = 3.14 * r * r\n",
- " p = 2 * 3.14 * r \n",
- " return a,p\n",
- "\n",
- "area,perimeter = areaperi ( radius ) #function call\n",
- "\n",
- "\n",
- "#Result\n",
- "print \"Area = \", area \n",
- "print \"Perimeter = \", perimeter "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter radius of a circle: \n",
- "5\n",
- "Area = 78.5\n",
- "Perimeter = 31.4\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Iterative Factorial Function , Page number: 190<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# function definition\n",
- "def factorial(x):\n",
- " f = 1\n",
- " for i in range(x,0,-1 ):\n",
- " f = f * i\n",
- " return f\n",
- "\n",
- "#Input from user\n",
- "#a = raw_input( \"Enter any number: \" )\n",
- "print \"Enter any number: \"\n",
- "a = 6\n",
- "print a\n",
- "\n",
- "fact = factorial(a) #function call\n",
- "\n",
- "#Result\n",
- "print \"Factorial value = \", fact\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter any number: \n",
- "6\n",
- "Factorial value = 720\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Recursive Factorial Function, Page number: 191<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# function definition\n",
- "def rec(x):\n",
- " if x == 1:\n",
- " return 1\n",
- " else:\n",
- " f = x * rec ( x - 1 ) # calling the function\n",
- " return f\n",
- "\n",
- "#Input from user\n",
- "#a = raw_input( \"Enter any number: \" )\n",
- "print \"Enter any number: \"\n",
- "a = 5\n",
- "print a\n",
- "\n",
- "fact = rec(a) #function call\n",
- "\n",
- "#Result\n",
- "print \"Factorial value = \", fact \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter any number: \n",
- "5\n",
- "Factorial value = 120\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Recursion Stack , Page number: 195<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "a = 5\n",
- "b = 2\n",
- "\n",
- "#Function definition\n",
- "def add ( i, j ):\n",
- " s = i + j\n",
- " return s\n",
- "\n",
- "c = add ( a, b ) # function call\n",
- "\n",
- "#Result\n",
- "print \"sum = \", c "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "sum = 7\n"
- ]
- }
- ],
- "prompt_number": 21
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:ff4108fd8429f13da3024f33c6733cc054cfdd0248ac7308786b7df9d4793937" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h1>Chapter 5: Functions & Pointers <h1>" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Message Function, Page number: 159<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definition\n", + "def message():\n", + " print \"Smile, and the world smiles with you...\" \n", + "\n", + "message() #function call\n", + "print \"Cry, and you stop the monotony!\" \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Smile, and the world smiles with you...\n", + "Cry, and you stop the monotony!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Calling More Than One Funnction , Page number: 159<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definitions\n", + "def italy():\n", + " print \"I am in italy\" \n", + " \n", + "def brazil():\n", + " print \"I am in brazil\" \n", + "\n", + "def argentina():\n", + " print \"I am in argentina\" \n", + " \n", + "\n", + "print \"I am in main\" \n", + "#function calls\n", + "italy()\n", + "brazil()\n", + "argentina()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "I am in main\n", + "I am in italy\n", + "I am in brazil\n", + "I am in argentina\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Function Calling Function, Page number: 161<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definitions\n", + "def argentina():\n", + " print \"I am in argentina\" \n", + "\n", + "def brazil():\n", + " print \"I am in brazil\" \n", + " argentina() #function call\n", + "\n", + "def italy():\n", + " print \"I am in italy\" \n", + " brazil() #function call\n", + " print \"I am back in italy\" \n", + " \n", + "print \"I am in main\" \n", + "#function call\n", + "italy()\n", + "print \"I am finally back in main\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "I am in main\n", + "I am in italy\n", + "I am in brazil\n", + "I am in argentina\n", + "I am back in italy\n", + "I am finally back in main\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Calsum Function , Page number: 166<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definition\n", + "def calsum ( x, y, z ):\n", + " d = x + y + z\n", + " return d\n", + "\n", + "#Input from user\n", + "#a,b,c = raw_input (\"Enter any three numbers: \").split()\n", + "print \"Enter any three numbers: \"\n", + "a = 10\n", + "b = 20\n", + "c = 30\n", + "print a,b,c\n", + "\n", + "#function call\n", + "s = calsum(a,b,c) \n", + "\n", + "#Result\n", + "print \"Sum = \", s \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter any three numbers: \n", + "10 20 30\n", + "Sum = 60\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Return Statement , Page number: 169<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "# function definition\n", + "def fun():\n", + " #Input from user\n", + " #ch = raw_input (\"Enter any alphabet: \")\n", + " print \"Enter any alphabet: \"\n", + " ch = 'a'\n", + " print ch\n", + " ch = ord(ch)\n", + " if ch >= 65 and ch <= 90:\n", + " return ascii(ch)\n", + " else:\n", + " return ascii( ch + 32 )\n", + "\n", + "#function call\n", + "ch = fun()\n", + "\n", + "#Result\n", + "print ch\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Formal Arguments, Page number: 170<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definition\n", + "def fun(b):\n", + " b = 60\n", + " print b \n", + "\n", + "a = 30\n", + "fun(a) #function call\n", + "print a" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "60\n", + "30\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Scope Rule of Functions , Page number: 171<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definition\n", + "def display(j):\n", + " k = 35\n", + " print j\n", + " print k\n", + "\n", + "i = 20 \n", + "display(i) #function call\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "20\n", + "35\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Square Function , Page number: 176<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definition\n", + "def square(x):\n", + " y = x * x\n", + " return y\n", + "\n", + "#Input from user\n", + "#a = raw_input(\"Enter any number: \")\n", + "print \"Enter any number: \"\n", + "a = 4.5\n", + "print a\n", + "\n", + "b = square(a) #function call\n", + "\n", + "#Result\n", + "print \"Square of %f is %f\" %( a, b )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter any number: \n", + "4.5\n", + "Square of 4.500000 is 20.250000\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Void Function , Page number: 177<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definition\n", + "def gospel(): # void function\n", + " print \"Viruses are electronic bandits...\" \n", + " print \"who eat nuggets of information...\" \n", + " print \"and chunks of bytes...\" \n", + " print \"when you least expect...\" \n", + "\n", + "gospel() # function call" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Viruses are electronic bandits...\n", + "who eat nuggets of information...\n", + "and chunks of bytes...\n", + "when you least expect...\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Address of a Variable , Page number: 180<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "i = 3\n", + "\n", + "#Result\n", + "print \"Address of i = \" , id(i) #printing address\n", + "print \"Value of i = \", i \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Address of i = 30301288\n", + "Value of i = 3\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Pointer Relations , Page number: 182<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "i = 3 \n", + "j = id(i) # address of variable 'i'\n", + "\n", + "#Result\n", + "print \"Address of i = \", id(i) \n", + "print \"Address of i = \", j \n", + "print \"Address of j = \", id(j)\n", + "print \"Value of j = \", j \n", + "print \"Value of i = \", i \n", + "print \"Value of i = \", i \n", + "print \"Value of i = \", i \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Address of i = 30301288\n", + "Address of i = 30301288\n", + "Address of j = 134133200\n", + "Value of j = 30301288\n", + "Value of i = 3\n", + "Value of i = 3\n", + "Value of i = 3\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Pointer to Another Pointer , Page number: 184<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "i = 3\n", + "j = id(i) # address of i\n", + "k = id(j) # address of j\n", + "\n", + "#Result\n", + "print \"Address of i = \", id(i) \n", + "print \"Address of i = \", j \n", + "print \"Address of i = \", j \n", + "print \"Address of j = \", id(j) \n", + "print \"Address of j = \", k \n", + "print \"Address of k = \", id(k)\n", + "print \"Value of j = \", j \n", + "print \"Value of k = \", k \n", + "print \"Value of i = \", i \n", + "print \"Value of i = \", i \n", + "print \"Value of i = \", i \n", + "print \"Value of i = \", i " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Address of i = 30301288\n", + "Address of i = 30301288\n", + "Address of i = 30301288\n", + "Address of j = 134132944\n", + "Address of j = 134132944\n", + "Address of k = 134133200\n", + "Value of j = 30301288\n", + "Value of k = 134132944\n", + "Value of i = 3\n", + "Value of i = 3\n", + "Value of i = 3\n", + "Value of i = 3\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Call By Value , Page number: 186<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definition\n", + "def swapv (x,y):\n", + " x,y=y,x\n", + " print \"x = %d y = %d\" %( x, y )\n", + "\n", + "#Variable declaration\n", + "a = 10\n", + "b = 20\n", + "\n", + "swapv ( a, b ) # function call\n", + "\n", + "#Result\n", + "print \"a = %d b = %d\" %( a, b )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x = 20 y = 10\n", + "a = 10 b = 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Call By Reference , Page number: 187<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definition\n", + "def swapv (a,b):\n", + " a,b=b,a\n", + " return a,b\n", + "\n", + "#Variable declaration\n", + "a = 10\n", + "b = 20\n", + "\n", + "a,b = swapv ( a, b ) # function call\n", + "\n", + "#Result\n", + "print \"a = %d b = %d\" %( a, b )" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a = 20 b = 10\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Area And Perimeter of a Circle , Page number: 188<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "print \"Enter radius of a circle: \"\n", + "radius = 5\n", + "print radius\n", + "\n", + "#Function definition\n", + "def areaperi ( r ):\n", + " a = 3.14 * r * r\n", + " p = 2 * 3.14 * r \n", + " return a,p\n", + "\n", + "area,perimeter = areaperi ( radius ) #function call\n", + "\n", + "\n", + "#Result\n", + "print \"Area = \", area \n", + "print \"Perimeter = \", perimeter " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter radius of a circle: \n", + "5\n", + "Area = 78.5\n", + "Perimeter = 31.4\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Iterative Factorial Function , Page number: 190<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definition\n", + "def factorial(x):\n", + " f = 1\n", + " for i in range(x,0,-1 ):\n", + " f = f * i\n", + " return f\n", + "\n", + "\n", + "print \"Enter any number: \"\n", + "a = 6\n", + "print a\n", + "\n", + "fact = factorial(a) #function call\n", + "\n", + "#Result\n", + "print \"Factorial value = \", fact\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter any number: \n", + "6\n", + "Factorial value = 720\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Recursive Factorial Function, Page number: 191<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# function definition\n", + "def rec(x):\n", + " if x == 1:\n", + " return 1\n", + " else:\n", + " f = x * rec ( x - 1 ) # calling the function\n", + " return f\n", + "\n", + "\n", + "print \"Enter any number: \"\n", + "a = 5\n", + "print a\n", + "\n", + "fact = rec(a) #function call\n", + "\n", + "#Result\n", + "print \"Factorial value = \", fact \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter any number: \n", + "5\n", + "Factorial value = 120\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Recursion Stack , Page number: 195<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "a = 5\n", + "b = 2\n", + "\n", + "#Function definition\n", + "def add ( i, j ):\n", + " s = i + j\n", + " return s\n", + "\n", + "c = add ( a, b ) # function call\n", + "\n", + "#Result\n", + "print \"sum = \", c " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "sum = 7\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Let_us_C/chapter-6.ipynb b/Let_us_C/chapter-6.ipynb index 8234fda0..ff2bda1a 100644 --- a/Let_us_C/chapter-6.ipynb +++ b/Let_us_C/chapter-6.ipynb @@ -1,672 +1,666 @@ -{
- "metadata": {
- "name": "chapter-6.ipynb"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h1>Chapter 6: Data Types Revisted <h1>"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>char Example, Page number: 218<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "ch = 291\n",
- "\n",
- "#Result\n",
- "print \"%d %c\" %( ch, (ch%128) ) \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "291 #\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Range of char, Page number: 218<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "for ch in range(0,256):\n",
- " print \"%d %c\" %(ch, ch%128 )\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0 \u0000\n",
- "1 \u0001\n",
- "2 \u0002\n",
- "3 \u0003\n",
- "4 \u0004\n",
- "5 \u0005\n",
- "6 \u0006\n",
- "7 \u0007\n",
- "8 \b\n",
- "9 \t\n",
- "10 \n",
- "\n",
- "11 \u000b",
- "\n",
- "12 \f",
- "\n",
- "13 \r\n",
- "14 \u000e\n",
- "15 \u000f\n",
- "16 \u0010\n",
- "17 \u0011\n",
- "18 \u0012\n",
- "19 \u0013\n",
- "20 \u0014\n",
- "21 \u0015\n",
- "22 \u0016\n",
- "23 \u0017\n",
- "24 \u0018\n",
- "25 \u0019\n",
- "26 \u001a\n",
- "27 \u001b\n",
- "28 \u001c",
- "\n",
- "29 \u001d",
- "\n",
- "30 \u001e",
- "\n",
- "31 \u001f\n",
- "32 \n",
- "33 !\n",
- "34 \"\n",
- "35 #\n",
- "36 $\n",
- "37 %\n",
- "38 &\n",
- "39 '\n",
- "40 (\n",
- "41 )\n",
- "42 *\n",
- "43 +\n",
- "44 ,\n",
- "45 -\n",
- "46 .\n",
- "47 /\n",
- "48 0\n",
- "49 1\n",
- "50 2\n",
- "51 3\n",
- "52 4\n",
- "53 5\n",
- "54 6\n",
- "55 7\n",
- "56 8\n",
- "57 9\n",
- "58 :\n",
- "59 ;\n",
- "60 <\n",
- "61 =\n",
- "62 >\n",
- "63 ?\n",
- "64 @\n",
- "65 A\n",
- "66 B\n",
- "67 C\n",
- "68 D\n",
- "69 E\n",
- "70 F\n",
- "71 G\n",
- "72 H\n",
- "73 I\n",
- "74 J\n",
- "75 K\n",
- "76 L\n",
- "77 M\n",
- "78 N\n",
- "79 O\n",
- "80 P\n",
- "81 Q\n",
- "82 R\n",
- "83 S\n",
- "84 T\n",
- "85 U\n",
- "86 V\n",
- "87 W\n",
- "88 X\n",
- "89 Y\n",
- "90 Z\n",
- "91 [\n",
- "92 \\\n",
- "93 ]\n",
- "94 ^\n",
- "95 _\n",
- "96 `\n",
- "97 a\n",
- "98 b\n",
- "99 c\n",
- "100 d\n",
- "101 e\n",
- "102 f\n",
- "103 g\n",
- "104 h\n",
- "105 i\n",
- "106 j\n",
- "107 k\n",
- "108 l\n",
- "109 m\n",
- "110 n\n",
- "111 o\n",
- "112 p\n",
- "113 q\n",
- "114 r\n",
- "115 s\n",
- "116 t\n",
- "117 u\n",
- "118 v\n",
- "119 w\n",
- "120 x\n",
- "121 y\n",
- "122 z\n",
- "123 {\n",
- "124 |\n",
- "125 }\n",
- "126 ~\n",
- "127 \u007f\n",
- "128 \u0000\n",
- "129 \u0001\n",
- "130 \u0002\n",
- "131 \u0003\n",
- "132 \u0004\n",
- "133 \u0005\n",
- "134 \u0006\n",
- "135 \u0007\n",
- "136 \b\n",
- "137 \t\n",
- "138 \n",
- "\n",
- "139 \u000b",
- "\n",
- "140 \f",
- "\n",
- "141 \r\n",
- "142 \u000e\n",
- "143 \u000f\n",
- "144 \u0010\n",
- "145 \u0011\n",
- "146 \u0012\n",
- "147 \u0013\n",
- "148 \u0014\n",
- "149 \u0015\n",
- "150 \u0016\n",
- "151 \u0017\n",
- "152 \u0018\n",
- "153 \u0019\n",
- "154 \u001a\n",
- "155 \u001b\n",
- "156 \u001c",
- "\n",
- "157 \u001d",
- "\n",
- "158 \u001e",
- "\n",
- "159 \u001f\n",
- "160 \n",
- "161 !\n",
- "162 \"\n",
- "163 #\n",
- "164 $\n",
- "165 %\n",
- "166 &\n",
- "167 '\n",
- "168 (\n",
- "169 )\n",
- "170 *\n",
- "171 +\n",
- "172 ,\n",
- "173 -\n",
- "174 .\n",
- "175 /\n",
- "176 0\n",
- "177 1\n",
- "178 2\n",
- "179 3\n",
- "180 4\n",
- "181 5\n",
- "182 6\n",
- "183 7\n",
- "184 8\n",
- "185 9\n",
- "186 :\n",
- "187 ;\n",
- "188 <\n",
- "189 =\n",
- "190 >\n",
- "191 ?\n",
- "192 @\n",
- "193 A\n",
- "194 B\n",
- "195 C\n",
- "196 D\n",
- "197 E\n",
- "198 F\n",
- "199 G\n",
- "200 H\n",
- "201 I\n",
- "202 J\n",
- "203 K\n",
- "204 L\n",
- "205 M\n",
- "206 N\n",
- "207 O\n",
- "208 P\n",
- "209 Q\n",
- "210 R\n",
- "211 S\n",
- "212 T\n",
- "213 U\n",
- "214 V\n",
- "215 W\n",
- "216 X\n",
- "217 Y\n",
- "218 Z\n",
- "219 [\n",
- "220 \\\n",
- "221 ]\n",
- "222 ^\n",
- "223 _\n",
- "224 `\n",
- "225 a\n",
- "226 b\n",
- "227 c\n",
- "228 d\n",
- "229 e\n",
- "230 f\n",
- "231 g\n",
- "232 h\n",
- "233 i\n",
- "234 j\n",
- "235 k\n",
- "236 l\n",
- "237 m\n",
- "238 n\n",
- "239 o\n",
- "240 p\n",
- "241 q\n",
- "242 r\n",
- "243 s\n",
- "244 t\n",
- "245 u\n",
- "246 v\n",
- "247 w\n",
- "248 x\n",
- "249 y\n",
- "250 z\n",
- "251 {\n",
- "252 |\n",
- "253 }\n",
- "254 ~\n",
- "255 \u007f\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Scope and Life of Automatic Variable, Page number: 225<h3>\n"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "i = 1 #auto int\n",
- "\n",
- "def b2 (i):\n",
- " print i \n",
- "\n",
- "def b3 (i):\n",
- " print i \n",
- "\n",
- "\n",
- "def b1 (i):\n",
- " print i \n",
- " b2(i)\n",
- " b3(i)\n",
- "\n",
- "\n",
- "#Result\n",
- "b1(i)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1\n",
- "1\n",
- "1\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Scope and Life of Automatic Variable, Page number: 226<h3>\n"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "i = 1 #auto int\n",
- "\n",
- "def b2 (i):\n",
- " i = 2 # auto int \n",
- " print i \n",
- "\n",
- "def b3 (i):\n",
- " i = 3 #auto int \n",
- " print i \n",
- "\n",
- "\n",
- "def b1 (i):\n",
- " b3(i)\n",
- " b2(i)\n",
- " print i \n",
- "\n",
- "\n",
- "#Result\n",
- "b1(i)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "3\n",
- "2\n",
- "1\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Different Data Types, Page number: 220<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#char\n",
- "#c,d = raw_input(\"char: \").split()\n",
- "c = 'a'\n",
- "d = 'b'\n",
- "print \"%c %c\" %( c, d )\n",
- "\n",
- "#int \n",
- "#i,j = raw_input( \"int: \").split()\n",
- "i = 333\n",
- "j = 288\n",
- "print \"%d %u\"%( i, j ) \n",
- "\n",
- "#short int \n",
- "#,l = raw_input( \"short int: \" ).split()\n",
- "k = 2\n",
- "l = 1\n",
- "print \"%d %u \" %(k, l ) \n",
- "\n",
- "#long int \n",
- "#m,n = raw_input( \"long int: \" ).split()\n",
- "m = 73277727727\n",
- "n = 189189819891\n",
- "print \"%ld %lu\"%( m, n ) \n",
- "\n",
- "\n",
- "#float, double, long double\n",
- "from decimal import Decimal \n",
- "#x,y,z = raw_input ( \"float double long double: \").split()\n",
- "x = 72.12\n",
- "y = Decimal(8282910.0109010)\n",
- "z = Decimal(29189999111.128918918)\n",
- "print x, y, z "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a b\n",
- "333 288\n",
- "2 1 \n",
- "73277727727 189189819891\n",
- "72.12 8282910.0109010003507137298583984375 29189999111.128917694091796875\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Auto Increment, Page number: 228<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#function definition \n",
- "def increment( ):\n",
- " i = 1 #auto int\n",
- " print i \n",
- " i = i + 1 \n",
- "\n",
- "#function calls\n",
- "increment( )\n",
- "increment( )\n",
- "increment( )\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1\n",
- "1\n",
- "1\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Static Increment, Page number: 228<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#function definition \n",
- "def increment(i = [1]): #static int \n",
- " print i[0] \n",
- " i[0] += 1 \n",
- "\n",
- "#function calls\n",
- "increment()\n",
- "increment()\n",
- "increment()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1\n",
- "2\n",
- "3\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Static Storage Class, Page number: 229<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "#function definition\n",
- "def fun( ):\n",
- " k = 35 \n",
- " return (k)\n",
- "\n",
- "j = fun( ) #function call\n",
- "print j #result\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "35\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>External Storage Class, Page number: 231<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration \n",
- "i = [0] # external variable\n",
- "\n",
- "#Function definitions \n",
- "def increment(i = [0]):\n",
- " i[0] += 1\n",
- " print \"on incrementing i = \", i[0] \n",
- "\n",
- "\n",
- "def decrement(i = [2]):\n",
- " i[0] -= 1\n",
- " print \"on decrementing i = \", i[0] \n",
- " \n",
- "\n",
- "\n",
- "print \"i = \", i[0]\n",
- "#function calls\n",
- "increment() \n",
- "increment() \n",
- "decrement() \n",
- "decrement() "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "i = 0\n",
- "on incrementing i = 1\n",
- "on incrementing i = 2\n",
- "on decrementing i = 1\n",
- "on decrementing i = 0\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:840b5b41a5ba5f473d9fd4f85395b35887d7b6a2fb119c03c9559a162f751aa0" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h1>Chapter 6: Data Types Revisted <h1>" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>char Example, Page number: 218<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "ch = 291\n", + "\n", + "#Result\n", + "print \"%d %c\" %( ch, (ch%128) ) \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "291 #\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Range of char, Page number: 218<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "for ch in range(0,256):\n", + " print \"%d %c\" %(ch, ch%128 )\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "0 \u0000\n", + "1 \u0001\n", + "2 \u0002\n", + "3 \u0003\n", + "4 \u0004\n", + "5 \u0005\n", + "6 \u0006\n", + "7 \u0007\n", + "8 \b\n", + "9 \t\n", + "10 \n", + "\n", + "11 \u000b", + "\n", + "12 \f", + "\n", + "13 \r\n", + "14 \u000e\n", + "15 \u000f\n", + "16 \u0010\n", + "17 \u0011\n", + "18 \u0012\n", + "19 \u0013\n", + "20 \u0014\n", + "21 \u0015\n", + "22 \u0016\n", + "23 \u0017\n", + "24 \u0018\n", + "25 \u0019\n", + "26 \u001a\n", + "27 \u001b\n", + "28 \u001c", + "\n", + "29 \u001d", + "\n", + "30 \u001e", + "\n", + "31 \u001f\n", + "32 \n", + "33 !\n", + "34 \"\n", + "35 #\n", + "36 $\n", + "37 %\n", + "38 &\n", + "39 '\n", + "40 (\n", + "41 )\n", + "42 *\n", + "43 +\n", + "44 ,\n", + "45 -\n", + "46 .\n", + "47 /\n", + "48 0\n", + "49 1\n", + "50 2\n", + "51 3\n", + "52 4\n", + "53 5\n", + "54 6\n", + "55 7\n", + "56 8\n", + "57 9\n", + "58 :\n", + "59 ;\n", + "60 <\n", + "61 =\n", + "62 >\n", + "63 ?\n", + "64 @\n", + "65 A\n", + "66 B\n", + "67 C\n", + "68 D\n", + "69 E\n", + "70 F\n", + "71 G\n", + "72 H\n", + "73 I\n", + "74 J\n", + "75 K\n", + "76 L\n", + "77 M\n", + "78 N\n", + "79 O\n", + "80 P\n", + "81 Q\n", + "82 R\n", + "83 S\n", + "84 T\n", + "85 U\n", + "86 V\n", + "87 W\n", + "88 X\n", + "89 Y\n", + "90 Z\n", + "91 [\n", + "92 \\\n", + "93 ]\n", + "94 ^\n", + "95 _\n", + "96 `\n", + "97 a\n", + "98 b\n", + "99 c\n", + "100 d\n", + "101 e\n", + "102 f\n", + "103 g\n", + "104 h\n", + "105 i\n", + "106 j\n", + "107 k\n", + "108 l\n", + "109 m\n", + "110 n\n", + "111 o\n", + "112 p\n", + "113 q\n", + "114 r\n", + "115 s\n", + "116 t\n", + "117 u\n", + "118 v\n", + "119 w\n", + "120 x\n", + "121 y\n", + "122 z\n", + "123 {\n", + "124 |\n", + "125 }\n", + "126 ~\n", + "127 \u007f\n", + "128 \u0000\n", + "129 \u0001\n", + "130 \u0002\n", + "131 \u0003\n", + "132 \u0004\n", + "133 \u0005\n", + "134 \u0006\n", + "135 \u0007\n", + "136 \b\n", + "137 \t\n", + "138 \n", + "\n", + "139 \u000b", + "\n", + "140 \f", + "\n", + "141 \r\n", + "142 \u000e\n", + "143 \u000f\n", + "144 \u0010\n", + "145 \u0011\n", + "146 \u0012\n", + "147 \u0013\n", + "148 \u0014\n", + "149 \u0015\n", + "150 \u0016\n", + "151 \u0017\n", + "152 \u0018\n", + "153 \u0019\n", + "154 \u001a\n", + "155 \u001b\n", + "156 \u001c", + "\n", + "157 \u001d", + "\n", + "158 \u001e", + "\n", + "159 \u001f\n", + "160 \n", + "161 !\n", + "162 \"\n", + "163 #\n", + "164 $\n", + "165 %\n", + "166 &\n", + "167 '\n", + "168 (\n", + "169 )\n", + "170 *\n", + "171 +\n", + "172 ,\n", + "173 -\n", + "174 .\n", + "175 /\n", + "176 0\n", + "177 1\n", + "178 2\n", + "179 3\n", + "180 4\n", + "181 5\n", + "182 6\n", + "183 7\n", + "184 8\n", + "185 9\n", + "186 :\n", + "187 ;\n", + "188 <\n", + "189 =\n", + "190 >\n", + "191 ?\n", + "192 @\n", + "193 A\n", + "194 B\n", + "195 C\n", + "196 D\n", + "197 E\n", + "198 F\n", + "199 G\n", + "200 H\n", + "201 I\n", + "202 J\n", + "203 K\n", + "204 L\n", + "205 M\n", + "206 N\n", + "207 O\n", + "208 P\n", + "209 Q\n", + "210 R\n", + "211 S\n", + "212 T\n", + "213 U\n", + "214 V\n", + "215 W\n", + "216 X\n", + "217 Y\n", + "218 Z\n", + "219 [\n", + "220 \\\n", + "221 ]\n", + "222 ^\n", + "223 _\n", + "224 `\n", + "225 a\n", + "226 b\n", + "227 c\n", + "228 d\n", + "229 e\n", + "230 f\n", + "231 g\n", + "232 h\n", + "233 i\n", + "234 j\n", + "235 k\n", + "236 l\n", + "237 m\n", + "238 n\n", + "239 o\n", + "240 p\n", + "241 q\n", + "242 r\n", + "243 s\n", + "244 t\n", + "245 u\n", + "246 v\n", + "247 w\n", + "248 x\n", + "249 y\n", + "250 z\n", + "251 {\n", + "252 |\n", + "253 }\n", + "254 ~\n", + "255 \u007f\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Scope and Life of Automatic Variable, Page number: 225<h3>\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "i = 1 #auto int\n", + "\n", + "def b2 (i):\n", + " print i \n", + "\n", + "def b3 (i):\n", + " print i \n", + "\n", + "\n", + "def b1 (i):\n", + " print i \n", + " b2(i)\n", + " b3(i)\n", + "\n", + "\n", + "#Result\n", + "b1(i)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "1\n", + "1\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Scope and Life of Automatic Variable, Page number: 226<h3>\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "i = 1 #auto int\n", + "\n", + "def b2 (i):\n", + " i = 2 # auto int \n", + " print i \n", + "\n", + "def b3 (i):\n", + " i = 3 #auto int \n", + " print i \n", + "\n", + "\n", + "def b1 (i):\n", + " b3(i)\n", + " b2(i)\n", + " print i \n", + "\n", + "\n", + "#Result\n", + "b1(i)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n", + "2\n", + "1\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Different Data Types, Page number: 220<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "c = 'a'\n", + "d = 'b'\n", + "print \"%c %c\" %( c, d )\n", + "\n", + "i = 333\n", + "j = 288\n", + "print \"%d %u\"%( i, j ) \n", + "\n", + "\n", + "k = 2\n", + "l = 1\n", + "print \"%d %u \" %(k, l ) \n", + "\n", + "m = 73277727727\n", + "n = 189189819891\n", + "print \"%ld %lu\"%( m, n ) \n", + "\n", + "\n", + "#float, double, long double\n", + "from decimal import Decimal \n", + "#x,y,z = raw_input ( \"float double long double: \").split()\n", + "x = 72.12\n", + "y = Decimal(8282910.0109010)\n", + "z = Decimal(29189999111.128918918)\n", + "print x, y, z " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a b\n", + "333 288\n", + "2 1 \n", + "73277727727 189189819891\n", + "72.12 8282910.0109010003507137298583984375 29189999111.128917694091796875\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Auto Increment, Page number: 228<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#function definition \n", + "def increment( ):\n", + " i = 1 #auto int\n", + " print i \n", + " i = i + 1 \n", + "\n", + "#function calls\n", + "increment( )\n", + "increment( )\n", + "increment( )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "1\n", + "1\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Static Increment, Page number: 228<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#function definition \n", + "def increment(i = [1]): #static int \n", + " print i[0] \n", + " i[0] += 1 \n", + "\n", + "#function calls\n", + "increment()\n", + "increment()\n", + "increment()\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n", + "2\n", + "3\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Static Storage Class, Page number: 229<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#function definition\n", + "def fun( ):\n", + " k = 35 \n", + " return (k)\n", + "\n", + "j = fun( ) #function call\n", + "print j #result\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "35\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>External Storage Class, Page number: 231<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration \n", + "i = [0] # external variable\n", + "\n", + "#Function definitions \n", + "def increment(i = [0]):\n", + " i[0] += 1\n", + " print \"on incrementing i = \", i[0] \n", + "\n", + "\n", + "def decrement(i = [2]):\n", + " i[0] -= 1\n", + " print \"on decrementing i = \", i[0] \n", + " \n", + "\n", + "\n", + "print \"i = \", i[0]\n", + "#function calls\n", + "increment() \n", + "increment() \n", + "decrement() \n", + "decrement() " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i = 0\n", + "on incrementing i = 1\n", + "on incrementing i = 2\n", + "on decrementing i = 1\n", + "on decrementing i = 0\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Let_us_C/chapter-9.ipynb b/Let_us_C/chapter-9.ipynb index e74e2dd8..a712e2f0 100644 --- a/Let_us_C/chapter-9.ipynb +++ b/Let_us_C/chapter-9.ipynb @@ -1,599 +1,600 @@ -{
- "metadata": {
- "name": "chapter-9.ipynb"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h1>Chapter 9: Puppetting On Strings <h1>"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Print String , Page number: 329<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "name= \"Klinsman\" # character array or string\n",
- "i = 0\n",
- "\n",
- "#while loop for printing\n",
- "while i <= 7 :\n",
- " print name[i] \n",
- " i = i + 1\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "K\n",
- "l\n",
- "i\n",
- "n\n",
- "s\n",
- "m\n",
- "a\n",
- "n\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Print String, Page number: 330<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "name= \"Klinsman\\0\" # character array or string\n",
- "i = 0\n",
- "\n",
- "#while loop for printing\n",
- "while (name[i] != '\\0') :\n",
- " print name[i]\n",
- " i = i + 1\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "K\n",
- "l\n",
- "i\n",
- "n\n",
- "s\n",
- "m\n",
- "a\n",
- "n\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Print String Using Pointer, Page number: 330<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "name = \"Klinsman\\0\" # string or character array\n",
- "i = 0\n",
- "ptr = name[i] # store base address of string\n",
- "\n",
- "#Result\n",
- "while ptr != '\\0':\n",
- " print ptr\n",
- " i = i+1\n",
- " ptr = name[i]\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "K\n",
- "l\n",
- "i\n",
- "n\n",
- "s\n",
- "m\n",
- "a\n",
- "n\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>strlen Function, Page number: 336<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "#Variable declaration\n",
- "arr = \"Bamboozled\" # character array or string\n",
- "\n",
- "#string length function\n",
- "len1 = len(arr) \n",
- "len2 = len( \"Humpty Dumpty\" )\n",
- "\n",
- "#Result\n",
- "print \"string = %s length = %d\" %( arr, len1 )\n",
- "print \"string = %s length = %d\" %(\"Humpty Dumpty\", len2 )\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "string = Bamboozled length = 10\n",
- "string = Humpty Dumpty length = 13\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>xstrlen Function, Page number: 337<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Function definition\n",
- "def xstrlen(s):\n",
- " length = 0\n",
- " while ( s[length] != '\\0' ):\n",
- " length += 1\n",
- " return length \n",
- "\n",
- "#Variable declaration\n",
- "arr = \"Bamboozled\\0\" # character array or string\n",
- "\n",
- "#Function calls\n",
- "len1 = xstrlen(arr) \n",
- "len2 = xstrlen( \"Humpty Dumpty\\0\" )\n",
- "\n",
- "#Result\n",
- "print \"string = %s length = %d\" %( arr, len1 )\n",
- "print \"string = %s length = %d\" %(\"Humpty Dumpty\\0\", len2 )\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "string = Bamboozled\u0000 length = 10\n",
- "string = Humpty Dumpty\u0000 length = 13\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>strcpy Function, Page number: 338<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "#Variable declaration\n",
- "source = \"Sayonara\" \n",
- "target = [] \n",
- "\n",
- "#strcpy function\n",
- "import copy\n",
- "target = copy.copy(source)\n",
- "\n",
- "#Result\n",
- "print \"source string = \", source \n",
- "print \"target string = \", target \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "source string = Sayonara\n",
- "target string = Sayonara\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>xstrcpy Function, Page number: 339<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Function definition\n",
- "def xstrcpy (t,s):\n",
- " i = 0\n",
- " while ( s[i] != '\\0' ):\n",
- " t = t + s[i]\n",
- " i = i + 1\n",
- " return t\n",
- " \n",
- "#Variable declaration\n",
- "source = \"Sayonara\\0\" \n",
- "target = ''\n",
- "\n",
- "target = xstrcpy ( target, source ) # function call\n",
- "\n",
- "#Result\n",
- "print \"source string = \", source \n",
- "print \"target string = \", target "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "source string = Sayonara\u0000\n",
- "target string = Sayonara\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>strcat Function, Page number: 342<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "source = \"Folks!\" \n",
- "target = \"Hello\"\n",
- " \n",
- "target = target + source # string concatenation\n",
- "#Result\n",
- "print \"source string = \", source \n",
- "print \"target string = \", target \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "source string = Folks!\n",
- "target string = HelloFolks!\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>strcmp Function, Page number: 343<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "string1 = \"Jerry\\0\" \n",
- "string2 = \"Ferry\\0\"\n",
- "\n",
- "#Function definition\n",
- "def strcmp (string1 , string2):\n",
- " if (string1 == string2):\n",
- " v = 0 #If the two strings are identical, strcmp returns a value zero\n",
- " return v\n",
- " else:\n",
- " n = 0\n",
- " while ( string1[n]):\n",
- " if ( string1[n] == string2[n]):\n",
- " n = n + 1\n",
- " continue\n",
- " else:\n",
- " v = ord(string1[n]) - ord(string2[n]) #returns the numeric difference between the ASCII values of the first non-matching pairs of characters\n",
- " return v\n",
- " return v\n",
- "\n",
- "#Function call\n",
- "i = strcmp ( string1, \"Jerry\\0\" ) \n",
- "j = strcmp ( string1, string2 ) \n",
- "k = strcmp ( string1, \"Jerry boy\\0\" )\n",
- "\n",
- "#Result\n",
- "print i,j,k"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0 4 -32\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Two Dimensional Array of Characters, Page number: 344<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "name against a master list to see if you are worthy of\n",
- "\n",
- "\n",
- "#Function definition\n",
- "def strcmp (string1 , string2):\n",
- " if (string1 == string2):\n",
- " v = 0 #If the two strings are identical, strcmp returns a value zero\n",
- " return v\n",
- " else:\n",
- " n = 0\n",
- " while ( string1[n]):\n",
- " if ( string1[n] == string2[n]):\n",
- " n = n + 1\n",
- " continue\n",
- " else:\n",
- " v = ord(string1[n]) - ord(string2[n]) #returns the numeric difference between the ASCII values of the first non-matching pairs of characters\n",
- " return v\n",
- " return v\n",
- "\n",
- "#Variable declaration\n",
- "FOUND = 1\n",
- "NOTFOUND = 0\n",
- "masterlist =[\"akshay\",\"parag\",\"raman\",\"srinivas\",\"gopal\",\"rajesh\"]\n",
- "yourname = []\n",
- "flag = NOTFOUND\n",
- "\n",
- "#Input from user\n",
- "#yourname = raw_input(\"Enter your name: \")\n",
- "yourname = \"Akshatha\"\n",
- "\n",
- "#Checking in the master list\n",
- "for i in range(0,6):\n",
- " a = strcmp ( masterlist[i], yourname )\n",
- " if a == 0:\n",
- " print \"Welcome, you can enter the palace\" \n",
- " flag = FOUND\n",
- " break\n",
- " \n",
- "if flag == NOTFOUND :\n",
- " print \"Sorry, you are a trespasser\" "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sorry, you are a trespasser\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Exchange Names using 2-D Array of Characters, Page number: 348<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "names = [\"akshay\\0\\0\\0\",\"parag\\0\\0\\0\\0\",\"raman\\0\\0\\0\\0\",\"srinivas\\0\",\"gopal\\0\\0\\0\\0\",\"rajesh\\0\\0\\0\"]\n",
- "\n",
- "#Initial condition\n",
- "print \"Original: \", names[2], names[3] \n",
- "\n",
- "#Exchanging names\n",
- "for i in range(0,9):\n",
- " t = names[3][i]\n",
- " names[3] = names[3][0:i] + names[2][i] + names[3][i+1:]\n",
- " names[2] = names[2][0:i] + t + names[2][i+1:]\n",
- " \n",
- "\n",
- "#Result \n",
- "print \"New: \", names[2], names[3] "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Original: raman\u0000\u0000\u0000\u0000 srinivas\u0000\n",
- "New: srinivas\u0000 raman\u0000\u0000\u0000\u0000\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Exchange Names using Array of Pointers to Strings, Page number: 349<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "names = [\"akshay\\0\\0\\0\",\"parag\\0\\0\\0\\0\",\"raman\\0\\0\\0\\0\",\"srinivas\\0\",\"gopal\\0\\0\\0\\0\",\"rajesh\\0\\0\\0\"]\n",
- "\n",
- "#Initial condition\n",
- "print \"Original: \", names[2], names[3] \n",
- "\n",
- "#Exchanging names\n",
- "temp = names[2] \n",
- "names[2] = names[3] \n",
- "names[3] = temp \n",
- "\n",
- "#Result \n",
- "print \"New: \", names[2], names[3] \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Original: raman\u0000\u0000\u0000\u0000 srinivas\u0000\n",
- "New: srinivas\u0000 raman\u0000\u0000\u0000\u0000\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "<h3>Solution, Page number: 351<h3>"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import copy\n",
- "\n",
- "#Variable declaration\n",
- "names = []\n",
- "n=[\"John\",\"Max\",\"Jim\",\"Tony\",\"Tom\",\"Harry\"]\n",
- "\n",
- "for i in range(0,6):\n",
- " n1 = n[i]\n",
- " p = copy.copy(n1)\n",
- " names.append(p) \n",
- "\n",
- "for i in range(0,6):\n",
- " print names[i] \n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "John\n",
- "Max\n",
- "Jim\n",
- "Tony\n",
- "Tom\n",
- "Harry\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:4f09be4d67c9b4aa6b1f97f3788fa85904e9dfc6d52d9f340d60a59f47f71089" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h1>Chapter 9: Puppetting On Strings <h1>" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Print String , Page number: 329<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "name= \"Klinsman\" # character array or string\n", + "i = 0\n", + "\n", + "#while loop for printing\n", + "while i <= 7 :\n", + " print name[i] \n", + " i = i + 1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "K\n", + "l\n", + "i\n", + "n\n", + "s\n", + "m\n", + "a\n", + "n\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Print String, Page number: 330<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "name= \"Klinsman\\0\" # character array or string\n", + "i = 0\n", + "\n", + "#while loop for printing\n", + "while (name[i] != '\\0') :\n", + " print name[i]\n", + " i = i + 1\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "K\n", + "l\n", + "i\n", + "n\n", + "s\n", + "m\n", + "a\n", + "n\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Print String Using Pointer, Page number: 330<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "name = \"Klinsman\\0\" # string or character array\n", + "i = 0\n", + "ptr = name[i] # store base address of string\n", + "\n", + "#Result\n", + "while ptr != '\\0':\n", + " print ptr\n", + " i = i+1\n", + " ptr = name[i]\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "K\n", + "l\n", + "i\n", + "n\n", + "s\n", + "m\n", + "a\n", + "n\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>strlen Function, Page number: 336<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#Variable declaration\n", + "arr = \"Bamboozled\" # character array or string\n", + "\n", + "#string length function\n", + "len1 = len(arr) \n", + "len2 = len( \"Humpty Dumpty\" )\n", + "\n", + "#Result\n", + "print \"string = %s length = %d\" %( arr, len1 )\n", + "print \"string = %s length = %d\" %(\"Humpty Dumpty\", len2 )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "string = Bamboozled length = 10\n", + "string = Humpty Dumpty length = 13\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>xstrlen Function, Page number: 337<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Function definition\n", + "def xstrlen(s):\n", + " length = 0\n", + " while ( s[length] != '\\0' ):\n", + " length += 1\n", + " return length \n", + "\n", + "#Variable declaration\n", + "arr = \"Bamboozled\\0\" # character array or string\n", + "\n", + "#Function calls\n", + "len1 = xstrlen(arr) \n", + "len2 = xstrlen( \"Humpty Dumpty\\0\" )\n", + "\n", + "#Result\n", + "print \"string = %s length = %d\" %( arr, len1 )\n", + "print \"string = %s length = %d\" %(\"Humpty Dumpty\\0\", len2 )\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "string = Bamboozled\u0000 length = 10\n", + "string = Humpty Dumpty\u0000 length = 13\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>strcpy Function, Page number: 338<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#Variable declaration\n", + "source = \"Sayonara\" \n", + "target = [] \n", + "\n", + "#strcpy function\n", + "import copy\n", + "target = copy.copy(source)\n", + "\n", + "#Result\n", + "print \"source string = \", source \n", + "print \"target string = \", target \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "source string = Sayonara\n", + "target string = Sayonara\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>xstrcpy Function, Page number: 339<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Function definition\n", + "def xstrcpy (t,s):\n", + " i = 0\n", + " while ( s[i] != '\\0' ):\n", + " t = t + s[i]\n", + " i = i + 1\n", + " return t\n", + " \n", + "#Variable declaration\n", + "source = \"Sayonara\\0\" \n", + "target = ''\n", + "\n", + "target = xstrcpy ( target, source ) # function call\n", + "\n", + "#Result\n", + "print \"source string = \", source \n", + "print \"target string = \", target " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "source string = Sayonara\u0000\n", + "target string = Sayonara\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>strcat Function, Page number: 342<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "source = \"Folks!\" \n", + "target = \"Hello\"\n", + " \n", + "target = target + source # string concatenation\n", + "#Result\n", + "print \"source string = \", source \n", + "print \"target string = \", target \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "source string = Folks!\n", + "target string = HelloFolks!\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>strcmp Function, Page number: 343<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "string1 = \"Jerry\\0\" \n", + "string2 = \"Ferry\\0\"\n", + "\n", + "#Function definition\n", + "def strcmp (string1 , string2):\n", + " if (string1 == string2):\n", + " v = 0 #If the two strings are identical, strcmp returns a value zero\n", + " return v\n", + " else:\n", + " n = 0\n", + " while ( string1[n]):\n", + " if ( string1[n] == string2[n]):\n", + " n = n + 1\n", + " continue\n", + " else:\n", + " v = ord(string1[n]) - ord(string2[n]) #returns the numeric difference between the ASCII values of the first non-matching pairs of characters\n", + " return v\n", + " return v\n", + "\n", + "#Function call\n", + "i = strcmp ( string1, \"Jerry\\0\" ) \n", + "j = strcmp ( string1, string2 ) \n", + "k = strcmp ( string1, \"Jerry boy\\0\" )\n", + "\n", + "#Result\n", + "print i,j,k" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "0 4 -32\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Two Dimensional Array of Characters, Page number: 344<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "\n", + "#Function definition\n", + "def strcmp (string1 , string2):\n", + " if (string1 == string2):\n", + " v = 0 #If the two strings are identical, strcmp returns a value zero\n", + " return v\n", + " else:\n", + " n = 0\n", + " while ( string1[n]):\n", + " if ( string1[n] == string2[n]):\n", + " n = n + 1\n", + " continue\n", + " else:\n", + " v = ord(string1[n]) - ord(string2[n]) #returns the numeric difference between the ASCII values of the first non-matching pairs of characters\n", + " return v\n", + " return v\n", + "\n", + "#Variable declaration\n", + "FOUND = 1\n", + "NOTFOUND = 0\n", + "masterlist =[\"akshay\",\"parag\",\"raman\",\"srinivas\",\"gopal\",\"rajesh\"]\n", + "yourname = []\n", + "flag = NOTFOUND\n", + "\n", + "#Input from user\n", + "#yourname = raw_input(\"Enter your name: \")\n", + "yourname = \"Akshatha\"\n", + "\n", + "#Checking in the master list\n", + "for i in range(0,6):\n", + " a = strcmp ( masterlist[i], yourname )\n", + " if a == 0:\n", + " print \"Welcome, you can enter the palace\" \n", + " flag = FOUND\n", + " break\n", + " \n", + "if flag == NOTFOUND :\n", + " print \"Sorry, you are a trespasser\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry, you are a trespasser\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Exchange Names using 2-D Array of Characters, Page number: 348<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "names = [\"akshay\\0\\0\\0\",\"parag\\0\\0\\0\\0\",\"raman\\0\\0\\0\\0\",\"srinivas\\0\",\"gopal\\0\\0\\0\\0\",\"rajesh\\0\\0\\0\"]\n", + "\n", + "#Initial condition\n", + "print \"Original: \", names[2], names[3] \n", + "\n", + "#Exchanging names\n", + "for i in range(0,9):\n", + " t = names[3][i]\n", + " names[3] = names[3][0:i] + names[2][i] + names[3][i+1:]\n", + " names[2] = names[2][0:i] + t + names[2][i+1:]\n", + " \n", + "\n", + "#Result \n", + "print \"New: \", names[2], names[3] " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Original: raman\u0000\u0000\u0000\u0000 srinivas\u0000\n", + "New: srinivas\u0000 raman\u0000\u0000\u0000\u0000\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Exchange Names using Array of Pointers to Strings, Page number: 349<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "names = [\"akshay\\0\\0\\0\",\"parag\\0\\0\\0\\0\",\"raman\\0\\0\\0\\0\",\"srinivas\\0\",\"gopal\\0\\0\\0\\0\",\"rajesh\\0\\0\\0\"]\n", + "\n", + "#Initial condition\n", + "print \"Original: \", names[2], names[3] \n", + "\n", + "#Exchanging names\n", + "temp = names[2] \n", + "names[2] = names[3] \n", + "names[3] = temp \n", + "\n", + "#Result \n", + "print \"New: \", names[2], names[3] \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Original: raman\u0000\u0000\u0000\u0000 srinivas\u0000\n", + "New: srinivas\u0000 raman\u0000\u0000\u0000\u0000\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<h3>Solution, Page number: 351<h3>" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import copy\n", + "\n", + "#Variable declaration\n", + "names = []\n", + "n=[\"John\",\"Max\",\"Jim\",\"Tony\",\"Tom\",\"Harry\"]\n", + "\n", + "for i in range(0,6):\n", + " n1 = n[i]\n", + " p = copy.copy(n1)\n", + " names.append(p) \n", + "\n", + "for i in range(0,6):\n", + " print names[i] \n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "John\n", + "Max\n", + "Jim\n", + "Tony\n", + "Tom\n", + "Harry\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Mechanics_of_Materials/chapter6.ipynb b/Mechanics_of_Materials/chapter6.ipynb index 611851ab..abed2b92 100644 --- a/Mechanics_of_Materials/chapter6.ipynb +++ b/Mechanics_of_Materials/chapter6.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:19ad2940f302eb9e5e16b3155aded36e0654d4a04f790dfd2d797d83e5d7886f" + "signature": "sha256:6b805af6437b1e35c2a86410c53cf433b859c30c76e14feb211f91f3f6b4d2d7" }, "nbformat": 3, "nbformat_minor": 0, @@ -31,9 +31,7 @@ "\n", "import math \n", "\n", - "#initialisation\n", - "# 4*6 inch wood beam dimension\n", - "# 4*0.5 inch steel beam dimension\n", + "\n", "M = 60.0 # Moment in k-in\n", "E1 = 1500. # in Ksi\n", "E2 = 30000.0 # in Ksi\n", @@ -155,9 +153,6 @@ "\n", "import math \n", "\n", - "#initialisation\n", - "# 4*6 inch wood beam dimension\n", - "# 4*0.5 inch steel beam dimension\n", "M = 60.0 # Moment in k-in\n", "E1 = 1500.0 # in Ksi\n", "E2 = 30000.0 # in Ksi\n", diff --git a/Mechanics_of_Materials/chapter7.ipynb b/Mechanics_of_Materials/chapter7.ipynb index 57556b9c..3bf957bb 100644 --- a/Mechanics_of_Materials/chapter7.ipynb +++ b/Mechanics_of_Materials/chapter7.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:4b150feddb9dc8fb4618b52384e38cf0a1bb69c134a6face9686f115e6bbaa31" + "signature": "sha256:79553db761abdf4228d341c670873d408edd8ca0894b0f7f1ee9a5c598382141" }, "nbformat": 3, "nbformat_minor": 0, @@ -32,8 +32,6 @@ "\n", "import math \n", "\n", - "#initialisation\n", - "# Let x1, y1 be the transformed direction inclined at 45 deegree to the original\n", "sx = 16000 # Direct stress in x-direction in psi\n", "sy = 6000 # Direct stress in y-direction \"\"\n", "txy = 4000 # Shear stress in y-direction \"\"\n", @@ -80,8 +78,6 @@ "\n", "import math \n", "\n", - "#initialisation\n", - "# Let x1, y1 be the transformed direction inclined at 15 deegree to the original\n", "sx = -46e06 # Direct stress in x-direction in Pa\n", "sy = 12e06 # Direct stress in y-direction \"\"\n", "txy = -19e06 # Shear stress in y-direction \"\"\n", diff --git a/Microwave_and_Radar_Engineering/Chapter_3.ipynb b/Microwave_and_Radar_Engineering/Chapter_3.ipynb index 033e0551..116264a3 100644 --- a/Microwave_and_Radar_Engineering/Chapter_3.ipynb +++ b/Microwave_and_Radar_Engineering/Chapter_3.ipynb @@ -1,535 +1,531 @@ -{
- "metadata": {
- "name": "Chapter 3"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 3: Transmission Lines"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example number 3.1, Page number 47"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "Zo = 100 #o/p impedance(Ohms)\n",
- "s = 5 #VSWR\n",
- "\n",
- "#Calculations\n",
- "Zmax = Zo*s\n",
- "\n",
- "#Results\n",
- "print \"Terminating impedance = \",Zmax,\"Ohms\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Terminating impedance = 500 Ohms\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.2, Page number 47"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "import cmath\n",
- "\n",
- "#Varaible declaration \n",
- "R = 8 #resistance(Ohms)\n",
- "L = 2*10**-3 #inductance(H/km)\n",
- "C = 0.002*10**-6 #capacitance(F)\n",
- "G = 0.07*10**-6 #conductance(s/km)\n",
- "f = 2*10**3 #frequency(Hz)\n",
- "Vs = 2 #input signal(V)\n",
- "l = 500. #line length(km)\n",
- "\n",
- "#Calculations\n",
- "w = 2*math.pi*f\n",
- "x = complex(R,w*L)\n",
- "y = complex(G,w*C)\n",
- "Zo = cmath.sqrt(x/y)\n",
- "gamma = cmath.sqrt(x*y)\n",
- "Is = Vs/Zo.real\n",
- "Il = Is*cmath.exp(-1*gamma*l)\n",
- "P = Il**2*Zo.real\n",
- "\n",
- "#Results\n",
- "print \"Characteristic impedance =\",Zo,\"Ohms\"\n",
- "print \"Attenuation constant =\",round(gamma.real,6),\"NP/km\"\n",
- "print \"Phase constant =\", round(gamma.imag,6),\"rad/km\"\n",
- "print \"Power delivered to the load =\", round((abs(P)/1E-6),2), \"uW\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Characteristic impedance = (1012.50018135-155.813417548j) Ohms\n",
- "Attenuation constant = 0.003987 NP/km\n",
- "Phase constant = 0.025436 rad/km\n",
- "Power delivered to the load = 73.31 uW\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.3, Page number 48"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "\n",
- "#Varaible declaration\n",
- "f = 2*10**3 #frequency(Hz)\n",
- "B = 0.02543 #phase constant(rad/km)\n",
- "\n",
- "#Calculations\n",
- "w = 2*math.pi*f\n",
- "Vp = w/B\n",
- "\n",
- "#Results\n",
- "print \"Phase velocity =\",round((Vp/1E+3),2),\"km/sec\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Phase velocity = 494.16 km/sec\n"
- ]
- }
- ],
- "prompt_number": 24
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.4, Page number 48"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a) Current drawn from generator\n",
- "b) Power delivered to the load\n",
- "\n",
- "import cmath\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "f = 37.5*10**6 #frequency(Hz)\n",
- "V = 200 #Voltage signal(Vrms)\n",
- "r = 200 #internal resistance(Ohms)\n",
- "Zo = 200 #characteristic impedance(Ohms)\n",
- "l = 10 #line length(m)\n",
- "Zl = 100 #resistive load(Ohms)\n",
- "c = 3*10**8 #velocity of propagation(m/s)\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "lamda = c/f\n",
- "Bl = (5*math.degrees(math.pi))/4\n",
- "x = complex(Zl,(Zo*math.tan(Bl)))\n",
- "y = complex(Zo,(Zl*math.tan(Bl)))\n",
- "Zi = Zo*(x/y)\n",
- "Vs = (Zi.real*Zo)/(Zi.real+Zo)\n",
- "Is = Zo/(Zi.real+Zo)\n",
- "\n",
- "#Part b\n",
- "P = Vs*Is\n",
- "\n",
- "#Part c\n",
- "Il = math.sqrt(P/Zl)\n",
- "\n",
- "#Results\n",
- "print \"Please note that the solution given in the textbook is incorrect.Hence the difference in answers\\n\"\n",
- "print \"Current drawn from generator is\",round(Is,2),\"A\" \n",
- "print \"Power delivered to the load is\",round(P,2),\"W\"\n",
- "print \"Current flowing through the load is\",round(Il,3),\"A\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Please note that the solution given in the textbook is incorrect.Hence the difference in answers\n",
- "\n",
- "Current drawn from generator is 0.41 A\n",
- "Power delivered to the load is 48.47 W\n",
- "Current flowing through the load is 0.696 A\n"
- ]
- }
- ],
- "prompt_number": 35
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.5, Page number 50"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import cmath\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "zo = 50 #characteristic impedance(Ohms)\n",
- "f = 300*10**6 #frequency(Hz)\n",
- "zl = complex(50,50) #terminating load(Ohms)\n",
- "c = 3*10**8 #velocity of propagation(m/s)\n",
- "\n",
- "#Calculations\n",
- "lamda = c/f\n",
- "rho = (zl-zo)/(zl+zo)\n",
- "phi = cmath.phase(rho)\n",
- "s = (1+abs(rho))/(1-abs(rho))\n",
- "\n",
- "#Results\n",
- "print \"Reflection co-efficient =\",round(abs(rho),3),\"with phase =\",round(math.degrees(phi),2)\n",
- "print \"VSWR =\",round(s,2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Reflection co-efficient = 0.447 with phase = 63.43\n",
- "VSWR = 2.62\n"
- ]
- }
- ],
- "prompt_number": 46
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.6, Page number 50"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "Zl = 100. #load resistance(Ohms)\n",
- "Zo = 600. #characteristic impedance(Ohms)\n",
- "f = 100*10**6 #frequency(Hz)\n",
- "c = 3*10**8 #velocity of propagation(m/s)\n",
- "\n",
- "#Calculations\n",
- "lamda = c/f\n",
- "l = (lamda*math.atan(math.sqrt(Zl/Zo)))/(2*math.pi)\n",
- "l_dash = (lamda*math.atan(math.sqrt((Zl*Zo)/(Zo-Zl))))/(2*math.pi)\n",
- "\n",
- "#Results\n",
- "print \"The position of the stub is\", round(l,3),\"m\\n\"\n",
- "print \"Please note that the solution for l_dash given in the textbook is incorrect\"\n",
- "print \"Length of stub is\",round(l_dash,3),\"m\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The position of the stub is 0.185 m\n",
- "\n",
- "Please note that the solution for l_dash given in the textbook is incorrect\n",
- "Length of stub is 0.707 m\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.7, Page number 50"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import cmath\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "s = 3.2 #VSWR\n",
- "Xmin = 0.237 #minimum voltage(V)\n",
- "Zo = 50 #characteristic impedance(Ohms)\n",
- "\n",
- "#Calculations\n",
- "q = math.tan(math.degrees(2*math.pi*Xmin))\n",
- "x = complex(1,-(s*q))\n",
- "y = complex(s, -q)\n",
- "Zl = Zo*(x/y)\n",
- "\n",
- "#Result\n",
- "print \"Please note that the solution given in the textbook is incorrect.Hence the difference in answers\\n\"\n",
- "print \"Terminating impedance =\", Zl,\"Ohms\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Please note that the solution given in the textbook is incorrect.Hence the difference in answers\n",
- "\n",
- "Terminating impedance = (19.6572514629-23.7885950214j) Ohms\n"
- ]
- }
- ],
- "prompt_number": 27
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.8, Page number 51"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)VSWR\n",
- "b) Position of first Vmin and Vmax\n",
- "c) Vmin and Vmax\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "Zo = 50. #characteristic impedance(Ohms)\n",
- "Zl = 100. #load resistance(Ohms)\n",
- "f = 300*10**3 #frequency(Hz)\n",
- "Pl = 50*10**-3 #load power(W)\n",
- "c = 3*10**8 #velocity of propagation(m/s)\n",
- "\n",
- "#Calculations\n",
- "lamda = c/f\n",
- "\n",
- "#Part a\n",
- "rho = (Zl-Zo)/(Zl+Zo)\n",
- "s = (1+abs(rho))/(1-abs(rho))\n",
- "\n",
- "#Part b\n",
- "#Since real Zl>Zo, first Vmax is located at the load\n",
- "Vmin_pos = lamda/4\n",
- "\n",
- "#Part c\n",
- "Vmax = math.sqrt(Pl*Zl)\n",
- "Vmin = Vmax/s\n",
- "\n",
- "#Part d\n",
- "Zin_at_Vmin = Zo/s\n",
- "Zin_at_Vmax = Zo*s\n",
- "\n",
- "\n",
- "#Results\n",
- "print \"VSWR = \", s\n",
- "print \"First Vmax is loacted at load and first Vmin is located at\", Vmin_pos,\"m from the load\"\n",
- "print \"Vmin = \",round(Vmin,2),\"V and Vmax = \",round(Vmax,2),\"V\"\n",
- "print \"Impedance at Vmin is \", Zin_at_Vmin,\"Ohm and impedance at Vmax is\",Zin_at_Vmax,\"Ohm\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "VSWR = 2.0\n",
- "First Vmax is loacted at load and first Vmin is located at 250 m from the load\n",
- "Vmin = 1.12 V and Vmax = 2.24 V\n",
- "Impedance at Vmin is 25.0 Ohm and impedance at Vmax is 100.0 Ohm\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.9, Page number 52"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)Transmission loss\n",
- "b)Reflection loss\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "Zo = 600. #characteristic impedance(Ohms)\n",
- "Zs = 50 #source impedance(Ohms)\n",
- "l = 200 #length of line(m)\n",
- "Zl = 500. #load resistance(Ohms)\n",
- "\n",
- "#Calculations\n",
- "rho = (Zl-Zo)/(Zl+Zo)\n",
- "\n",
- "#Part a\n",
- "ref_l = math.log10(1/(1-((abs(rho))**2)))\n",
- "\n",
- "#Part b\n",
- "#Since, the line is lossless,\n",
- "att_l = 0\n",
- "trans_l = ref_l+att_l\n",
- "\n",
- "#Part c\n",
- "ret_l = math.log10(abs(rho))\n",
- "\n",
- "#Results\n",
- "print \"Reflection loss =\",round(ref_l,4),\"dB\"\n",
- "print \"Transmission loss =\",round(trans_l,4),\"dB\"\n",
- "print \"Return loss =\",round(ret_l,3),\"dB (Calculation error in the textbook)\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Reflection loss = 0.0036 dB\n",
- "Transmission loss = 0.0036 dB\n",
- "Return loss = -1.041 dB (Calculation error in the textbook)\n"
- ]
- }
- ],
- "prompt_number": 55
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.10, Page number 52"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import cmath\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "l = 10 #length of line(km)\n",
- "zsc = complex(1895.47,2234.29) \n",
- "zoc = complex(216.99,-143.37)\n",
- "f = 1*10**3 #frequency(Hz)\n",
- "\n",
- "#Calculations\n",
- "zo = cmath.sqrt(zsc*zoc)\n",
- "x = cmath.sqrt(zsc/zoc)\n",
- "t = (1+x)/(1-x)\n",
- "gamma = cmath.log(t)/(l*2)\n",
- "B = gamma.imag\n",
- "w = 2*math.pi*f\n",
- "Vp = w/B\n",
- "\n",
- "#Results\n",
- "print \"There is calculation mistake throughout the problem in the textbook\\n\"\n",
- "print \"Characteristic impedance =\",zo,\"Ohms\"\n",
- "print \"Phase velocity =\",round((Vp/1E+3),3),\"*10^3 m/sec\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "There is calculation mistake throughout the problem in the textbook\n",
- "\n",
- "Characteristic impedance = (864.190238563+123.274392427j) Ohms\n",
- "Phase velocity = 45.994 *10^3 m/sec\n"
- ]
- }
- ],
- "prompt_number": 27
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:dfa1112ea6b0d370508845e5b6861c8e0c5d67e82e0a759d3e8e0f96252d9846" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 3: Transmission Lines" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example number 3.1, Page number 47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "Zo = 100 #o/p impedance(Ohms)\n", + "s = 5 #VSWR\n", + "\n", + "#Calculations\n", + "Zmax = Zo*s\n", + "\n", + "#Results\n", + "print \"Terminating impedance = \",Zmax,\"Ohms\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Terminating impedance = 500 Ohms\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.2, Page number 47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "import cmath\n", + "\n", + "#Varaible declaration \n", + "R = 8 #resistance(Ohms)\n", + "L = 2*10**-3 #inductance(H/km)\n", + "C = 0.002*10**-6 #capacitance(F)\n", + "G = 0.07*10**-6 #conductance(s/km)\n", + "f = 2*10**3 #frequency(Hz)\n", + "Vs = 2 #input signal(V)\n", + "l = 500. #line length(km)\n", + "\n", + "#Calculations\n", + "w = 2*math.pi*f\n", + "x = complex(R,w*L)\n", + "y = complex(G,w*C)\n", + "Zo = cmath.sqrt(x/y)\n", + "gamma = cmath.sqrt(x*y)\n", + "Is = Vs/Zo.real\n", + "Il = Is*cmath.exp(-1*gamma*l)\n", + "P = Il**2*Zo.real\n", + "\n", + "#Results\n", + "print \"Characteristic impedance =\",Zo,\"Ohms\"\n", + "print \"Attenuation constant =\",round(gamma.real,6),\"NP/km\"\n", + "print \"Phase constant =\", round(gamma.imag,6),\"rad/km\"\n", + "print \"Power delivered to the load =\", round((abs(P)/1E-6),2), \"uW\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Characteristic impedance = (1012.50018135-155.813417548j) Ohms\n", + "Attenuation constant = 0.003987 NP/km\n", + "Phase constant = 0.025436 rad/km\n", + "Power delivered to the load = 73.31 uW\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.3, Page number 48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "\n", + "#Varaible declaration\n", + "f = 2*10**3 #frequency(Hz)\n", + "B = 0.02543 #phase constant(rad/km)\n", + "\n", + "#Calculations\n", + "w = 2*math.pi*f\n", + "Vp = w/B\n", + "\n", + "#Results\n", + "print \"Phase velocity =\",round((Vp/1E+3),2),\"km/sec\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Phase velocity = 494.16 km/sec\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.4, Page number 48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import cmath\n", + "import math\n", + "\n", + "#Variable declaration\n", + "f = 37.5*10**6 #frequency(Hz)\n", + "V = 200 #Voltage signal(Vrms)\n", + "r = 200 #internal resistance(Ohms)\n", + "Zo = 200 #characteristic impedance(Ohms)\n", + "l = 10 #line length(m)\n", + "Zl = 100 #resistive load(Ohms)\n", + "c = 3*10**8 #velocity of propagation(m/s)\n", + "\n", + "#Calculations\n", + "#Part a\n", + "lamda = c/f\n", + "Bl = (5*math.degrees(math.pi))/4\n", + "x = complex(Zl,(Zo*math.tan(Bl)))\n", + "y = complex(Zo,(Zl*math.tan(Bl)))\n", + "Zi = Zo*(x/y)\n", + "Vs = (Zi.real*Zo)/(Zi.real+Zo)\n", + "Is = Zo/(Zi.real+Zo)\n", + "\n", + "#Part b\n", + "P = Vs*Is\n", + "\n", + "#Part c\n", + "Il = math.sqrt(P/Zl)\n", + "\n", + "#Results\n", + "print \"Please note that the solution given in the textbook is incorrect.Hence the difference in answers\\n\"\n", + "print \"Current drawn from generator is\",round(Is,2),\"A\" \n", + "print \"Power delivered to the load is\",round(P,2),\"W\"\n", + "print \"Current flowing through the load is\",round(Il,3),\"A\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please note that the solution given in the textbook is incorrect.Hence the difference in answers\n", + "\n", + "Current drawn from generator is 0.41 A\n", + "Power delivered to the load is 48.47 W\n", + "Current flowing through the load is 0.696 A\n" + ] + } + ], + "prompt_number": 35 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.5, Page number 50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import cmath\n", + "import math\n", + "\n", + "#Variable declaration\n", + "zo = 50 #characteristic impedance(Ohms)\n", + "f = 300*10**6 #frequency(Hz)\n", + "zl = complex(50,50) #terminating load(Ohms)\n", + "c = 3*10**8 #velocity of propagation(m/s)\n", + "\n", + "#Calculations\n", + "lamda = c/f\n", + "rho = (zl-zo)/(zl+zo)\n", + "phi = cmath.phase(rho)\n", + "s = (1+abs(rho))/(1-abs(rho))\n", + "\n", + "#Results\n", + "print \"Reflection co-efficient =\",round(abs(rho),3),\"with phase =\",round(math.degrees(phi),2)\n", + "print \"VSWR =\",round(s,2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Reflection co-efficient = 0.447 with phase = 63.43\n", + "VSWR = 2.62\n" + ] + } + ], + "prompt_number": 46 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.6, Page number 50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Zl = 100. #load resistance(Ohms)\n", + "Zo = 600. #characteristic impedance(Ohms)\n", + "f = 100*10**6 #frequency(Hz)\n", + "c = 3*10**8 #velocity of propagation(m/s)\n", + "\n", + "#Calculations\n", + "lamda = c/f\n", + "l = (lamda*math.atan(math.sqrt(Zl/Zo)))/(2*math.pi)\n", + "l_dash = (lamda*math.atan(math.sqrt((Zl*Zo)/(Zo-Zl))))/(2*math.pi)\n", + "\n", + "#Results\n", + "print \"The position of the stub is\", round(l,3),\"m\\n\"\n", + "print \"Please note that the solution for l_dash given in the textbook is incorrect\"\n", + "print \"Length of stub is\",round(l_dash,3),\"m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The position of the stub is 0.185 m\n", + "\n", + "Please note that the solution for l_dash given in the textbook is incorrect\n", + "Length of stub is 0.707 m\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.7, Page number 50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import cmath\n", + "import math\n", + "\n", + "#Variable declaration\n", + "s = 3.2 #VSWR\n", + "Xmin = 0.237 #minimum voltage(V)\n", + "Zo = 50 #characteristic impedance(Ohms)\n", + "\n", + "#Calculations\n", + "q = math.tan(math.degrees(2*math.pi*Xmin))\n", + "x = complex(1,-(s*q))\n", + "y = complex(s, -q)\n", + "Zl = Zo*(x/y)\n", + "\n", + "#Result\n", + "print \"Please note that the solution given in the textbook is incorrect.Hence the difference in answers\\n\"\n", + "print \"Terminating impedance =\", Zl,\"Ohms\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please note that the solution given in the textbook is incorrect.Hence the difference in answers\n", + "\n", + "Terminating impedance = (19.6572514629-23.7885950214j) Ohms\n" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.8, Page number 51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Zo = 50. #characteristic impedance(Ohms)\n", + "Zl = 100. #load resistance(Ohms)\n", + "f = 300*10**3 #frequency(Hz)\n", + "Pl = 50*10**-3 #load power(W)\n", + "c = 3*10**8 #velocity of propagation(m/s)\n", + "\n", + "#Calculations\n", + "lamda = c/f\n", + "\n", + "#Part a\n", + "rho = (Zl-Zo)/(Zl+Zo)\n", + "s = (1+abs(rho))/(1-abs(rho))\n", + "\n", + "#Part b\n", + "#Since real Zl>Zo, first Vmax is located at the load\n", + "Vmin_pos = lamda/4\n", + "\n", + "#Part c\n", + "Vmax = math.sqrt(Pl*Zl)\n", + "Vmin = Vmax/s\n", + "\n", + "#Part d\n", + "Zin_at_Vmin = Zo/s\n", + "Zin_at_Vmax = Zo*s\n", + "\n", + "\n", + "#Results\n", + "print \"VSWR = \", s\n", + "print \"First Vmax is loacted at load and first Vmin is located at\", Vmin_pos,\"m from the load\"\n", + "print \"Vmin = \",round(Vmin,2),\"V and Vmax = \",round(Vmax,2),\"V\"\n", + "print \"Impedance at Vmin is \", Zin_at_Vmin,\"Ohm and impedance at Vmax is\",Zin_at_Vmax,\"Ohm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "VSWR = 2.0\n", + "First Vmax is loacted at load and first Vmin is located at 250 m from the load\n", + "Vmin = 1.12 V and Vmax = 2.24 V\n", + "Impedance at Vmin is 25.0 Ohm and impedance at Vmax is 100.0 Ohm\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.9, Page number 52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Zo = 600. #characteristic impedance(Ohms)\n", + "Zs = 50 #source impedance(Ohms)\n", + "l = 200 #length of line(m)\n", + "Zl = 500. #load resistance(Ohms)\n", + "\n", + "#Calculations\n", + "rho = (Zl-Zo)/(Zl+Zo)\n", + "\n", + "#Part a\n", + "ref_l = math.log10(1/(1-((abs(rho))**2)))\n", + "\n", + "#Part b\n", + "#Since, the line is lossless,\n", + "att_l = 0\n", + "trans_l = ref_l+att_l\n", + "\n", + "#Part c\n", + "ret_l = math.log10(abs(rho))\n", + "\n", + "#Results\n", + "print \"Reflection loss =\",round(ref_l,4),\"dB\"\n", + "print \"Transmission loss =\",round(trans_l,4),\"dB\"\n", + "print \"Return loss =\",round(ret_l,3),\"dB (Calculation error in the textbook)\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reflection loss = 0.0036 dB\n", + "Transmission loss = 0.0036 dB\n", + "Return loss = -1.041 dB (Calculation error in the textbook)\n" + ] + } + ], + "prompt_number": 55 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.10, Page number 52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import cmath\n", + "import math\n", + "\n", + "#Variable declaration\n", + "l = 10 #length of line(km)\n", + "zsc = complex(1895.47,2234.29) \n", + "zoc = complex(216.99,-143.37)\n", + "f = 1*10**3 #frequency(Hz)\n", + "\n", + "#Calculations\n", + "zo = cmath.sqrt(zsc*zoc)\n", + "x = cmath.sqrt(zsc/zoc)\n", + "t = (1+x)/(1-x)\n", + "gamma = cmath.log(t)/(l*2)\n", + "B = gamma.imag\n", + "w = 2*math.pi*f\n", + "Vp = w/B\n", + "\n", + "#Results\n", + "print \"There is calculation mistake throughout the problem in the textbook\\n\"\n", + "print \"Characteristic impedance =\",zo,\"Ohms\"\n", + "print \"Phase velocity =\",round((Vp/1E+3),3),\"*10^3 m/sec\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "There is calculation mistake throughout the problem in the textbook\n", + "\n", + "Characteristic impedance = (864.190238563+123.274392427j) Ohms\n", + "Phase velocity = 45.994 *10^3 m/sec\n" + ] + } + ], + "prompt_number": 27 + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Microwave_and_Radar_Engineering/Chapter_4.ipynb b/Microwave_and_Radar_Engineering/Chapter_4.ipynb index 24431e97..05272d36 100644 --- a/Microwave_and_Radar_Engineering/Chapter_4.ipynb +++ b/Microwave_and_Radar_Engineering/Chapter_4.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:fddff29c571385d7ad533c0da8d46227c19589926b0642ffe1126b7caf1c9ca6" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,9 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "a)Inductance per unit length\n", - "b)Capacitance per unit lengh\n", - "c)Characteristic impedance\n", + "\n", "\n", "import math\n", "\n", @@ -223,8 +222,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "a)Characteristic impedance\n", - "b)Dielectric constant\n", + "\n", "\n", "import math\n", "\n", @@ -293,7 +291,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "a) TE wave is propagated\n", + "\n", "\n", "import math\n", "\n", @@ -439,8 +437,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "a)possible modes\n", - "b)cut-off frequencies\n", + "\n", "\n", "import math\n", "\n", @@ -504,7 +501,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "a)the required size of cross setional area of the guide\n", + "\n", "\n", "import math\n", "\n", @@ -602,8 +599,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "a)cut-off wavelength\n", - "b)cut-off frequency\n", "\n", "import math\n", "\n", diff --git a/Microwave_and_Radar_Engineering/Chapter_5.ipynb b/Microwave_and_Radar_Engineering/Chapter_5.ipynb index 111d3a6e..dae9fa40 100644 --- a/Microwave_and_Radar_Engineering/Chapter_5.ipynb +++ b/Microwave_and_Radar_Engineering/Chapter_5.ipynb @@ -1,196 +1,193 @@ -{
- "metadata": {
- "name": "Chapter 5"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chpater 5:Cavity Resonators"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.1, Page number 174"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "a = 3 #radius of circular waveguide(cm)\n",
- "fo = 10*10**9 #frequency for TM011 mode(Hz)\n",
- "P01 = 2.405\n",
- "c = 3*10**10 #velocity of proapagation(m/s)\n",
- "\n",
- "#Calculation\n",
- "d = math.sqrt((math.pi**2)/(((4*math.pi**2)/9)-((P01/a)**2)))\n",
- "\n",
- "#Result\n",
- "print \"The minimum distance between two plates is\",round(d,2),\"cms\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The minimum distance between two plates is 1.62 cms\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.2, Page number 174"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "#dimensions of resonator\n",
- "a = 2.\n",
- "b = 1.\n",
- "d = 3.\n",
- "#For dominant mode TE101,\n",
- "m = 1.\n",
- "n = 0\n",
- "p = 1.\n",
- "\n",
- "c = 3*10**10 #velocity of propagation(m/s)\n",
- "\n",
- "#Calculation\n",
- "fo = (c/2)*(((m/a)**2+(n/b)**2+(p/d)**2))**0.5\n",
- "\n",
- "#Result\n",
- "print \"The lowest resonating frequency of a rectangular cavity resonator is\",round((fo/1E+9),2),\"Ghz\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The lowest resonating frequency of a rectangular cavity resonator is 9.01 Ghz\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.3, Page number 175"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "D = 12.5 #diameter of resonator(cm)\n",
- "d = 5 #length of resonator(cm)\n",
- "P01 = 2.405 #dominant mode TM01\n",
- "c = 3*10**10 #velocity of propagation(m/s)\n",
- "\n",
- "#For TM012 mode,\n",
- "m = 1\n",
- "n = 0\n",
- "p = 2\n",
- "\n",
- "#Calculation\n",
- "a = D/2\n",
- "fo = (c/(2*math.pi))*((P01/a)**2+((p*math.pi)/d)**2)**0.5\n",
- "\n",
- "#Result\n",
- "print \"The resonanat frequency of a circular resonator is\",round((fo/1E+9),2),\"GHz\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The resonanat frequency of a circular resonator is 6.27 GHz\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.4, Page number 175"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "#dimensions of resonator\n",
- "a = 3.\n",
- "b = 2.\n",
- "d = 4.\n",
- "#For dominant mode TE101,\n",
- "m = 1.\n",
- "n = 0\n",
- "p = 1.\n",
- "\n",
- "c = 3*10**10 #velocity of propagation(m/s)\n",
- "\n",
- "#Calculation\n",
- "fo = (c/2)*(((m/a)**2+(n/b)**2+(p/d)**2))**0.5\n",
- "\n",
- "#Result\n",
- "print \"The lowest resonating frequency of a circular resonator is\",round((fo/1E+9),2),\"Ghz\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The lowest resonating frequency of a circular resonator is 6.25 Ghz\n"
- ]
- }
- ],
- "prompt_number": 15
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:2fe50082340642dd8429d3545371d7b4c451ffac9b445487719541932115a705" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chpater 5:Cavity Resonators" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.1, Page number 174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "a = 3 #radius of circular waveguide(cm)\n", + "fo = 10*10**9 #frequency for TM011 mode(Hz)\n", + "P01 = 2.405\n", + "c = 3*10**10 #velocity of proapagation(m/s)\n", + "\n", + "#Calculation\n", + "d = math.sqrt((math.pi**2)/(((4*math.pi**2)/9)-((P01/a)**2)))\n", + "\n", + "#Result\n", + "print \"The minimum distance between two plates is\",round(d,2),\"cms\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The minimum distance between two plates is 1.62 cms\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.2, Page number 174" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "a = 2.\n", + "b = 1.\n", + "d = 3.\n", + "#For dominant mode TE101,\n", + "m = 1.\n", + "n = 0\n", + "p = 1.\n", + "\n", + "c = 3*10**10 #velocity of propagation(m/s)\n", + "\n", + "#Calculation\n", + "fo = (c/2)*(((m/a)**2+(n/b)**2+(p/d)**2))**0.5\n", + "\n", + "#Result\n", + "print \"The lowest resonating frequency of a rectangular cavity resonator is\",round((fo/1E+9),2),\"Ghz\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The lowest resonating frequency of a rectangular cavity resonator is 9.01 Ghz\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.3, Page number 175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "D = 12.5 #diameter of resonator(cm)\n", + "d = 5 #length of resonator(cm)\n", + "P01 = 2.405 #dominant mode TM01\n", + "c = 3*10**10 #velocity of propagation(m/s)\n", + "\n", + "#For TM012 mode,\n", + "m = 1\n", + "n = 0\n", + "p = 2\n", + "\n", + "#Calculation\n", + "a = D/2\n", + "fo = (c/(2*math.pi))*((P01/a)**2+((p*math.pi)/d)**2)**0.5\n", + "\n", + "#Result\n", + "print \"The resonanat frequency of a circular resonator is\",round((fo/1E+9),2),\"GHz\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The resonanat frequency of a circular resonator is 6.27 GHz\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.4, Page number 175" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "a = 3.\n", + "b = 2.\n", + "d = 4.\n", + "#For dominant mode TE101,\n", + "m = 1.\n", + "n = 0\n", + "p = 1.\n", + "\n", + "c = 3*10**10 #velocity of propagation(m/s)\n", + "\n", + "#Calculation\n", + "fo = (c/2)*(((m/a)**2+(n/b)**2+(p/d)**2))**0.5\n", + "\n", + "#Result\n", + "print \"The lowest resonating frequency of a circular resonator is\",round((fo/1E+9),2),\"Ghz\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The lowest resonating frequency of a circular resonator is 6.25 Ghz\n" + ] + } + ], + "prompt_number": 15 + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Microwave_and_Radar_Engineering/Chapter_8.ipynb b/Microwave_and_Radar_Engineering/Chapter_8.ipynb index ad0ccc9e..7dc18da5 100644 --- a/Microwave_and_Radar_Engineering/Chapter_8.ipynb +++ b/Microwave_and_Radar_Engineering/Chapter_8.ipynb @@ -1,995 +1,972 @@ -{
- "metadata": {
- "name": "Chapter 8"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 8: Microwave Tubes and Circuits"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.1, Page number 336"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)dc electron velocity\n",
- "b)dc phase constant\n",
- "c)plasma frequency\n",
- "d)reduced plasma frequency \n",
- "e)dc beam current density\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "Vo = 14.5*10**3 #beam voltage(V)\n",
- "i = 1.4 #beam current(A)\n",
- "f = 10*10**9 #frequency(Hz)\n",
- "rho_o = 10**-6 #dc electron charge density(c/m^3)\n",
- "rho = 10**-8 #RF charge density(c/m^3)\n",
- "V = 10**5 #velocity perturbations(m/s)\n",
- "eo = 8.854*10**-12\n",
- "R = 0.4\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "vo = 0.593*10**6*math.sqrt(Vo) #dc electron velocity\n",
- "\n",
- "#Part b\n",
- "w = 2.*math.pi*f\n",
- "ip = w/vo #dc phase current\n",
- "\n",
- "#Part c\n",
- "wp = math.sqrt((1.759*10**11*rho_o)/eo)\n",
- "\n",
- "#Part d\n",
- "wq = R*wp\n",
- "\n",
- "#Part e\n",
- "Jo = rho_o * vo\n",
- "\n",
- "#Part f\n",
- "J = rho*vo+rho_o*V\n",
- "\n",
- "#Results\n",
- "print \"dc electron velocity =\",round((vo/1E+8),3),\"*10**8 m/sec\"\n",
- "print \"dc phase curent =\",round(ip,2),\"rad/sec (Calculation mistake in the textbook)\"\n",
- "print \"plasma frequency =\",round((wp/1E+8),2),\"*10**8 rad/sec\"\n",
- "print \"Reduced plasma frequency =\",round((wq/1E+8),3),\"*10**8 rad/sec\"\n",
- "print \"dc beam current density =\",round(Jo,2), \"A/m^2\"\n",
- "print \"instantaeneous beam current density =\",round(J,3),\"A/m^2\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "dc electron velocity = 0.714 *10**8 m/sec\n",
- "dc phase curent = 879.92 rad/sec (Calculation mistake in the textbook)\n",
- "plasma frequency = 1.41 *10**8 rad/sec\n",
- "Reduced plasma frequency = 0.564 *10**8 rad/sec\n",
- "dc beam current density = 71.41 A/m^2\n",
- "instantaeneous beam current density = 0.814 A/m^2\n"
- ]
- }
- ],
- "prompt_number": 73
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.2, Page number 337"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)input rms voltage\n",
- "b)output rms voltage\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "Av = 15. #voltage gain(dB)\n",
- "Pin = 5*10**-3 #input power(W)\n",
- "Rsh_in = 30*10**3 #Rsh of input cavity(Ohms)\n",
- "Rsh_out = 20.*10**3 #Rsh of output cavity(Ohms)\n",
- "Rl = 40*10**4 #load impedance(Ohms)\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "V1 = math.sqrt(Pin*Rsh_in) #input rms voltage\n",
- "\n",
- "#Part b\n",
- "#Av = 20log(V2/V1) db\n",
- "V2 = V1*10**(Av/20) #deriving V2 from above equation\n",
- "\n",
- "#Part c\n",
- "Pout = (V2**2)/Rsh_out #output power\n",
- "\n",
- "#Results\n",
- "print \"input rms voltage =\",round(V1,2),\"V\"\n",
- "print \"output rms voltage =\",round(V2,2),\"V\"\n",
- "print \"output power =\",round((Pout/1E-3),2),\"mW\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "input rms voltage = 12.25 V\n",
- "output rms voltage = 68.87 V\n",
- "output power = 237.17 mW\n"
- ]
- }
- ],
- "prompt_number": 50
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.3, Page number 338"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)input power\n",
- "b)output power\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "n = 2 #no. of modes\n",
- "Vo = 300 #beam voltage(V)\n",
- "Io = 20*10**-3 #beam current(A)\n",
- "J1X = 1.25\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "Pdc = Vo*Io #input power\n",
- "\n",
- "#Part b\n",
- "Pac = (2*Pdc*J1X)/(2*math.pi*n-(math.pi/2))\n",
- "\n",
- "#Part c\n",
- "N = (Pac/Pdc)*100. #efficiency\n",
- "\n",
- "\n",
- "#Results\n",
- "print \"Input power =\",round(Pdc,2),\"W\"\n",
- "print \"Output power =\",round(Pac,2),\"W\"\n",
- "print \"Efficiency =\",round(N,2),\"%\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Input power = 6.0 W\n",
- "Output power = 1.36 W\n",
- "Efficiency = 22.74 %\n"
- ]
- }
- ],
- "prompt_number": 60
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.4, Page number 338"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)electron velocity \n",
- "b)dc transit time of electrons\n",
- "c)input voltage for maximum output voltage\n",
- "\n",
- "import math\n",
- "\n",
- "#Varaible declaration\n",
- "Vo = 900 #beam voltage(V)\n",
- "Io = 30*10**-3 #beam current(A)\n",
- "f = 8*10**9 #frequency(Hz)\n",
- "d = 1*10**-3 #gap spacing in either cavity(m)\n",
- "L = 4*10**-2 #spacing between centers of cavities(m)\n",
- "Rsh = 40*10**3 #effective shunt impedance(Ohms)\n",
- "J1X = 0.582\n",
- "X = 1.841\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "vo = 0.593*10**6*math.sqrt(Vo)\n",
- "\n",
- "#Part b\n",
- "To = L/vo\n",
- "\n",
- "#Part c\n",
- "w = 2*math.pi*f\n",
- "theta_o = w*To\n",
- "theta_g = (w*d)/vo\n",
- "Bo = math.sin(theta_g/2)/(theta_g/2)\n",
- "V1_max = (Vo*3.68)/(Bo*theta_o)\n",
- "\n",
- "#Part d\n",
- "Ro = Vo/Io\n",
- "Av = ((Bo**2)*theta_o*J1X*Rsh)/(Ro*X)\n",
- "\n",
- "#Results\n",
- "print \"Electron velocity =\",round((vo/1E+6),2),\"*10**6 m/sec\"\n",
- "print \"dc transit time of electrons =\",round((To/1E-8),3),\"*10**-8 sec\"\n",
- "print \"Maximum input voltage =\",round(V1_max,3),\"V\"\n",
- "print \"Volatge gain =\",round(Av,3),\"V\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Electron velocity = 17.79 *10**6 m/sec\n",
- "dc transit time of electrons = 0.225 *10**-8 sec\n",
- "Maximum input voltage = 41.923 V\n",
- "Volatge gain = 23.278 V\n"
- ]
- }
- ],
- "prompt_number": 86
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.5, Page number 339"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)Find the input microwave voltage V1 in order to generate maximum output voltage\n",
- "b)Determine the voltage gain (reflecting beam loading in the output cavity)\n",
- "c)Calculate the efficiency of the amplifier neglecting beam loading\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "Vo = 1200. #beam voltage(V)\n",
- "Io = 28*10**-3 #beam current(A)\n",
- "f = 8*10**9 #frequency(Hz)\n",
- "d = 1*10**-3 #gap spacing in either cavity(m)\n",
- "L = 4.*10**-2 #spacing between centers of cavities(m)\n",
- "Rsh = 40*10**3 #effective shunt impedance(Ohms)\n",
- "J1X = 0.582\n",
- "X = 1.841\n",
- "Go = 23.3*10**-6\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "vo = 0.593*10**6*math.sqrt(Vo)\n",
- "w = 2*math.pi*f\n",
- "theta_o = (w*L)/vo\n",
- "theta_g = (w*d)/vo\n",
- "Bo = math.sin(theta_g/2)/(theta_g/2)\n",
- "V1_max = (Vo*3.68)/(Bo*theta_o)\n",
- "\n",
- "#Part b\n",
- "Ro = Vo/Io\n",
- "Av = ((Bo**2)*theta_o*J1X*Rsh)/(Ro*X)\n",
- "\n",
- "#Part c\n",
- "V2 = 2*Io*J1X*Bo*Rsh\n",
- "N = ((0.58*V2)/Vo)*100\n",
- "\n",
- "#Part d\n",
- "Gb = (Go*((Bo**2)-(Bo*math.cos(theta_g))))/2\n",
- "Rb = 1/Gb\n",
- "\n",
- "#Results\n",
- "print \"The input microwave voltage V1 in order to generate maximum output voltage is\",round(V1_max,2),\"V\"\n",
- "print \"The voltage gain (reflecting beam loading in the output cavity) is\",round(Av,3)\n",
- "print \"The efficiency of the amplifier neglecting beam loading is\",round(N,3),\"%\" \n",
- "print \"The beam loading conductance is\",round((Rb/1E+3),2),\"K Ohms (Calculation mistake in the textbook)\"\n",
- "print \"The value of\",round((Rb/1E+3),2),\"K Ohms is very much comparable to Rsh and cannot be neglected because theta_g is quite high\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The input microwave voltage V1 in order to generate maximum output voltage is 58.71 V\n",
- "The voltage gain (reflecting beam loading in the output cavity) is 17.058\n",
- "The efficiency of the amplifier neglecting beam loading is 48.427 %\n",
- "The beam loading conductance is 72.68 K Ohms (Calculation mistake in the textbook)\n",
- "The value of 72.68 K Ohms is very much comparable to Rsh and cannot be neglected because theta_g is quite high\n"
- ]
- }
- ],
- "prompt_number": 111
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.6, Page number 341"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)Find the value of repeller voltage Vr\n",
- "b)Find the dc necesaary to give the microwave gap of voltage of 200V\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "Vo = 500. #beam voltage(V)\n",
- "Rsh = 20*10**3 #effective shunt impedance(Ohms)\n",
- "f = 8*10**9 #frequency(Hz)\n",
- "L = 1.*10**-3 #spacing between centers of cavities(m)\n",
- "n = 2\n",
- "e_m = 1.759*10**11\n",
- "V1 = 200\n",
- "J1X = 0.582\n",
- "\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "w = 2*math.pi*f\n",
- "x = (e_m*((2*math.pi*n)-(math.pi/2))**2)/(8*(w**2)*(L**2))\n",
- "y = math.sqrt(Vo/x)\n",
- "Vr = y+Vo\n",
- "\n",
- "#Part b\n",
- "Bo = 1 #Assumption\n",
- "Io = V1/(2*J1X*Rsh)\n",
- "\n",
- "#Part c\n",
- "vo = 0.593*10**6*math.sqrt(Vo)\n",
- "theta_o = (w*2*L*vo)/(e_m*(Vr+Vo))\n",
- "Bi = 1 #Assumption\n",
- "X_dash = (V1*theta_o)/(2*Vo)\n",
- "X = 1.51 #from graph\n",
- "J1X = 0.84\n",
- "N = ((2*J1X)/((2*math.pi*n)-(math.pi/2)))*100\n",
- "\n",
- "#Results\n",
- "print \"The value of repeller voltage is\",round(Vr,2),\"V (Calculation mistake in the textbook)\"\n",
- "print \"The dc necesaary to give the microwave gap of voltage of 200V is\",round((Io/1E-3),2),\"mA\"\n",
- "print \"The elctron efficiency is\", round(N,2),\"%\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of repeller voltage is 1189.36 V (Calculation mistake in the textbook)\n",
- "The dc necesaary to give the microwave gap of voltage of 200V is 8.59 mA\n",
- "The elctron efficiency is 15.28 %\n"
- ]
- }
- ],
- "prompt_number": 41
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.7, Page number 342"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)Determine the efficiency of the reflex klystron\n",
- "b)Find the total power output in mW\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "n = 1 #no. of modes\n",
- "Pdc = 40*10**-3 #input power(W)\n",
- "V1_Vo = 0.278 #ratio\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "N = (V1_Vo*3*math.pi)/4\n",
- "\n",
- "#Part b \n",
- "Pout = (8.91*Pdc)/100\n",
- "\n",
- "#Part c\n",
- "Pl = (Pout*80)/100\n",
- "\n",
- "#Results\n",
- "print \"The efficiency of the reflex klystron is\",round(N,3)\n",
- "print \"The total power output is\",round((Pout/1E-3),2),\"W\"\n",
- "print \"The power delivered to the load is\",round((Pl/1E-3),2),\"W\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The efficiency of the reflex klystron is 0.655\n",
- "The total power output is 3.56 W\n",
- "The power delivered to the load is 2.85 W\n"
- ]
- }
- ],
- "prompt_number": 23
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.8, Page number 343"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)Hull cut-off voltage\n",
- "b)Cut-off magnetic flux density\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "a = 0.15 #inner raddius(m)\n",
- "b = 0.45 #outer radius(m)\n",
- "Bo = 1.2*10**-3 #magnetic flux density(Wb/m^2)\n",
- "Vo = 6000. #beam voltage(V)\n",
- "e = 1.759*10**11\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "V = (e*Bo*(b**2)*(1-(a**2/b**2))**2)/8\n",
- "\n",
- "#Part b\n",
- "Bc = math.sqrt(8*Vo)/(e**2)*b*(1-(a**2/b**2))**2\n",
- "\n",
- "#Part c\n",
- "wc = (e*Bo)/(math.pi*2)\n",
- "\n",
- "\n",
- "#Results\n",
- "print \"Please note that here are calculation errors in this problem. Hence, the difference in answers\\n\"\n",
- "print \"Hull cut-off voltage =\",round((V/1E+3),2),\"kV\"\n",
- "print \"Cut-off magnetic flux density =\",((Bc/1E-3)),\"mwb/m^2\"\n",
- "print \"Cyclotron frequency =\",round(wc,2),\"Hz\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Please note that here are calculation errors in this problem. Hence, the difference in answers\n",
- "\n",
- "Hull cut-off voltage = 4221.6 kV\n",
- "Cut-off magnetic flux density = 2.51765610822e-18 mwb/m^2\n",
- "Cyclotron frequency = 33594425.39 Hz\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.9, Page number 343"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "d = 2*10**-3 #diameter of helical TWT(m)\n",
- "n = 50. #no. of turns per cm\n",
- "v = 3*10**8 #velocity of light(m/s)\n",
- "m = 9.1*10**-31 #mass of electron\n",
- "e = 1.6*10**-19 #charge on electron\n",
- "\n",
- "#Calculations\n",
- "p = 1/n*10**-2 #pitch(m)\n",
- "c = math.pi*d #circumference(m)\n",
- "Vp = (v*p)/c \n",
- "\n",
- "Vo = (m*(Vp**2))/(2*e)\n",
- "\n",
- "#Results\n",
- "print \"Axial phase velociity =\",round(Vp,2),\"m/sec\"\n",
- "print \"Anode voltage =\",round(Vo,2),\"V(Calculation mistake in the textbook)\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Axial phase velociity = 9549296.59 m/sec\n",
- "Anode voltage = 259.32 V(Calculation mistake in the textbook)\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.10, Page number 344"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)electron velocity\n",
- "b)dc electronic transit time\n",
- "c)input voltage for maximum output voltage\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "Vo = 900 #beam voltage(V)\n",
- "Io = 30.*10**-3 #beam current(A)\n",
- "f = 8.*10**9 #frequency(Hz)\n",
- "d = 1.*10**-3 #gap spacing in either cavity(m)\n",
- "L = 4.*10**-2 #spacing between centres of cavity(m)\n",
- "Rsh = 40.*10**3 #effective shunt impedance(Ohms)\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "vo = 0.593*10**6*math.sqrt(Vo)\n",
- "\n",
- "#Part b\n",
- "Tt = d/vo\n",
- "\n",
- "#Part c\n",
- "w = 2*math.pi*f\n",
- "theta_g = (w*d)/vo\n",
- "Bo = math.sin(theta_g/2)/(theta_g/2) #Beam coupling coefficient\n",
- "theta_o = (w*L)/vo #dc transit angle\n",
- "#For maximum o/p volltage,\n",
- "J1X = 0.582\n",
- "X = 1.841\n",
- "V1max = (2*Vo*X)/(Bo*theta_o)\n",
- "\n",
- "#Part d\n",
- "Av = (Bo**2*theta_o*J1X*Rsh)/(Io*X)\n",
- "\n",
- "#Results\n",
- "print \"dc electron velocity =\",round((vo/1E+7),1),\"*10**7 m/sec\"\n",
- "print \"Transit time =\",round((Tt/1E-10),2),\"*10^-10 s\"\n",
- "print \"Input voltage for maximum output voltage =\",round(V1max,2),\"V\"\n",
- "print \"Voltage gain =\",round((Av/1E+6),2),\"dB\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "dc electron velocity = 1.8 *10**7 m/sec\n",
- "Transit time = 0.56 *10^-10 s\n",
- "Input voltage for maximum output voltage = 41.95 V\n",
- "Voltage gain = 23.28 dB\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.11, Page number 345"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)dc electron velocity\n",
- "b)dc phase constant\n",
- "c)plasma frequency\n",
- "d)reduced plasma frequency\n",
- "e)beam current density\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "Vo = 20*10**3 #beam voltage(V)\n",
- "Io = 2 #beam current(A)\n",
- "f = 9*10**9 #frequency(Hz)\n",
- "rho_o = 10**-6 #dc electron charge density(c/m^3)\n",
- "rho = 10**-8 #RF charge density(c/m^3)\n",
- "V = 10**5 #velocity perturbations(m/s)\n",
- "eo = 8.854*10**-12\n",
- "R = 0.5\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "vo = 0.59*10**6*math.sqrt(Vo)\n",
- "\n",
- "#Part b\n",
- "w = 2.*math.pi*f\n",
- "ip = w/vo #dc phase current\n",
- "\n",
- "#Part c\n",
- "wp = math.sqrt((1.759*10**11*rho_o)/eo)\n",
- "\n",
- "#Part d\n",
- "wq = R*wp\n",
- "\n",
- "#Part e\n",
- "Jo = rho_o * vo\n",
- "\n",
- "#Part f\n",
- "J = rho*vo-rho_o*V\n",
- "\n",
- "#Results\n",
- "print \"dc electron velocity =\",round((vo/1E+7),3),\"*10**7 m/sec\"\n",
- "print \"dc phase constant =\",round(ip,2),\"rad/sec (Calculation mistake in the textbook)\"\n",
- "print \"plasma frequency =\",round((wp/1E+8),2),\"*10**8 rad/sec\"\n",
- "print \"Reduced plasma frequency =\",round((wq/1E+8),3),\"*10**8 rad/sec\"\n",
- "print \"dc beam current density =\",round(Jo,2), \"A/m^2\"\n",
- "print \"instantaeneous beam current density =\",round(J,2),\"A/m^2\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "dc electron velocity = 8.344 *10**7 m/sec\n",
- "dc phase constant = 677.73 rad/sec (Calculation mistake in the textbook)\n",
- "plasma frequency = 1.41 *10**8 rad/sec\n",
- "Reduced plasma frequency = 0.705 *10**8 rad/sec\n",
- "dc beam current density = 83.44 A/m^2\n",
- "instantaeneous beam current density = 0.73 A/m^2\n"
- ]
- }
- ],
- "prompt_number": 71
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.12, Page number 345"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "f = 5*10**9 #frequency(Hz)\n",
- "Vo = 1000 #operating voltage(V)\n",
- "n = 1.75 #no. of turns\n",
- "Vr = -500 #repeller voltage(V)\n",
- "d = 2*10**-3 #cavity gap(m)\n",
- "\n",
- "#Calculations\n",
- "w = 2*math.pi*f\n",
- "uo = 5.93*10**5*math.sqrt(Vo)\n",
- "theta_g = (w*d)/uo\n",
- "\n",
- "#Results\n",
- "print \"Transit angle =\",round(theta_g,2),\"radians\"\n",
- "print \"\\nThe length of drift region cannot be computed as the value of F is not given\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Transit angle = 3.35 radians\n",
- "\n",
- "The length of drift region cannot be computed as the value of F is not given\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.13, Page number 346"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)input RF voltage\n",
- "b)voltage gain\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "f = 10*10**9 #frequency(Hz)\n",
- "Vo = 1200 #beam voltage(V)\n",
- "Io = 30*10**-3 #beam current(A)\n",
- "d = 1*10**-3 #diameter(m)\n",
- "Rsh = 40*10**3 #shunt resistance(Ohms)\n",
- "L = 4*10**-2 #length(m)\n",
- "X = 1.84\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "vo = 0.59*10**6*math.sqrt(Vo)\n",
- "w = 2*math.pi*f\n",
- "theta_o = (w*L)/vo\n",
- "V1 = (2*X*Vo)/theta_o\n",
- "theta_g = (theta_o*d)/L\n",
- "Bi = (math.sin(theta_g/2))/(theta_g/2)\n",
- "V1max = V1/Bi\n",
- "\n",
- "#Part b\n",
- "J1X = 0.58 #from table\n",
- "I2 = 2*Io*J1X\n",
- "V2 = Bi*I2*Rsh\n",
- "A = V2/V1\n",
- "Av = 20*math.log10(A)\n",
- "\n",
- "#Part c\n",
- "N = ((0.58*V2)/Vo)*100\n",
- "\n",
- "#Results\n",
- "print \"Input RF voltage is\",round(V1max,2),\"V\" \n",
- "print \"Voltage gain is\",round(Av,2),\"dB\"\n",
- "print \"efficiency is\",round(N,2),\"%\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Input RF voltage is 55.23 V\n",
- "Voltage gain is 28.03 dB\n",
- "efficiency is 43.75 %\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.14, Page number 347"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)cyclotron angular frequency\n",
- "b)Hull cut-off voltage\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "Vo = 30*10**3 #beam voltage(V)\n",
- "Io = 80 #beam current(A)\n",
- "Bo = 0.01 #Wb/m**2\n",
- "a = 4*10**-2 #length of magnetron(m)\n",
- "b = 8*10**-2 #breadth of magnetron(m)\n",
- "e = 1.6*10**-19 #charge on electron(C)\n",
- "m = 9.1*10**-31 #mass of electron\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "w = (e*Bo)/m\n",
- "\n",
- "#Part b\n",
- "Vhc = (e*(Bo**2)*(b**2)*((1-((a/b)**2))**2))/(8*m)\n",
- "\n",
- "#PArt c\n",
- "Bc = ((8*Vo*(m/e))**0.5)/(b*(1-((a/b)**2)))\n",
- "\n",
- "#Results\n",
- "print \"Cyclotron angular frequency =\",round((w/1E+9),3),\"*10**9 rad/s\"\n",
- "print \"Hull cut-off voltage =\",round((Vhc/1E+3),3),\"kV\"\n",
- "print \"Cut-off magnetic flux density =\",round((Bc/1E-3),3),\"mWb/m**2\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Cyclotron angular frequency = 1.758 *10**9 rad/s\n",
- "Hull cut-off voltage = 7.912 kV\n",
- "Cut-off magnetic flux density = 19.472 mWb/m**2\n"
- ]
- }
- ],
- "prompt_number": 26
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.15, Page number 348"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)input power\n",
- "b)output power\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "n = 2 #mode\n",
- "Vo = 280 #beam volatge(V)\n",
- "Io = 22*10**-3 #beam current(A)\n",
- "V1 = 30 #signal voltage(V)\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "Pdc = Vo*Io\n",
- "\n",
- "#Part b\n",
- "J1X = 1.25 #from table\n",
- "Pac = (2*Pdc*J1X)/((2*n*math.pi)-(math.pi/2))\n",
- "\n",
- "#Part c\n",
- "N = (Pac/Pdc)*100\n",
- "\n",
- "#Results\n",
- "print \"Input power =\",round(Pdc,2),\"W\"\n",
- "print \"Output power =\",round(Pac,2),\"W\"\n",
- "print \"Efficiency =\",round(N,2),\"%\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Input power = 6.16 W\n",
- "Output power = 1.4 W\n",
- "Efficiency = 22.74 %\n"
- ]
- }
- ],
- "prompt_number": 28
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.16, Page number 348"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)repeller voltage\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "f = 8*10**9 #frequency(Hz)\n",
- "Vo = 300 #beam voltage(V)\n",
- "Rsh = 20*10**3 #shunt resistance(Ohms)\n",
- "L = 1*10**-3 #length(m)\n",
- "V1 = 200 #gap voltage(V)\n",
- "e_m = 1.759*10**11\n",
- "n = 2 #mode\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "w = 2*math.pi*f\n",
- "x = (e_m*((2*math.pi*n)-(math.pi/2))**2)/(8*(w**2)*(L**2))\n",
- "y = math.sqrt(Vo/x)\n",
- "Vr = y+Vo\n",
- "\n",
- "#Part b\n",
- "Bo = 1 #assumption\n",
- "J1X = 0.582 #from table\n",
- "Io = V1/(2*J1X*Rsh)\n",
- "\n",
- "#Results\n",
- "print \"Repeller voltage =\",round(Vr,3),\"V\"\n",
- "print \"Beam current =\",round((Io/1E-3),2),\"mA\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Repeller voltage = 833.98 V\n",
- "Beam current = 8.59 mA\n"
- ]
- }
- ],
- "prompt_number": 37
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:35777e633db88a5618cd88c47986862d4ccaaacc3cda8478283a81851ed8d31c" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Microwave Tubes and Circuits" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.1, Page number 336" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Vo = 14.5*10**3 #beam voltage(V)\n", + "i = 1.4 #beam current(A)\n", + "f = 10*10**9 #frequency(Hz)\n", + "rho_o = 10**-6 #dc electron charge density(c/m^3)\n", + "rho = 10**-8 #RF charge density(c/m^3)\n", + "V = 10**5 #velocity perturbations(m/s)\n", + "eo = 8.854*10**-12\n", + "R = 0.4\n", + "\n", + "#Calculations\n", + "#Part a\n", + "vo = 0.593*10**6*math.sqrt(Vo) #dc electron velocity\n", + "\n", + "#Part b\n", + "w = 2.*math.pi*f\n", + "ip = w/vo #dc phase current\n", + "\n", + "#Part c\n", + "wp = math.sqrt((1.759*10**11*rho_o)/eo)\n", + "\n", + "#Part d\n", + "wq = R*wp\n", + "\n", + "#Part e\n", + "Jo = rho_o * vo\n", + "\n", + "#Part f\n", + "J = rho*vo+rho_o*V\n", + "\n", + "#Results\n", + "print \"dc electron velocity =\",round((vo/1E+8),3),\"*10**8 m/sec\"\n", + "print \"dc phase curent =\",round(ip,2),\"rad/sec (Calculation mistake in the textbook)\"\n", + "print \"plasma frequency =\",round((wp/1E+8),2),\"*10**8 rad/sec\"\n", + "print \"Reduced plasma frequency =\",round((wq/1E+8),3),\"*10**8 rad/sec\"\n", + "print \"dc beam current density =\",round(Jo,2), \"A/m^2\"\n", + "print \"instantaeneous beam current density =\",round(J,3),\"A/m^2\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "dc electron velocity = 0.714 *10**8 m/sec\n", + "dc phase curent = 879.92 rad/sec (Calculation mistake in the textbook)\n", + "plasma frequency = 1.41 *10**8 rad/sec\n", + "Reduced plasma frequency = 0.564 *10**8 rad/sec\n", + "dc beam current density = 71.41 A/m^2\n", + "instantaeneous beam current density = 0.814 A/m^2\n" + ] + } + ], + "prompt_number": 73 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.2, Page number 337" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Av = 15. #voltage gain(dB)\n", + "Pin = 5*10**-3 #input power(W)\n", + "Rsh_in = 30*10**3 #Rsh of input cavity(Ohms)\n", + "Rsh_out = 20.*10**3 #Rsh of output cavity(Ohms)\n", + "Rl = 40*10**4 #load impedance(Ohms)\n", + "\n", + "#Calculations\n", + "#Part a\n", + "V1 = math.sqrt(Pin*Rsh_in) #input rms voltage\n", + "\n", + "#Part b\n", + "#Av = 20log(V2/V1) db\n", + "V2 = V1*10**(Av/20) #deriving V2 from above equation\n", + "\n", + "#Part c\n", + "Pout = (V2**2)/Rsh_out #output power\n", + "\n", + "#Results\n", + "print \"input rms voltage =\",round(V1,2),\"V\"\n", + "print \"output rms voltage =\",round(V2,2),\"V\"\n", + "print \"output power =\",round((Pout/1E-3),2),\"mW\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "input rms voltage = 12.25 V\n", + "output rms voltage = 68.87 V\n", + "output power = 237.17 mW\n" + ] + } + ], + "prompt_number": 50 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.3, Page number 338" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "a\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "n = 2 #no. of modes\n", + "Vo = 300 #beam voltage(V)\n", + "Io = 20*10**-3 #beam current(A)\n", + "J1X = 1.25\n", + "\n", + "#Calculations\n", + "#Part a\n", + "Pdc = Vo*Io #input power\n", + "\n", + "#Part b\n", + "Pac = (2*Pdc*J1X)/(2*math.pi*n-(math.pi/2))\n", + "\n", + "#Part c\n", + "N = (Pac/Pdc)*100. #efficiency\n", + "\n", + "\n", + "#Results\n", + "print \"Input power =\",round(Pdc,2),\"W\"\n", + "print \"Output power =\",round(Pac,2),\"W\"\n", + "print \"Efficiency =\",round(N,2),\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Input power = 6.0 W\n", + "Output power = 1.36 W\n", + "Efficiency = 22.74 %\n" + ] + } + ], + "prompt_number": 60 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.4, Page number 338" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "\n", + "#Varaible declaration\n", + "Vo = 900 #beam voltage(V)\n", + "Io = 30*10**-3 #beam current(A)\n", + "f = 8*10**9 #frequency(Hz)\n", + "d = 1*10**-3 #gap spacing in either cavity(m)\n", + "L = 4*10**-2 #spacing between centers of cavities(m)\n", + "Rsh = 40*10**3 #effective shunt impedance(Ohms)\n", + "J1X = 0.582\n", + "X = 1.841\n", + "\n", + "#Calculations\n", + "#Part a\n", + "vo = 0.593*10**6*math.sqrt(Vo)\n", + "\n", + "#Part b\n", + "To = L/vo\n", + "\n", + "#Part c\n", + "w = 2*math.pi*f\n", + "theta_o = w*To\n", + "theta_g = (w*d)/vo\n", + "Bo = math.sin(theta_g/2)/(theta_g/2)\n", + "V1_max = (Vo*3.68)/(Bo*theta_o)\n", + "\n", + "#Part d\n", + "Ro = Vo/Io\n", + "Av = ((Bo**2)*theta_o*J1X*Rsh)/(Ro*X)\n", + "\n", + "#Results\n", + "print \"Electron velocity =\",round((vo/1E+6),2),\"*10**6 m/sec\"\n", + "print \"dc transit time of electrons =\",round((To/1E-8),3),\"*10**-8 sec\"\n", + "print \"Maximum input voltage =\",round(V1_max,3),\"V\"\n", + "print \"Volatge gain =\",round(Av,3),\"V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Electron velocity = 17.79 *10**6 m/sec\n", + "dc transit time of electrons = 0.225 *10**-8 sec\n", + "Maximum input voltage = 41.923 V\n", + "Volatge gain = 23.278 V\n" + ] + } + ], + "prompt_number": 86 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.5, Page number 339" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Vo = 1200. #beam voltage(V)\n", + "Io = 28*10**-3 #beam current(A)\n", + "f = 8*10**9 #frequency(Hz)\n", + "d = 1*10**-3 #gap spacing in either cavity(m)\n", + "L = 4.*10**-2 #spacing between centers of cavities(m)\n", + "Rsh = 40*10**3 #effective shunt impedance(Ohms)\n", + "J1X = 0.582\n", + "X = 1.841\n", + "Go = 23.3*10**-6\n", + "\n", + "#Calculations\n", + "#Part a\n", + "vo = 0.593*10**6*math.sqrt(Vo)\n", + "w = 2*math.pi*f\n", + "theta_o = (w*L)/vo\n", + "theta_g = (w*d)/vo\n", + "Bo = math.sin(theta_g/2)/(theta_g/2)\n", + "V1_max = (Vo*3.68)/(Bo*theta_o)\n", + "\n", + "#Part b\n", + "Ro = Vo/Io\n", + "Av = ((Bo**2)*theta_o*J1X*Rsh)/(Ro*X)\n", + "\n", + "#Part c\n", + "V2 = 2*Io*J1X*Bo*Rsh\n", + "N = ((0.58*V2)/Vo)*100\n", + "\n", + "#Part d\n", + "Gb = (Go*((Bo**2)-(Bo*math.cos(theta_g))))/2\n", + "Rb = 1/Gb\n", + "\n", + "#Results\n", + "print \"The input microwave voltage V1 in order to generate maximum output voltage is\",round(V1_max,2),\"V\"\n", + "print \"The voltage gain (reflecting beam loading in the output cavity) is\",round(Av,3)\n", + "print \"The efficiency of the amplifier neglecting beam loading is\",round(N,3),\"%\" \n", + "print \"The beam loading conductance is\",round((Rb/1E+3),2),\"K Ohms (Calculation mistake in the textbook)\"\n", + "print \"The value of\",round((Rb/1E+3),2),\"K Ohms is very much comparable to Rsh and cannot be neglected because theta_g is quite high\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The input microwave voltage V1 in order to generate maximum output voltage is 58.71 V\n", + "The voltage gain (reflecting beam loading in the output cavity) is 17.058\n", + "The efficiency of the amplifier neglecting beam loading is 48.427 %\n", + "The beam loading conductance is 72.68 K Ohms (Calculation mistake in the textbook)\n", + "The value of 72.68 K Ohms is very much comparable to Rsh and cannot be neglected because theta_g is quite high\n" + ] + } + ], + "prompt_number": 111 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.6, Page number 341" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Vo = 500. #beam voltage(V)\n", + "Rsh = 20*10**3 #effective shunt impedance(Ohms)\n", + "f = 8*10**9 #frequency(Hz)\n", + "L = 1.*10**-3 #spacing between centers of cavities(m)\n", + "n = 2\n", + "e_m = 1.759*10**11\n", + "V1 = 200\n", + "J1X = 0.582\n", + "\n", + "\n", + "#Calculations\n", + "#Part a\n", + "w = 2*math.pi*f\n", + "x = (e_m*((2*math.pi*n)-(math.pi/2))**2)/(8*(w**2)*(L**2))\n", + "y = math.sqrt(Vo/x)\n", + "Vr = y+Vo\n", + "\n", + "#Part b\n", + "Bo = 1 #Assumption\n", + "Io = V1/(2*J1X*Rsh)\n", + "\n", + "#Part c\n", + "vo = 0.593*10**6*math.sqrt(Vo)\n", + "theta_o = (w*2*L*vo)/(e_m*(Vr+Vo))\n", + "Bi = 1 #Assumption\n", + "X_dash = (V1*theta_o)/(2*Vo)\n", + "X = 1.51 #from graph\n", + "J1X = 0.84\n", + "N = ((2*J1X)/((2*math.pi*n)-(math.pi/2)))*100\n", + "\n", + "#Results\n", + "print \"The value of repeller voltage is\",round(Vr,2),\"V (Calculation mistake in the textbook)\"\n", + "print \"The dc necesaary to give the microwave gap of voltage of 200V is\",round((Io/1E-3),2),\"mA\"\n", + "print \"The elctron efficiency is\", round(N,2),\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of repeller voltage is 1189.36 V (Calculation mistake in the textbook)\n", + "The dc necesaary to give the microwave gap of voltage of 200V is 8.59 mA\n", + "The elctron efficiency is 15.28 %\n" + ] + } + ], + "prompt_number": 41 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.7, Page number 342" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "n = 1 #no. of modes\n", + "Pdc = 40*10**-3 #input power(W)\n", + "V1_Vo = 0.278 #ratio\n", + "\n", + "#Calculations\n", + "#Part a\n", + "N = (V1_Vo*3*math.pi)/4\n", + "\n", + "#Part b \n", + "Pout = (8.91*Pdc)/100\n", + "\n", + "#Part c\n", + "Pl = (Pout*80)/100\n", + "\n", + "#Results\n", + "print \"The efficiency of the reflex klystron is\",round(N,3)\n", + "print \"The total power output is\",round((Pout/1E-3),2),\"W\"\n", + "print \"The power delivered to the load is\",round((Pl/1E-3),2),\"W\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The efficiency of the reflex klystron is 0.655\n", + "The total power output is 3.56 W\n", + "The power delivered to the load is 2.85 W\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.8, Page number 343" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "a = 0.15 #inner raddius(m)\n", + "b = 0.45 #outer radius(m)\n", + "Bo = 1.2*10**-3 #magnetic flux density(Wb/m^2)\n", + "Vo = 6000. #beam voltage(V)\n", + "e = 1.759*10**11\n", + "\n", + "#Calculations\n", + "#Part a\n", + "V = (e*Bo*(b**2)*(1-(a**2/b**2))**2)/8\n", + "\n", + "#Part b\n", + "Bc = math.sqrt(8*Vo)/(e**2)*b*(1-(a**2/b**2))**2\n", + "\n", + "#Part c\n", + "wc = (e*Bo)/(math.pi*2)\n", + "\n", + "\n", + "#Results\n", + "print \"Please note that here are calculation errors in this problem. Hence, the difference in answers\\n\"\n", + "print \"Hull cut-off voltage =\",round((V/1E+3),2),\"kV\"\n", + "print \"Cut-off magnetic flux density =\",((Bc/1E-3)),\"mwb/m^2\"\n", + "print \"Cyclotron frequency =\",round(wc,2),\"Hz\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please note that here are calculation errors in this problem. Hence, the difference in answers\n", + "\n", + "Hull cut-off voltage = 4221.6 kV\n", + "Cut-off magnetic flux density = 2.51765610822e-18 mwb/m^2\n", + "Cyclotron frequency = 33594425.39 Hz\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.9, Page number 343" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "d = 2*10**-3 #diameter of helical TWT(m)\n", + "n = 50. #no. of turns per cm\n", + "v = 3*10**8 #velocity of light(m/s)\n", + "m = 9.1*10**-31 #mass of electron\n", + "e = 1.6*10**-19 #charge on electron\n", + "\n", + "#Calculations\n", + "p = 1/n*10**-2 #pitch(m)\n", + "c = math.pi*d #circumference(m)\n", + "Vp = (v*p)/c \n", + "\n", + "Vo = (m*(Vp**2))/(2*e)\n", + "\n", + "#Results\n", + "print \"Axial phase velociity =\",round(Vp,2),\"m/sec\"\n", + "print \"Anode voltage =\",round(Vo,2),\"V(Calculation mistake in the textbook)\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Axial phase velociity = 9549296.59 m/sec\n", + "Anode voltage = 259.32 V(Calculation mistake in the textbook)\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.10, Page number 344" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Vo = 900 #beam voltage(V)\n", + "Io = 30.*10**-3 #beam current(A)\n", + "f = 8.*10**9 #frequency(Hz)\n", + "d = 1.*10**-3 #gap spacing in either cavity(m)\n", + "L = 4.*10**-2 #spacing between centres of cavity(m)\n", + "Rsh = 40.*10**3 #effective shunt impedance(Ohms)\n", + "\n", + "#Calculations\n", + "#Part a\n", + "vo = 0.593*10**6*math.sqrt(Vo)\n", + "\n", + "#Part b\n", + "Tt = d/vo\n", + "\n", + "#Part c\n", + "w = 2*math.pi*f\n", + "theta_g = (w*d)/vo\n", + "Bo = math.sin(theta_g/2)/(theta_g/2) #Beam coupling coefficient\n", + "theta_o = (w*L)/vo #dc transit angle\n", + "#For maximum o/p volltage,\n", + "J1X = 0.582\n", + "X = 1.841\n", + "V1max = (2*Vo*X)/(Bo*theta_o)\n", + "\n", + "#Part d\n", + "Av = (Bo**2*theta_o*J1X*Rsh)/(Io*X)\n", + "\n", + "#Results\n", + "print \"dc electron velocity =\",round((vo/1E+7),1),\"*10**7 m/sec\"\n", + "print \"Transit time =\",round((Tt/1E-10),2),\"*10^-10 s\"\n", + "print \"Input voltage for maximum output voltage =\",round(V1max,2),\"V\"\n", + "print \"Voltage gain =\",round((Av/1E+6),2),\"dB\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "dc electron velocity = 1.8 *10**7 m/sec\n", + "Transit time = 0.56 *10^-10 s\n", + "Input voltage for maximum output voltage = 41.95 V\n", + "Voltage gain = 23.28 dB\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.11, Page number 345" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Vo = 20*10**3 #beam voltage(V)\n", + "Io = 2 #beam current(A)\n", + "f = 9*10**9 #frequency(Hz)\n", + "rho_o = 10**-6 #dc electron charge density(c/m^3)\n", + "rho = 10**-8 #RF charge density(c/m^3)\n", + "V = 10**5 #velocity perturbations(m/s)\n", + "eo = 8.854*10**-12\n", + "R = 0.5\n", + "\n", + "#Calculations\n", + "#Part a\n", + "vo = 0.59*10**6*math.sqrt(Vo)\n", + "\n", + "#Part b\n", + "w = 2.*math.pi*f\n", + "ip = w/vo #dc phase current\n", + "\n", + "#Part c\n", + "wp = math.sqrt((1.759*10**11*rho_o)/eo)\n", + "\n", + "#Part d\n", + "wq = R*wp\n", + "\n", + "#Part e\n", + "Jo = rho_o * vo\n", + "\n", + "#Part f\n", + "J = rho*vo-rho_o*V\n", + "\n", + "#Results\n", + "print \"dc electron velocity =\",round((vo/1E+7),3),\"*10**7 m/sec\"\n", + "print \"dc phase constant =\",round(ip,2),\"rad/sec (Calculation mistake in the textbook)\"\n", + "print \"plasma frequency =\",round((wp/1E+8),2),\"*10**8 rad/sec\"\n", + "print \"Reduced plasma frequency =\",round((wq/1E+8),3),\"*10**8 rad/sec\"\n", + "print \"dc beam current density =\",round(Jo,2), \"A/m^2\"\n", + "print \"instantaeneous beam current density =\",round(J,2),\"A/m^2\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "dc electron velocity = 8.344 *10**7 m/sec\n", + "dc phase constant = 677.73 rad/sec (Calculation mistake in the textbook)\n", + "plasma frequency = 1.41 *10**8 rad/sec\n", + "Reduced plasma frequency = 0.705 *10**8 rad/sec\n", + "dc beam current density = 83.44 A/m^2\n", + "instantaeneous beam current density = 0.73 A/m^2\n" + ] + } + ], + "prompt_number": 71 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.12, Page number 345" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "f = 5*10**9 #frequency(Hz)\n", + "Vo = 1000 #operating voltage(V)\n", + "n = 1.75 #no. of turns\n", + "Vr = -500 #repeller voltage(V)\n", + "d = 2*10**-3 #cavity gap(m)\n", + "\n", + "#Calculations\n", + "w = 2*math.pi*f\n", + "uo = 5.93*10**5*math.sqrt(Vo)\n", + "theta_g = (w*d)/uo\n", + "\n", + "#Results\n", + "print \"Transit angle =\",round(theta_g,2),\"radians\"\n", + "print \"\\nThe length of drift region cannot be computed as the value of F is not given\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Transit angle = 3.35 radians\n", + "\n", + "The length of drift region cannot be computed as the value of F is not given\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.13, Page number 346" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "f = 10*10**9 #frequency(Hz)\n", + "Vo = 1200 #beam voltage(V)\n", + "Io = 30*10**-3 #beam current(A)\n", + "d = 1*10**-3 #diameter(m)\n", + "Rsh = 40*10**3 #shunt resistance(Ohms)\n", + "L = 4*10**-2 #length(m)\n", + "X = 1.84\n", + "\n", + "#Calculations\n", + "#Part a\n", + "vo = 0.59*10**6*math.sqrt(Vo)\n", + "w = 2*math.pi*f\n", + "theta_o = (w*L)/vo\n", + "V1 = (2*X*Vo)/theta_o\n", + "theta_g = (theta_o*d)/L\n", + "Bi = (math.sin(theta_g/2))/(theta_g/2)\n", + "V1max = V1/Bi\n", + "\n", + "#Part b\n", + "J1X = 0.58 #from table\n", + "I2 = 2*Io*J1X\n", + "V2 = Bi*I2*Rsh\n", + "A = V2/V1\n", + "Av = 20*math.log10(A)\n", + "\n", + "#Part c\n", + "N = ((0.58*V2)/Vo)*100\n", + "\n", + "#Results\n", + "print \"Input RF voltage is\",round(V1max,2),\"V\" \n", + "print \"Voltage gain is\",round(Av,2),\"dB\"\n", + "print \"efficiency is\",round(N,2),\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Input RF voltage is 55.23 V\n", + "Voltage gain is 28.03 dB\n", + "efficiency is 43.75 %\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.14, Page number 347" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Vo = 30*10**3 #beam voltage(V)\n", + "Io = 80 #beam current(A)\n", + "Bo = 0.01 #Wb/m**2\n", + "a = 4*10**-2 #length of magnetron(m)\n", + "b = 8*10**-2 #breadth of magnetron(m)\n", + "e = 1.6*10**-19 #charge on electron(C)\n", + "m = 9.1*10**-31 #mass of electron\n", + "\n", + "#Calculations\n", + "#Part a\n", + "w = (e*Bo)/m\n", + "\n", + "#Part b\n", + "Vhc = (e*(Bo**2)*(b**2)*((1-((a/b)**2))**2))/(8*m)\n", + "\n", + "#PArt c\n", + "Bc = ((8*Vo*(m/e))**0.5)/(b*(1-((a/b)**2)))\n", + "\n", + "#Results\n", + "print \"Cyclotron angular frequency =\",round((w/1E+9),3),\"*10**9 rad/s\"\n", + "print \"Hull cut-off voltage =\",round((Vhc/1E+3),3),\"kV\"\n", + "print \"Cut-off magnetic flux density =\",round((Bc/1E-3),3),\"mWb/m**2\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Cyclotron angular frequency = 1.758 *10**9 rad/s\n", + "Hull cut-off voltage = 7.912 kV\n", + "Cut-off magnetic flux density = 19.472 mWb/m**2\n" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.15, Page number 348" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "n = 2 #mode\n", + "Vo = 280 #beam volatge(V)\n", + "Io = 22*10**-3 #beam current(A)\n", + "V1 = 30 #signal voltage(V)\n", + "\n", + "#Calculations\n", + "#Part a\n", + "Pdc = Vo*Io\n", + "\n", + "#Part b\n", + "J1X = 1.25 #from table\n", + "Pac = (2*Pdc*J1X)/((2*n*math.pi)-(math.pi/2))\n", + "\n", + "#Part c\n", + "N = (Pac/Pdc)*100\n", + "\n", + "#Results\n", + "print \"Input power =\",round(Pdc,2),\"W\"\n", + "print \"Output power =\",round(Pac,2),\"W\"\n", + "print \"Efficiency =\",round(N,2),\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Input power = 6.16 W\n", + "Output power = 1.4 W\n", + "Efficiency = 22.74 %\n" + ] + } + ], + "prompt_number": 28 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.16, Page number 348" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "f = 8*10**9 #frequency(Hz)\n", + "Vo = 300 #beam voltage(V)\n", + "Rsh = 20*10**3 #shunt resistance(Ohms)\n", + "L = 1*10**-3 #length(m)\n", + "V1 = 200 #gap voltage(V)\n", + "e_m = 1.759*10**11\n", + "n = 2 #mode\n", + "\n", + "#Calculations\n", + "#Part a\n", + "w = 2*math.pi*f\n", + "x = (e_m*((2*math.pi*n)-(math.pi/2))**2)/(8*(w**2)*(L**2))\n", + "y = math.sqrt(Vo/x)\n", + "Vr = y+Vo\n", + "\n", + "#Part b\n", + "Bo = 1 #assumption\n", + "J1X = 0.582 #from table\n", + "Io = V1/(2*J1X*Rsh)\n", + "\n", + "#Results\n", + "print \"Repeller voltage =\",round(Vr,3),\"V\"\n", + "print \"Beam current =\",round((Io/1E-3),2),\"mA\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Repeller voltage = 833.98 V\n", + "Beam current = 8.59 mA\n" + ] + } + ], + "prompt_number": 37 + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Microwave_and_Radar_Engineering/Chapter_9.ipynb b/Microwave_and_Radar_Engineering/Chapter_9.ipynb index 99126c13..9e0e63f1 100644 --- a/Microwave_and_Radar_Engineering/Chapter_9.ipynb +++ b/Microwave_and_Radar_Engineering/Chapter_9.ipynb @@ -1,616 +1,612 @@ -{
- "metadata": {
- "name": "Chapter 9"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 9:Solid State Microwave devices"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.1, Page number 411"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "L = 2*10**-6 #drift length(m)\n",
- "Vd = 10**7*10**-2 #dfrift velocit(m/s)\n",
- "\n",
- "#Calculations\n",
- "f = Vd/(2*L)\n",
- "\n",
- "#Results\n",
- "print \"Frequncy of IMPATT diode is\",round((f/1E+9),2),\"GHz\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Frequncy of IMPATT diode is 25.0 GHz\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.2, Page number 411"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "f = 10*10**9 #operating frequency(Hz)\n",
- "L = 75*10**-6 #device length(m)\n",
- "V = 25. #voltage pulse amplified(V)\n",
- "\n",
- "#Calculations\n",
- "Eth = V/(L)\n",
- "\n",
- "#Result\n",
- "print \"The threshold electric field is\",round((Eth/1E+5),2),\"KV/cm\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The threshold electric field is 3.33 KV/cm\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.3, Page number 411"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)power gain in dB\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "fs = 2*10**9 #signal frequency(Hz)\n",
- "fp = 12*10**9 #pump frequency(Hz)\n",
- "Ri = 16 #output resistance of signal generator(Ohms)\n",
- "Rs = 1*10**3 #resistance of signal generator(Ohms)\n",
- "\n",
- "#Calculations\n",
- "#Part a \n",
- "P = 10*math.log10((fp-fs)/fs)\n",
- "\n",
- "#Part b\n",
- "Pc = 10*math.log10((fp+fs)/fs)\n",
- "\n",
- "#Results\n",
- "print \"Please note that there are calculation mistakes in the textbook. Hence, the difference in answers.\\n\"\n",
- "print \"Power gain =\",round(P,2),\"dB\"\n",
- "print \"Power gain as USB converter =\",round(Pc,2),\"dB\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Please note that there are calculation mistakes in the textbook. Hence, the difference in answers.\n",
- "\n",
- "Power gain = 6.99 dB\n",
- "Power gain as USB converter = 8.45 dB\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.4, Page number 411"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)critical voltage\n",
- "b)breakdown voltage\n",
- "\n",
- "#Variable declaration\n",
- "Es = 12.5 #relative dielectric constant\n",
- "N = 3.2*10**22 #donor concentration(/m**3)\n",
- "L = 8*10**-6 #length(m)\n",
- "Eo = 8.854*10**-12 #dielectric constant\n",
- "q = 1.6*10**-19\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "Vc = (q*N*L**2)/(2*Eo*Es)\n",
- "\n",
- "#Part b\n",
- "Vbd = 2*Vc\n",
- "\n",
- "#Part c\n",
- "Ebd = Vbd/L\n",
- "\n",
- "#Results\n",
- "print \"Critical voltage =\",round((Vc/1E+3),2),\"kV\"\n",
- "print \"Breakdown voltage =\",round((Vbd/1E+3),2),\"kV\"\n",
- "print \"Breakdown electric field =\",round((Ebd/1E+8),2),\"*10**8 V/cm\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Critical voltage = 1.48 kV\n",
- "Breakdown voltage = 2.96 kV\n",
- "Breakdown electric field = 3.7 *10**8 V/cm\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.5, Page number 412"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "Na = 2.5*10**16 #doping concentration(/cm**3)\n",
- "J = 33*10**3 #current density(A/cm**2)\n",
- "q = 1.6*10**-19\n",
- "\n",
- "#Calculations\n",
- "Vz = J/(q*Na)\n",
- "\n",
- "#Results\n",
- "print \"The avalanche zone velocity is\",round((Vz/1E+6),2),\"*10**6 cm/s\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The avalanche zone velocity is 8.25 *10**6 cm/s\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.6, Page number 412"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "Rd = -25 #negative resistance(Ohms)\n",
- "Rl = 50 #load resistance(Ohms)\n",
- "\n",
- "#Calculations\n",
- "G = ((Rd-Rl)/(Rd+Rl))**2\n",
- "\n",
- "#Results\n",
- "print \"Power gain =\",G"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Power gain = 9\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.7, Page number 412"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "L = 5.*10**-6 #drift length(m)\n",
- "V = 3.3*10**3 #voltagradient(V/cm)\n",
- "\n",
- "#Calculation\n",
- "Vmin = V*L\n",
- "\n",
- "#Result\n",
- "print \"The minimum voltage required is\",round(Vmin,4),\"V\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The minimum voltage required is 0.0165 V\n"
- ]
- }
- ],
- "prompt_number": 37
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.8, Page number 412"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable declaration\n",
- "Vd = 2*10**7 #drift velocity(cm/s)\n",
- "L = 20*10**-6 #active lengh(m)\n",
- "Ec = 3.3*10**3 #crtical field(GaAs)\n",
- "\n",
- "#Calculations\n",
- "f = Vd/L\n",
- "V = L*Ec\n",
- "\n",
- "#Results\n",
- "print \"Please note that there are calculation mistakes in the textbook. Hence, the difference in answers.\\n\"\n",
- "print \"Rational frequency =\",round((f/1E+9),2),\"GHz\"\n",
- "print \"Critical voltage =\",round(V,3),\"V\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Please note that there are calculation mistakes in the textbook. Hence, the difference in answers.\n",
- "\n",
- "Rational frequency = 1000.0 GHz\n",
- "Critical voltage = 0.066 V\n"
- ]
- }
- ],
- "prompt_number": 40
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.9, Page number 412"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "from math import pi,sqrt\n",
- "\n",
- "#Variable declaration\n",
- "Cj = 0.5*10**-12 #capacitance of IMPATT diode(F)\n",
- "Lp = 0.5*10**-9 #Inductance of IMPATT diode(H)\n",
- "Vbd = 100 #breakdown voltage(V)\n",
- "Ib = 100*10**-3 #dc bias current(A)\n",
- "Ip = 0.8 #peak current(A)\n",
- "Rl = 2 #load resistance(Ohms)\n",
- "\n",
- "#Calculations\n",
- "f = 1/(2*pi*sqrt(Lp*Cj))\n",
- "Pl = ((Ip**2)*Rl)/2\n",
- "Pdc = Vbd*Ib\n",
- "N = (Pl/Pdc)*100\n",
- "\n",
- "#Results\n",
- "print \"The resonant frequency is\",round((f/1E+9),1),\"GHz\"\n",
- "print \"Efficiency is\",round(N,2),\"%\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The resonant frequency is 10.1 GHz\n",
- "Efficiency is 6.4 %\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.10, Page number 413"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)drift time\n",
- "\n",
- "#Variable declaration\n",
- "Vd = 10**5 #carrier dirft velocity(cm/s)\n",
- "L = 2*10**-6 #drift length(m)\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "tou = L/Vd\n",
- "\n",
- "#Part b\n",
- "f = 1/(2*tou)\n",
- "\n",
- "#Results\n",
- "print \"Drift time of the carrier is\",round((tou/1E-11),2),\"*10**-11 sec\"\n",
- "print \"Operating frequency of diode is\",(f/1E+9),\"GHz\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Drift time of the carrier is 2.0 *10**-11 sec\n",
- "Operating frequency of diode is 25.0 GHz\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.11, Page number 413"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)breakdown voltage\n",
- "\n",
- "#Variable declaration\n",
- "Er = 11.8 #relative dielectric constant\n",
- "N = 3*10**21 #donor concentration(m^-3)\n",
- "L = 6.2*10**-6 #Si length(m)\n",
- "q = 1.6*10**-19 #charge of an electron(C)\n",
- "Eo = 8.854*10**-12 #dielctric constant\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "Vbd = (q*N*L**2)/(Eo*Er)\n",
- "\n",
- "#Part b\n",
- "Ebd = Vbd/L\n",
- "\n",
- "#Results\n",
- "print \"Breakdown voltage =\",round(Vbd,1),\"V\"\n",
- "print \"Breakdown electric field =\",round((Ebd/1E+7),2),\"*10**7 V/m\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Breakdown voltage = 176.6 V\n",
- "Breakdown electric field = 2.85 *10**7 V/m\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.12, Page number 413"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)Maximum power gain\n",
- "b)Noise figure\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "rQ = 8. #figure of merit\n",
- "fo_fs = 8. #ratio of o/p to i/p frequency\n",
- "Td = 300. #diode temperatur(K)\n",
- "To = 300. #ambient temperature(K)\n",
- "r = 0.2\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "X = rQ**2/fo_fs\n",
- "G = (X/((1+math.sqrt(1+X))**2))*fo_fs\n",
- "g = 10*math.log10(G)\n",
- "\n",
- "#Part b\n",
- "F = 1+((2*Td)/To)*((1/rQ)+(1/rQ**2))\n",
- "f = 10*math.log10(F)\n",
- "\n",
- "#Part c\n",
- "BW = 2*r*math.sqrt(fo_fs)\n",
- "\n",
- "#Results\n",
- "print \"Maximum power gain =\",round(g,2),\"dB\"\n",
- "print \"Noise figure =\",round(f,2),\"dB\"\n",
- "print \"Bandwidth =\",round(BW,2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Maximum power gain = 6.02 dB\n",
- "Noise figure = 1.08 dB\n",
- "Bandwidth = 1.13\n"
- ]
- }
- ],
- "prompt_number": 41
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.13, Page number 414"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "a)Equivalent noise resistance\n",
- "b)Gain\n",
- "c)Noise figure\n",
- "\n",
- "import math\n",
- "\n",
- "#Variable declaration\n",
- "fs = 2*10**9 #signal frequency(Hz)\n",
- "fp = 12*10**9 #amplifier frquency(Hz)\n",
- "fi = 10*10**9 #input frequency(Hz)\n",
- "fd = 5*10**9 #diode frequency(Hz)\n",
- "Ri = 1*10**3 #input resistance(Ohms)\n",
- "Rg = 1*10**3 #gate resistance(Ohms)\n",
- "RTs = 1*10**3 #resistance(Ohms)\n",
- "RTi = 1*10**3 #resistance(Ohms)\n",
- "r = 0.35 #resistane(Ohms)\n",
- "rQ = 10. #figure of merit\n",
- "rd = 300 #diode temperature(K)\n",
- "C = 0.01*10**-12 #capacitance(F)\n",
- "Td = 300\n",
- "To = 300\n",
- "\n",
- "#Calculations\n",
- "#Part a\n",
- "ws = 2*pi*fs\n",
- "wi = 2*pi*fi\n",
- "R = (r**2)/(ws*wi*C**2*RTi)\n",
- "a = R/RTs\n",
- "\n",
- "#Part b\n",
- "G = (4*fi*Rg*Ri*a)/(fs*RTs*RTi*(1-a)**2)\n",
- "g = 10*math.log10(G)\n",
- "\n",
- "#Part c\n",
- "F = 1+((2*Td)/To)*((1/rQ)+(1/rQ**2))\n",
- "f = 10*math.log10(F)\n",
- "\n",
- "#Part d\n",
- "BW = (r/2)*math.sqrt(fd/(fs*G))\n",
- "\n",
- "#Results\n",
- "print \"Equivalent noise resistance =\",round(a,2),\"Ohms\"\n",
- "print \"Gain =\",round(g,2),\"dB\"\n",
- "print \"Noise figure =\",round(f,2),\"dB\"\n",
- "print \"Bandwidth =\",round(BW,3),\"(Calculation error in the textbook)\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Equivalent noise resistance = 1.55 Ohms\n",
- "Gain = 20.09 dB\n",
- "Noise figure = 0.86 dB\n",
- "Bandwidth = 0.027 (Calculation error in the textbook)\n"
- ]
- }
- ],
- "prompt_number": 5
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:f43deb1cbcb6a316216c1fc44f3f241bda49709364f3041975049a823ac19904" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 9:Solid State Microwave devices" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.1, Page number 411" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "L = 2*10**-6 #drift length(m)\n", + "Vd = 10**7*10**-2 #dfrift velocit(m/s)\n", + "\n", + "#Calculations\n", + "f = Vd/(2*L)\n", + "\n", + "#Results\n", + "print \"Frequncy of IMPATT diode is\",round((f/1E+9),2),\"GHz\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Frequncy of IMPATT diode is 25.0 GHz\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.2, Page number 411" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "f = 10*10**9 #operating frequency(Hz)\n", + "L = 75*10**-6 #device length(m)\n", + "V = 25. #voltage pulse amplified(V)\n", + "\n", + "#Calculations\n", + "Eth = V/(L)\n", + "\n", + "#Result\n", + "print \"The threshold electric field is\",round((Eth/1E+5),2),\"KV/cm\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The threshold electric field is 3.33 KV/cm\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.3, Page number 411" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "fs = 2*10**9 #signal frequency(Hz)\n", + "fp = 12*10**9 #pump frequency(Hz)\n", + "Ri = 16 #output resistance of signal generator(Ohms)\n", + "Rs = 1*10**3 #resistance of signal generator(Ohms)\n", + "\n", + "#Calculations\n", + "#Part a \n", + "P = 10*math.log10((fp-fs)/fs)\n", + "\n", + "#Part b\n", + "Pc = 10*math.log10((fp+fs)/fs)\n", + "\n", + "#Results\n", + "print \"Please note that there are calculation mistakes in the textbook. Hence, the difference in answers.\\n\"\n", + "print \"Power gain =\",round(P,2),\"dB\"\n", + "print \"Power gain as USB converter =\",round(Pc,2),\"dB\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please note that there are calculation mistakes in the textbook. Hence, the difference in answers.\n", + "\n", + "Power gain = 6.99 dB\n", + "Power gain as USB converter = 8.45 dB\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.4, Page number 411" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "Es = 12.5 #relative dielectric constant\n", + "N = 3.2*10**22 #donor concentration(/m**3)\n", + "L = 8*10**-6 #length(m)\n", + "Eo = 8.854*10**-12 #dielectric constant\n", + "q = 1.6*10**-19\n", + "\n", + "#Calculations\n", + "#Part a\n", + "Vc = (q*N*L**2)/(2*Eo*Es)\n", + "\n", + "#Part b\n", + "Vbd = 2*Vc\n", + "\n", + "#Part c\n", + "Ebd = Vbd/L\n", + "\n", + "#Results\n", + "print \"Critical voltage =\",round((Vc/1E+3),2),\"kV\"\n", + "print \"Breakdown voltage =\",round((Vbd/1E+3),2),\"kV\"\n", + "print \"Breakdown electric field =\",round((Ebd/1E+8),2),\"*10**8 V/cm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Critical voltage = 1.48 kV\n", + "Breakdown voltage = 2.96 kV\n", + "Breakdown electric field = 3.7 *10**8 V/cm\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.5, Page number 412" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "Na = 2.5*10**16 #doping concentration(/cm**3)\n", + "J = 33*10**3 #current density(A/cm**2)\n", + "q = 1.6*10**-19\n", + "\n", + "#Calculations\n", + "Vz = J/(q*Na)\n", + "\n", + "#Results\n", + "print \"The avalanche zone velocity is\",round((Vz/1E+6),2),\"*10**6 cm/s\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The avalanche zone velocity is 8.25 *10**6 cm/s\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.6, Page number 412" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "Rd = -25 #negative resistance(Ohms)\n", + "Rl = 50 #load resistance(Ohms)\n", + "\n", + "#Calculations\n", + "G = ((Rd-Rl)/(Rd+Rl))**2\n", + "\n", + "#Results\n", + "print \"Power gain =\",G" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Power gain = 9\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.7, Page number 412" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "L = 5.*10**-6 #drift length(m)\n", + "V = 3.3*10**3 #voltagradient(V/cm)\n", + "\n", + "#Calculation\n", + "Vmin = V*L\n", + "\n", + "#Result\n", + "print \"The minimum voltage required is\",round(Vmin,4),\"V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The minimum voltage required is 0.0165 V\n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.8, Page number 412" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable declaration\n", + "Vd = 2*10**7 #drift velocity(cm/s)\n", + "L = 20*10**-6 #active lengh(m)\n", + "Ec = 3.3*10**3 #crtical field(GaAs)\n", + "\n", + "#Calculations\n", + "f = Vd/L\n", + "V = L*Ec\n", + "\n", + "#Results\n", + "print \"Please note that there are calculation mistakes in the textbook. Hence, the difference in answers.\\n\"\n", + "print \"Rational frequency =\",round((f/1E+9),2),\"GHz\"\n", + "print \"Critical voltage =\",round(V,3),\"V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please note that there are calculation mistakes in the textbook. Hence, the difference in answers.\n", + "\n", + "Rational frequency = 1000.0 GHz\n", + "Critical voltage = 0.066 V\n" + ] + } + ], + "prompt_number": 40 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.9, Page number 412" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "from math import pi,sqrt\n", + "\n", + "#Variable declaration\n", + "Cj = 0.5*10**-12 #capacitance of IMPATT diode(F)\n", + "Lp = 0.5*10**-9 #Inductance of IMPATT diode(H)\n", + "Vbd = 100 #breakdown voltage(V)\n", + "Ib = 100*10**-3 #dc bias current(A)\n", + "Ip = 0.8 #peak current(A)\n", + "Rl = 2 #load resistance(Ohms)\n", + "\n", + "#Calculations\n", + "f = 1/(2*pi*sqrt(Lp*Cj))\n", + "Pl = ((Ip**2)*Rl)/2\n", + "Pdc = Vbd*Ib\n", + "N = (Pl/Pdc)*100\n", + "\n", + "#Results\n", + "print \"The resonant frequency is\",round((f/1E+9),1),\"GHz\"\n", + "print \"Efficiency is\",round(N,2),\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The resonant frequency is 10.1 GHz\n", + "Efficiency is 6.4 %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.10, Page number 413" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#Variable declaration\n", + "Vd = 10**5 #carrier dirft velocity(cm/s)\n", + "L = 2*10**-6 #drift length(m)\n", + "\n", + "#Calculations\n", + "#Part a\n", + "tou = L/Vd\n", + "\n", + "#Part b\n", + "f = 1/(2*tou)\n", + "\n", + "#Results\n", + "print \"Drift time of the carrier is\",round((tou/1E-11),2),\"*10**-11 sec\"\n", + "print \"Operating frequency of diode is\",(f/1E+9),\"GHz\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Drift time of the carrier is 2.0 *10**-11 sec\n", + "Operating frequency of diode is 25.0 GHz\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.11, Page number 413" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#Variable declaration\n", + "Er = 11.8 #relative dielectric constant\n", + "N = 3*10**21 #donor concentration(m^-3)\n", + "L = 6.2*10**-6 #Si length(m)\n", + "q = 1.6*10**-19 #charge of an electron(C)\n", + "Eo = 8.854*10**-12 #dielctric constant\n", + "\n", + "#Calculations\n", + "#Part a\n", + "Vbd = (q*N*L**2)/(Eo*Er)\n", + "\n", + "#Part b\n", + "Ebd = Vbd/L\n", + "\n", + "#Results\n", + "print \"Breakdown voltage =\",round(Vbd,1),\"V\"\n", + "print \"Breakdown electric field =\",round((Ebd/1E+7),2),\"*10**7 V/m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Breakdown voltage = 176.6 V\n", + "Breakdown electric field = 2.85 *10**7 V/m\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.12, Page number 413" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "rQ = 8. #figure of merit\n", + "fo_fs = 8. #ratio of o/p to i/p frequency\n", + "Td = 300. #diode temperatur(K)\n", + "To = 300. #ambient temperature(K)\n", + "r = 0.2\n", + "\n", + "#Calculations\n", + "#Part a\n", + "X = rQ**2/fo_fs\n", + "G = (X/((1+math.sqrt(1+X))**2))*fo_fs\n", + "g = 10*math.log10(G)\n", + "\n", + "#Part b\n", + "F = 1+((2*Td)/To)*((1/rQ)+(1/rQ**2))\n", + "f = 10*math.log10(F)\n", + "\n", + "#Part c\n", + "BW = 2*r*math.sqrt(fo_fs)\n", + "\n", + "#Results\n", + "print \"Maximum power gain =\",round(g,2),\"dB\"\n", + "print \"Noise figure =\",round(f,2),\"dB\"\n", + "print \"Bandwidth =\",round(BW,2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum power gain = 6.02 dB\n", + "Noise figure = 1.08 dB\n", + "Bandwidth = 1.13\n" + ] + } + ], + "prompt_number": 41 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.13, Page number 414" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "fs = 2*10**9 #signal frequency(Hz)\n", + "fp = 12*10**9 #amplifier frquency(Hz)\n", + "fi = 10*10**9 #input frequency(Hz)\n", + "fd = 5*10**9 #diode frequency(Hz)\n", + "Ri = 1*10**3 #input resistance(Ohms)\n", + "Rg = 1*10**3 #gate resistance(Ohms)\n", + "RTs = 1*10**3 #resistance(Ohms)\n", + "RTi = 1*10**3 #resistance(Ohms)\n", + "r = 0.35 #resistane(Ohms)\n", + "rQ = 10. #figure of merit\n", + "rd = 300 #diode temperature(K)\n", + "C = 0.01*10**-12 #capacitance(F)\n", + "Td = 300\n", + "To = 300\n", + "\n", + "#Calculations\n", + "#Part a\n", + "ws = 2*pi*fs\n", + "wi = 2*pi*fi\n", + "R = (r**2)/(ws*wi*C**2*RTi)\n", + "a = R/RTs\n", + "\n", + "#Part b\n", + "G = (4*fi*Rg*Ri*a)/(fs*RTs*RTi*(1-a)**2)\n", + "g = 10*math.log10(G)\n", + "\n", + "#Part c\n", + "F = 1+((2*Td)/To)*((1/rQ)+(1/rQ**2))\n", + "f = 10*math.log10(F)\n", + "\n", + "#Part d\n", + "BW = (r/2)*math.sqrt(fd/(fs*G))\n", + "\n", + "#Results\n", + "print \"Equivalent noise resistance =\",round(a,2),\"Ohms\"\n", + "print \"Gain =\",round(g,2),\"dB\"\n", + "print \"Noise figure =\",round(f,2),\"dB\"\n", + "print \"Bandwidth =\",round(BW,3),\"(Calculation error in the textbook)\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Equivalent noise resistance = 1.55 Ohms\n", + "Gain = 20.09 dB\n", + "Noise figure = 0.86 dB\n", + "Bandwidth = 0.027 (Calculation error in the textbook)\n" + ] + } + ], + "prompt_number": 5 + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch10.ipynb b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch10.ipynb index d814a959..c6aa5bdf 100644 --- a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch10.ipynb +++ b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch10.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:45cc28c15d520b01f5e80bb34453647affc5cb5c7ebd0520e71c71e74dcb84cd" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,34 +28,40 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find values using\n", - "Raoult's law\n", - "from L-R rule\n", - "'''\n", "\n", "\n", "import math \n", "\n", + "# Variables\n", "P = 100. #[psia] Bubble point pressure\n", "x_ethane = 0.10 # Mole fraction of ethane in liquid phase\n", "x_hepmath_tane = (1-x_ethane)\n", "\n", + "# a) From figure 10.7( page 260 ) given in the book\n", + "# We read the chart to get the bubble-point temperature\n", + "# The dew point curve for 100 psia crosses the 10 mol% ethane line at about temperature \n", "T1 = 165. #[C]\n", + "# Now, we horizontally from that intersection point to the dew-point curve, finding the vapor phase composition of ethane \n", "y1_e = 0.92\n", "y1_h = (1- y1_e)\n", "\n", + "# b) By Raoult's law, we use a trial and error procedureon the temperature\n", + "# Antoine equation consmath.tants for ethanol are given \n", "A_e = 6.80267\n", "B_e = 656.4028\n", "C_e = 255.99\n", "\n", + "# and that for n-hepmath_tane are\n", "A_h = 6.9024\n", "B_h = 1268.115\n", "C_h = 216.9\n", "\n", + "# Antoine equation is given by\n", + "# (math.log10p) = (A - B/(T+C))\n", "T = 50. #[C]\n", "err = 1.\n", " \n", + "# Calculations\n", "while err > 10**(-4):\n", " p1_e = (10**(A_e - B_e/(C_e + T)))*(14.7/760)\n", " p1_h = (10**(A_h - B_h/(C_h + T)))*(14.7/760)\n", @@ -63,11 +70,18 @@ " err = abs((y2_e + y2_h) - 1)\n", " T = T + 0.0001\n", "\n", + "# Changing the temperature in deg F \n", "T2 = T*9./5 + 32 #[F] Bubble-point temperature\n", "\n", + "# c) In this method, we use L-R rule, instead of simple Raoult's law\n", + "# So,\n", + "# y_i = (x_i*p_i)/(v_i*P)\n", + "# Where calculated values of v_i from EOS are given in the table 10.A and are \n", "v_e = 0.950 # For ethane\n", "v_h = 0.459 # For n-hepmath_tane\n", "\n", + "# We again use trial and error on the temperature\n", + "# Let us assume the initial temperature \n", "Ti = 50. #[C]\n", "err = 1\n", " \n", @@ -79,8 +93,10 @@ " err = abs((y3_e + y3_h) - 1)\n", " Ti = Ti + 0.0001\n", "\n", + "# Changing the temperature in deg F \n", "T3 = Ti*9./5 + 32 #[F] Bubble-point temperature\n", "\n", + "# Results\n", "print \" The results are summarized in the following table:\"\n", "print \" Variable \\t Values calculated from\\t Values calculated from \\t Values calculated \"\n", "print \" \\t from figure 10.7 \\t Raoult''s law \\t\\t\\t from L-R rule\"\n", @@ -121,34 +137,42 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Tdeg\n", - "y_ethane\n", - "y_hepmath_tane\n", - "'''\n", - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "P = 800. #[psia] Bubble point pressure\n", "x_ethane = 0.60 # Mole fraction of ethane in liquid phase\n", "x_hepmath_tane = (1-x_ethane)\n", "\n", + "# a) From figure 10.7( page 260 ) given in the book\n", + "# We read the chart to get the bubble-point temperature\n", + "# The dew point curve for 800 psia crosses the 60 mol% ethane line at about temperature \n", + "# T1 = 165\n", + "# Now, we horizontally from that intersection point to the dew-point curve, finding the vapor phase composition of ethane \n", + "# y1_e = 0.95\n", + "# But, by linear interpolation in the experimental data on which Figure 10.7 is based we make a slightly more reliable estimate and get \n", "T1 = 209. #[F]\n", "y1_e = 0.945\n", "y1_h = (1- y1_e)\n", "\n", + "# b) By Raoult's law, we use a trial and error procedureon the temperature\n", + "# Antoine equation consmath.tants for ethanol are given \n", "A_e = 6.80267\n", "B_e = 656.4028\n", "C_e = 255.99\n", "\n", + "# and that for n-hepmath_tane are\n", "A_h = 6.9024\n", "B_h = 1268.115\n", "C_h = 216.9\n", "\n", + "# Antoine equation is given by\n", + "# (math.log10p) = (A - B/(T+C))\n", "T = 50. #[C]\n", "err = 1.\n", " \n", + "# Calculations\n", "while err > 10**(-4):\n", " p1_e = (10**(A_e - B_e/(C_e + T)))*(14.7/760)\n", " p1_h = (10**(A_h - B_h/(C_h + T)))*(14.7/760)\n", @@ -157,11 +181,18 @@ " err = abs((y2_e + y2_h) - 1)\n", " T = T + 0.0001\n", "\n", + "# Changing the temperature in deg F \n", "T2 = T*9./5 + 32 #[F] Bubble-point temperature\n", "\n", + "# c) In this method, we use L-R rule, instead of simple Raoult's law\n", + "# So,\n", + "# y_i = (x_i*p_i)/(v_i*P)\n", + "# Where calculated values of v_i from EOS are given \n", "v_e = 0.6290642 # For ethane\n", "v_h = 0.0010113 # For n-hepmath_tane\n", "\n", + "# We again use trial and error on the temperature\n", + "# Let us assume the initial temperature \n", "Ti = 10. #[C]\n", "err = 1.\n", " \n", @@ -173,8 +204,10 @@ " err = abs((y3_e + y3_h) - 1)\n", " Ti = Ti + 0.0001\n", "\n", + "# Changing the temperature in deg F \n", "T3 = Ti*9./5 + 32 #[F] Bubble-point temperature\n", "\n", + "# Results\n", "print \" The results are summarized in the following table:\"\n", "print \" \\t Variable \\t\\t Values calculated from\\t Values calculated from Values calculated\"\n", "print \" \\t\\t\\t\\t from figure 10.7 \\t Raoult''s law \\t\\t from L-R rule\"\n", @@ -216,39 +249,51 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Bubble point of the given ethanol and n-heptane mixture at 800 psia\n", - "Amount of ethanol in the vapour phase of the mixture at the given condition\n", - "Amount of n-heptane in the vapour phase of the mixture at the given \n", - "'''\n", + " \n", "\n", "from scipy.optimize import fsolve \n", "import math \n", "\n", + "# Variables\n", + "# The initial data for this example is same as that of example 10.2, i.e.\n", "P = 800. #[psia] Bubble point pressure\n", "x_e = 0.60 # Mole fraction of ethane in liquid phase\n", "x_h = (1-x_e) # Mole fraction of n-hepmath.tane in the liquid phase\n", "R = 0.08314 #( L*bar/(mol*K)) Universal gas consmath.tant \n", "\n", + "# Changing the pressure in bar\n", "Pb = (800/14.7)*(1.01325) #[bar]\n", "\n", + "# In this problem we will denote ethane by 'e' and that to n-hepmath.tane by 'h'\n", + "# From table A.1 ( page 417 ) given in the book, critical temperatures of ethane and hepmath.tane are \n", "T_c_e = 305.3 #[K]\n", "T_c_h = 540.2 #[K]\n", "\n", + "# and critical pressures are\n", "P_c_e = 48.72 #[bar]\n", "P_c_h = 27.40 #[bar]\n", "\n", + "# also the accentric facors are \n", "w_e = 0.1\n", "w_h = 0.35\n", "\n", + "# Thus we have\n", "P_r_e = Pb/P_c_e\n", "P_r_h = Pb/P_c_h\n", "\n", + "# Now from equations (F.13) and (F.14) ( page 459 ) given in the book we have\n", + "# A_e = 0.42747 + ( 1 + (0.480 + 1.574*w_e - 0.17*w_e**(2))*( 1 - T_r_e**(0.5)))**(2)*(P_r_e/T_r_e**(2))\n", + "# A_h = 0.42747 + ( 1 + (0.480 + 1.574*w_h - 0.17*w_h**(2))*( 1 - T_r_h**(0.5)))**(2)*(P_r_h/T_r_h**(2))\n", + "# and\n", + "# B_e = 0.08664*(P_r_e/T_r_e)\n", + "# B_h = 0.08664*(P_r_h/T_r_h)\n", "\n", + "# We will take the help trial and error method both on Temperature and the vapor phase composition of ethane\n", + "# Let us assume the starting temperature 200 deg F. Changing this temperature in K\n", "T = (200-32)*5./9 + 273.15 #[K]\n", "err = 1\n", "\n", + "# Calculations\n", "while err > 10**(-4):\n", " T_r_e = T/T_c_e\n", " T_r_h = T/T_c_h\n", @@ -293,12 +338,15 @@ " T = T + 0.1\n", "\n", "\n", + "# Changing the temperature in deg F, we have \n", "Tf = ( T - 273.15)*9./5 + 32 #[F]\n", "\n", + "# Results\n", "print \" Bubble point of the given ethanol and n-hepmath.tane mixture at 800 psia is %f deg F\"%(Tf)\n", "print \" Amount of ethanol in the vapour phase of the mixture at the given condition is %f \"%(y_e1)\n", "print \" Amount of n-heptane in the vapour phase of the mixture at the given condition is %f \"%(y_h1)\n", "\n", + "# Answers may vary because of rounding error." ], "language": "python", "metadata": {}, diff --git a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch11.ipynb b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch11.ipynb index 24212b64..f7d878eb 100644 --- a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch11.ipynb +++ b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch11.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:60047896579d8db89aebcb768a47215eec82ab7f225717125cd44a8e3788cb2b" }, "nbformat": 3, "nbformat_minor": 0, @@ -108,12 +109,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Mol water\n", - "Mol ethanol\n", - "Mol benzene\n", - "'''\n", + "\n", "import math \n", "\n", "Temp = 25. #[C]\n", @@ -168,11 +164,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Activity coefficient of benzene in water\n", - "Activity coefficient of water in benzene\n", - "'''\n", + "\n", "import math \n", "\n", "Temp = 25. #[C]\n", @@ -367,11 +359,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Heat of mixing of water-in-benzene\n", - "Heat of mixing of benzene-in-water\n", - "'''\n", + "\n", "import math \n", "\n", "R = 8.314 #[J/(ml*K)]\n", @@ -456,11 +444,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Ethanol's 0.1 mol distributed in the water rich phase\n", - "Ethanol's 0.1 mol distributed in the benzene rich phase\n", - "'''\n", + "\n", "\n", "from numpy import *\n", "from matplotlib.pyplot import *\n", @@ -527,11 +511,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Weight fraction of the NaCl in the saturated solution \n", - "Mol fraction of the NaCl in the saturated solution\n", - "'''\n", + "\n", "\n", "import math \n", "\n", @@ -577,11 +557,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Total amount of the solid left behind in the heater\n", - "Total amount of the solid left behind in the heater\n", - "'''\n", + "\n", "\n", "import math \n", "\n", @@ -630,11 +606,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Activity coefficient in benzene corresponding to practically ideal solution \n", - "Activity coefficient in CCl4 corresponding to mild type II behavior \n", - "'''\n", + "\n", "\n", "import math \n", "\n", diff --git a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch12.ipynb b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch12.ipynb index dece46d0..210f4e9f 100644 --- a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch12.ipynb +++ b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch12.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:0a1da29e7840a18bf7735e26f0a43477053969d9c5f5a2bfceee638c83ec8906" }, "nbformat": 3, "nbformat_minor": 0, @@ -70,13 +71,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "The equilibrium consmath.tant for the reaction\n", - "The concentration of NO at equilibrium\n", - "The equilibrium constant\n", - "The concentration of NO \n", - "'''\n", + "\n", "import math \n", "\n", "T = 298.15 #[K] temperature\n", @@ -186,12 +181,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Concentration of the ethylene \n", - "Concentration of the water \n", - "Concentration of the ethanol\n", - "'''\n", + "\n", "\n", "from scipy.optimize import fsolve \n", "import math \n", @@ -245,11 +235,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "The equilibrium mol fraction of the hydrogen \n", - "And the equilibrium mol fraction of the oxygen\n", - "'''\n", + "\n", "\n", "from scipy.optimize import fsolve \n", "import math \n", @@ -305,11 +291,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Total change in the free energy of water going under given conditions \n", - "and the free energy change\n", - "'''\n", + "\n", "import math \n", "from scipy.integrate import quad \n", "\n", @@ -456,11 +438,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "The mole fraction of NH3 in the equilibrium\n", - "The mole fraction of NH3 in the equilibrium\n", - "'''\n", + "\n", "\n", "from scipy.optimize import fsolve \n", "import math \n", @@ -610,11 +588,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "On increasing the pressure from 1 atm to 150 atm the reacted amount of the equimolar\n", - "reactants at equilibrium becomes times of initial\n", - "'''\n", + "\n", "\n", "from scipy.optimize import fsolve \n", "import math \n", diff --git a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch13.ipynb b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch13.ipynb index 810ca173..b398bb05 100644 --- a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch13.ipynb +++ b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch13.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:ce47d914f54a1d45d40a3d6f4d1380a1b0ebd1de3c08f3c2df6139c5199b3710" }, "nbformat": 3, "nbformat_minor": 0, @@ -72,13 +73,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "The equilibrium concentration of H2SO4 in terms of molality\n", - "The equilibrium concentration of HSO4- in terms of molality\n", - "The equilibrium concentration of SO4-- in terms of molality\n", - "The equilibrium concentration of H+ in terms of molality\n", - "'''\n", + "\n", "\n", "\n", "from scipy.optimize import fsolve \n", @@ -158,11 +153,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Percent conversion of CO\n", - "Percent conversion of CO2\n", - "'''\n", + "\n", "\n", "from scipy.optimize import fsolve \n", "import math \n", @@ -286,12 +277,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Amount of the CO2 dissolved in water in equilibrium with air\n", - "Conentration of HCO3 ion and hydrogen ion H- in solution in equilibrium with air\n", - "And concentration of CO3 ion in the solution in equilibrium with air\n", - "'''\n", + "\n", "\n", "import math \n", "\n", @@ -356,12 +342,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Amount of the CO2 dissolved in water in equilibrium with air\n", - "Conentration of HCO3 ion in solution in equilibrium with air\n", - "And concentration of CO3 ion in the solution in equilibrium with air\n", - "'''\n", + "\n", "\n", "import math \n", "\n", @@ -568,11 +549,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Mole fraction of the monomer in the vapour phase\n", - "Mole fraction of the dimer in the vapour phase\n", - "'''\n", + "\n", "\n", "from scipy.optimize import fsolve \n", "import math \n", diff --git a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch2.ipynb b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch2.ipynb index fc8059ee..aa52001e 100644 --- a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch2.ipynb +++ b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch2.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:0a185017fb6d8b2f89e2c9757a0bd5f1ee2fdeb7cbf86205eb93a1d0a3214502" }, "nbformat": 3, "nbformat_minor": 0, @@ -28,36 +29,50 @@ "cell_type": "code", "collapsed": false, "input": [ - "''' Calculate internal energy of the steam\n", - "enthalpy of the steam,entropy of the steam and Piston expanding.\n", - "'''\n", + " \n", "import math \n", "\n", + "# Variables\n", "m = 1. #[lbm] Mass of the steam\n", "T_1 = 300. #[F] Initial temperature\n", "P_1 = 14.7 #[psia] Initial pressure\n", "P_sorronding = 14.7 #[psia]\n", "Q = 50. #[Btu] Amount of the energy added to the system as heat\n", "\n", + "# This is a closed system and we can apply the following equations\n", + "# delta_U_system = sum(dQ_in_minus_out) + sum(dW_in_minus_out) (A)\n", + "# dS_system = (m*ds)_system = sum((dQ)/T)_in_minus_out + dS_reversible (B)\n", "\n", + "# From the steam tables, we look up the properties of steam at temperature 300F and pressure 14.7 psia and find \n", "u_initial = 1109.6 #[Btu/lbm] Internal energy of the steam\n", "h_initial = 1192.6 #[Btu/lbm] Enthalpy of the steam\n", "s_initial = 1.8157 #[Btu/(lbm*R)] Entropy of the steam\n", "\n", + "# The work here is done by the system, equal to\n", + "# -delta_w = P*A_piston*delta_x = P*m*delta_v\n", "\n", + "# Calculations\n", + "# Substituting this in the equation (A) and rearranging, we have\n", + "# m*delta_(u + P*v) = m*delta_h = delta_Q\n", + "# From which we can solve for the final specific enthalpy\n", "h_final = h_initial + Q #[Btu/lbm]\n", "\n", + "# Now, by the linear interpolation we find that at h = 1242.6 Btu/lbm and P = 1 atm, temperature of the steam is given \n", "T_2 = 405.7 #[F] Final temperature\n", "\n", + "# At this final temperature and pressure we have the steam properties \n", "u_final = 1147.7 #[Btu/lbm]\n", "s_final = 1.8772 #[Btu/(lbm*R)]\n", "\n", + "# Thus, increase in the internal energy, enthalpy and entropy are \n", "delta_u = u_final - u_initial #[Btu/lbm]\n", "delta_s = s_final - s_initial #[Btu/(lbm*R)]\n", "delta_h = Q #[Btu/lbm]\n", "\n", + "# The work done on the atmosphere is given by\n", "w = delta_h - delta_u #[Btulbm]\n", "\n", + "# Results\n", "print \"The increase in internal energy of the steam by adding the heat is %0.2f Btu/lbm\"%(delta_u)\n", "print \"The increase in enthalpy of the steam by adding the heat is %0.2f Btu/lbm\"%(delta_h)\n", "print \"The increase in entropy of the steam by adding the heat is %0.4f Btu/lbm\"%(delta_s)\n", @@ -91,25 +106,40 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "T_in = 600. #[F] Input steam temperature\n", "P_in = 200. #[psia] Input steam pressure\n", "P_exit = 50. #[psia]\n", "\n", + "# Because this is a steady-state, steady-flow process, we use \n", + "# (work per pound) = W/m = -( h_in - h_out )\n", "\n", + "# From the steam table we can read the the inlet enthalpy and entropy as \n", "h_in = 1322.1 #[Btu/lbm]\n", "s_in = 1.6767 #[Btu/(lb*R)]\n", "\n", + "# Now, we need the value of h_out\n", "\n", + "# For a reversible adiabatic steady-state, steady-flow process, we have\n", + "# sum(s*m_in_minus_out) = ( s_in - s_out ) = 0\n", "\n", + "# Which indicates that inlet and outlet entropies are same\n", + "# We can find the outlet temperature by finding the value of the temperature in the steam table\n", + "# For which the inlet entropy at 50 psia is the same as the inlet entropy, 1.6767 Btu/(lb*R). \n", + "# By linear interpolation in the table we find \n", "T_in = 307.1 #[R]\n", "\n", + "# and by the linear interpolation in the same table we find that\n", "h_out = 1188.1 #[Btu/lb]\n", "\n", + "# Calculations\n", + "# Thus, we find \n", "W_per_pound = (h_in - h_out) #[Btu/lb]\n", "\n", + "# Results\n", "print \" The work output of the turbine of steam is %0.1f Btu/lb\"%(-W_per_pound)\n" ], "language": "python", @@ -137,13 +167,17 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", "\n", + "# Variables\n", "T = 500. #[F]\n", "P = 680. #[psi]\n", "\n", + "# Calculations\n", + "# It is reported in the book in the table A.1(page 417) that for water \n", + "# We know that T_r = T/T_c and P_r = P/P_c, so\n", "T_c = 647.1*1.8 #[R]\n", "P_c = 220.55*14.51 #[psia]\n", "w = 0.345\n", @@ -153,7 +187,9 @@ "z_1 = P_r/T_r*(0.139-0.172/T_r**(4.2))\n", "z = z_0+w*z_1\n", "\n", + "# Results\n", "print \"The compressibility factor of steam at the given state is %0.3f\"%(z)\n", + "# Based on the steam table (which may be considered as reliable as the experimental data, the value of z is 0.804.\n" ], "language": "python", "metadata": {}, diff --git a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch5.ipynb b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch5.ipynb index 259744fa..df919019 100644 --- a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch5.ipynb +++ b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch5.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:45c34efa92ef22d9ef4ef3ec497299bfe0d1792fe0aef4bcd0da61b878004248" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,22 +28,32 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", "\n", + "# Variables\n", "T=212. # [F]\n", "\n", + "#**********#\n", + "#From the steam table, we have \n", "delta_h=970.3 #[Btu/lbm]\n", "delta_v=26.78 #[ft**(3)/lbm] and\n", "\n", + "# Calculations\n", + "# changing the units\n", "delta_h1=delta_h*778 #[ft*lbf/lbm]\n", "delta_v1=delta_v*144 #[ft*in**(2)/lbm]\n", "T=671.7 #[R]\n", "\n", + "# We have dP/dT = delta_h/(T*delta_v)\n", + "#Thus\n", "dP_by_dT=delta_h1/(T*delta_v1) #[psi/R]\n", "\n", + "# Results\n", "print \"The value of dP/dT is %f psi/R\"%(dP_by_dT)\n", + "#Using the nearest adjacent steam table entries for vapour pressure, wee have \n", + "#dP_by_dT = delta_P_by_delta_T=(15.291-14.125)/(214-210)=0.2915 psi/R\n" ], "language": "python", "metadata": {}, @@ -69,21 +80,32 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "p_2=0.005 # [psia]\n", "R=1.987/18. #[1/R]\n", "\n", + "#From the steam tables at the tripple point, we find \n", "T_1=460+32.018 #[R]\n", "p_1=0.0887 #[psia]\n", "\n", + "#delta_h(solid to gas) = delta_h(sublimation) = 1218.7#[Btu/lbm]\n", "delta_H=1218.7 #[Btu/lbm]\n", + "#Assuming that the enthalpy change of vaporization is independent of temperature (a fairly good approximation in this case)\n", + "#we start with Eq. 5.10 and rearrange:\n", + "#1/T_2 = 1/T_1-(math.log(p_2/p_1))*R/delta_H\n", + "#So\n", "\n", + "# Calculations\n", "T_2=1/(1/T_1-(math.log(p_2/p_1))*R/delta_H) #[R]\n", + "#Changing the temperature in farenheit\n", "T_2F=T_2-460 #[F]\n", "\n", + "# Results\n", "print \"The temperature is %.2f F\"%(T_2F)\n", + "#BY linear interpolation in the steam tables, one finds -23.8 F. Because of imprecision of linear interpolation, these values are approximately equal.\n" ], "language": "python", "metadata": {}, @@ -110,18 +132,27 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", - "\n", + " \n", "import math \n", "from numpy import *\n", "\n", + "# Variables\n", "T_3=1155.2 #[R]\n", "T_2=652.9 #[R]\n", "T_1=787.5 #[R]\n", "p_2=10. #[psia]\n", "p_1=100. #[psia]\n", "\n", + "# Calculations\n", + "#******#\n", + "#Here we can write Eq. 5.9 as reported in the book in the form most often seen.\n", + "# math.log(p)=A-B/T\n", + "#Where A and B are consmath.tants to be determined from the pair of T and p values above.\n", "\n", + "#we simply write \n", + "#math.log(10)=A-B/652.9\n", + "#math.log(100)=A-B/787.5\n", + "# We have to solve the above two simulmath.taneous equations having two vaiables A and B.\n", "\n", "M = matrix([[1, -1/652.9],[1,-1/787.5]])\n", "C = array([[math.log(10)],[math.log(100)]])\n", @@ -130,10 +161,14 @@ "A=X[0]\n", "B=X[1]\n", "\n", + "# By straightforward algebra we find the values of A and B. Thus, for 1155.2 R we have \n", "p_3=math.exp(A-B/T_3)\n", "\n", + "# Results\n", "print \"Vapuor pressure of water at given temperature is %f psia\"%(p_3)\n", "\n", + "# p_3=3499 psia. \n", + "# Note : \"It has been reported in the book that from table 5.1 we see that the correct value is 3000 psia. Thus there is an error of 16% in the predicted pressure.\"\n", "\n" ], "language": "python", @@ -161,14 +196,20 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", + "# At Tr = 0.7, we read \n", "Pr=0.023\n", + "# and thus accentric factor is given by\n", "\n", + "# Calculations\n", "w=-math.log10(0.023)-1\n", "\n", + "# Results\n", "print \"The accentric factor based on the given data is %f\"%(w)\n", + "#It has been reported in the book that table A.1 shows that the value based on the best data is 0.645.\n" ], "language": "python", "metadata": {}, @@ -195,18 +236,29 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", + "#From Antoine equation we have \n", + "# math.log(p) = A-B/(T+C)\n", + "#Solving above equation for T, we have\n", + "# T = B/(A-math.log(p))-C\n", + "#Inserting the values of the consmath.tants for the water which are reported in the given book in the table A.2 (page 419),\n", + "# and the value of 1.00 atm expressed in torr, we find that \n", "A=7.96681\n", "B=1668.21\n", "C=228.0\n", "p=760. #[torr]\n", "\n", + "# Calculations\n", + "#Thus\n", "T=B/(A-math.log10(p))-C\n", "\n", + "# Results\n", "print \"NBP of water umath.sing antoine equation and table A.2 is %f C\"%(T)\n", "\n", + "#This does not prove the overall accuracy of the Antoine equation, but does show that whoever fitted the consmath.tants to the experimental data for water made them represent the NBP (100C) very well. \n" ], "language": "python", "metadata": {}, @@ -233,26 +285,43 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "T_2=-22. #[C]\n", + "# converting temperature in farenheit\n", "T_2F=T_2*9/5+32 #[F]\n", + "#Expressing T_2 in Rankine\n", "T_2R=460+T_2F #[R]\n", + "#delta_h = delta_h(fusion)\n", "delta_h=143.35*778. #[ft*lbf/lbm]\n", + "#delta_v = v_water-v_ice\n", "delta_v=0.01602-0.01747 #[ft**(3)/lbm]\n", + "# changing the unit \n", "delta_v1=delta_v*144 #[ft*in/lbm]\n", "\n", + "# Calculations\n", + "#and\n", "T_1=460+32. #[R]\n", "dP_by_dT=delta_h/(T_1*delta_v1) #[psi/R] at 32F\n", "delta_T=T_2R-T_1\n", "\n", + "#This gives the rigorously correct slope of the liquid-solid curve at 32F on a P-T diagram.\n", + "#Here we use P instead of p because neither phase is a gas, so this is not a vapour pressure. \n", + "#If we further assume that the solid-liquid curve is a straight line, which is equivalent to assuming that delta_h/(T*deta_v)is a consmath.tant over the region of interest, then we can estimate the pressure at -22C = -7.6F by\n", + "#So\n", "\n", "delta_P=(dP_by_dT)*delta_T #[psi]\n", "\n", + "# From this we can estimate the final pressure as\n", "delta_P=delta_P+0.09 #[psi]\n", "\n", + "# Results\n", "print \"Freezing preesure of water at given temperature is %f psi\"%(delta_P)\n", + "# In this case, the experimental pressure is well known, because this temperature corresponds to the tripple point between liquid and water, \n", + "# ice I(the common variety), and ice III, a variety that does not exist at pressure below about 30000 psia (see figure 1.10 in the book). \n", + "# The measured value is 30000 psia, which shows that our assumption of a straight line on a P-T plot (delta_h/(T*delta_v)=consmath.tant) is only approximately correct.\n", "\n" ], "language": "python", diff --git a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch6.ipynb b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch6.ipynb index 16c57280..ce95f234 100644 --- a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch6.ipynb +++ b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch6.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:b5e7bc5aa10585d1f719544046b71d6acecd3da70a2a86327271cc53390af498" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,25 +28,31 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "calculate\n", - "Partial molal volume of ethanol in water at zero molality\n", - "Partial molal volume of ethanol in water at unity molality \n", - "'''\n", - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "T = 20. #[C]\n", "m_1 = 0. #[molal]\n", "m_2 = 1. #[molal]\n", "\n", + "# Calculations\n", + "# The data given in the figure 6.2 , as reported in book, can be repersented with excellent accuracy by a simple data fitting equation\n", + "#V = 1.0019+0.054668*m-0.000418*m**(2)\n", + "# Where 'V' is( solution volume, liters per 1000g of water ) and 'm' is the molality of ethanol in water\n", + "#The partial molal volume is obtained by differentiating the expression of the 'V' with respect to 'm'\n", + "# v_ethanol = dV/dm = 0.054668-2*0.000418*m\n", + "# So that at zero molality \n", "m = 0 #[molal]\n", + "# the partial molal volume is \n", "v_1 = 0.054668-2*0.000418*m #[L/mol]\n", + "# and at\n", "m = 1. #[molal]\n", "v_2 = 0.054668-2*0.000418*m #[L/mol]\n", "v_1 = v_1*1000 #[cm**(3)/mol]\n", "v_2 = v_2*1000 #[cm**(3)/mol]\n", "\n", + "# Results\n", "print \"Partial molal volume of ethanol in water at zero molality is %f cm**3/mol\"%(v_1)\n", "print \" Partial molal volume of ethanol in water at unity molality is %f cm**3/mol\"%(v_2)\n" ], @@ -75,24 +82,34 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "n_eth = 1. #[mol]\n", "W_water = 1. #[kg]\n", "Temp = 20. #[C]\n", "\n", + "# For pure ethanol at 20C\n", "v_ethanol = 58.4 #[cm**(3)/mol]\n", "v_ethanol = v_ethanol/1000 # [L/mol]\n", "v_water = 1.0019 #[L/1000g]\n", "\n", + "# Calculations\n", + "# Molality of ethanol in water is\n", "m = n_eth/W_water #[molal]\n", + "# We have the equation used in the previous example as\n", "V_final_mix = 1.0019+0.054668*m-0.000418*m**(2)\n", "\n", + "# Where 'V' is( solution volume, liters per 1000g of water ) and 'm' is the molality of ethanol in water\n", + "# V is the final volume of the solution \n", + "# The volume expansion on moxing is \n", "V_exp = V_final_mix-v_ethanol-v_water #[L]\n", "V_exp = V_exp*1000 #[cm**(3)]\n", "\n", + "# Results\n", "print \"Volume change on mixing emath.tanol and water is %0.3f cubic cm\"%(V_exp)\n", + "# We see that there is a net contraction on mixing of the volume of the ethanol added.\n", "\n" ], "language": "python", @@ -120,17 +137,24 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", + "# All the data are same as in the previous example \n", + "# The equation 6.5 reported in the book is \n", "v_i_average = 0.05425 #[L/mol]\n", + "# and\n", "v_i_0 = 0.0584 #[L/mol]\n", "delta_n = 1.00 #[mol]\n", "\n", + "# Calculations\n", "delta_V_mixing = (v_i_average-v_i_0)*delta_n #[L]\n", "delta_V_mixing = delta_V_mixing*1000 #[cm**(3)]\n", "\n", + "# Results\n", "print \"Volume change on mixing etanol and water is %f cm**3\"%(delta_V_mixing)\n", + "# Which is same as the solution in example 6.2\n" ], "language": "python", "metadata": {}, @@ -157,29 +181,41 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "calculate\n", - "Partial molar volume of the ethanol \n", - "Partial molar volume of the water \n", - "'''\n", + " \n", "import math \n", "\n", + "# Variables\n", "m = 1. #[molal] Molality of the solution with respect to ethanol\n", "M_water = 18. #[g/mol] molecular weight of water\n", "\n", + "# Calculations\n", + "# First we convert molality to mole fraction\n", "x_ethanol = m/(m + 1000/M_water)\n", "\n", + "# For the low range of data point on figure 6.5(page 112), we can fit an equation\n", + "# (Specific volume ) = 0.018032 + 0.037002*x_ethanol - 0.039593*x_ethanol**(2) + 0.21787*x_ethanol**(3)\n", + "# This is applicable for (0 < x_ethanol < 0.04 ), which is the case we have\n", "\n", + "# So\n", "v_math_tan = 0.018032 + 0.037002*x_ethanol - \\\n", "0.039593*x_ethanol**(2) + 0.21787*x_ethanol**(3) #[L/mol]\n", "\n", + "# Now we will find the derivative of the specific volume with respect to x_ethanol at the known point x_ethanol\n", + "# (dv/dx_ethanol) = 0.037002 - 2*0.039593*x_ethanol + 3*0.21787*x_ethanol**(2)\n", + "# Hence\n", "v_derv_math_tan = 0.037002 - 2*0.039593*x_ethanol + 3*0.21787*x_ethanol**(2) #[L/mol]\n", "\n", + "# By simple geometry from the figure 6.6(page 113) of the book we find\n", + "# a = v_math_tan + (1-x_math_tan)*(dv/dx_1)_math_tan\n", + "# b = v_math_tan - x_math_tan*(dv/dx_1)_math_tan\n", "\n", + "# We have a = v_ethanol and b = v_water\n", "x_math_tan = x_ethanol\n", + "# So\n", "v_ethanol = v_math_tan + (1-x_math_tan)*(v_derv_math_tan) #[L/mol]\n", "v_water = v_math_tan - x_math_tan*(v_derv_math_tan) #[L/mol]\n", "\n", + "# Results\n", "print \" Partial molar volume of the ethanol in the given solution is %f L/mol\"%(v_ethanol)\n", "print \" Partial molar volume of the water in the given solution is %f L/mol\"%(v_water)\n" ], @@ -209,25 +245,27 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "calculate\n", - "Partial molar enthalpy of water in the mixture\n", - "Partial molar enthalpy of H2SO4 in the mixture\n", - "'''\n", + " \n", "\n", "import math \n", "\n", + "# Variables\n", "x_sulph = 0.6\n", "x_water = 0.4\n", "Temp = 200. #[F]\n", + "# In the given figure 6.8 in the book, drawing the math.tangent to the 200F curve at 60 wt% H2SO4, we find that it intersects the 0%(pure water) axis at 25 Btu/lbm, and the 100% H2SO4 axis at -100Btu/lbm. i.e.\n", "h_water_per_pound = 25. #[Btu/lbm]\n", "h_sulph_per_pound = -100. #[Btu/lbm]\n", + "# also molecular weight of water and sulphuric acid are\n", "M_water = 18. #[lbm/lbmol]\n", "M_sulph = 98. #[lbm/lbmol]\n", "\n", + "# Calculations\n", + "# Using equation 6.20 given in the book we have\n", "h_water = h_water_per_pound*M_water #[Btu/lbmol]\n", "h_sulph = h_sulph_per_pound*M_sulph #[Btu/lbmol]\n", "\n", + "# Results\n", "print \"Partial molar enthalpy of water in the mixture is %f Btu/lbmol\"%(h_water)\n", "print \" Partial molar enthalpy of H2SO4 in the mixture is %f Btu/lbmol\"%(h_sulph)\n" ], @@ -257,20 +295,30 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "x_sulph = 0.6\n", "x_water = 0.4\n", "M_i = 18. #[lbm/lbmol]\n", "Temp = 200. #[F]\n", + "# From Equation 6.11 as given in the book, we have \n", + "# dQ/dm_in = h_i-h_in\n", + "# where h_i is partial molal enthalpy which is taken from the example 6.7 and h_in is the pure species molar enthalpy which is read from the figure 6.8.\n", + "# So at 200F we have \n", "h_i = 25. #[Btu/lbm]\n", "h_in = 168. #[Btu/lbm]\n", "\n", + "# Calculations\n", + "# hence\n", "dQ_by_dm_in = h_i-h_in #[Btu/lbm]\n", + "# Now \n", "dQ_by_dn_in = M_i*dQ_by_dm_in #[Btu/lbmol]\n", "\n", + "# Results\n", "print \"The amount of heat removed to keep the temperature consmath.tant is %f Btu/lbm of water added\"%(dQ_by_dm_in)\n", + "# The negative sign shows that this mixing is exothermic we must remove 143 Btu/lbm of water added.\n" ], "language": "python", "metadata": {}, @@ -297,19 +345,28 @@ "cell_type": "code", "collapsed": false, "input": [ + " \n", "import math \n", "\n", + "# Variables\n", "m_sulph = 0.4\n", "m_water = 0.6\n", "m = m_sulph+m_water\n", "Temp = 200. #[F]\n", + "# Here at 200F we can read the solution enthalpy h_solution and pure H2SO4 enthalpy h_sulph such that\n", "h_solution = -43. #[Btu/lbm]\n", "h_sulph = 168. #[Btu/lbm]\n", + "# By energy balance, umath.sing h_0_water from example 6.7 in the book i.e.\n", "h_0_water = 53. #[Btu/lbm]\n", "\n", + "# We find \n", + "# Calculations\n", "delta_Q = m*h_solution-(m_sulph*h_sulph+m_water*h_0_water) #[Btu]\n", "\n", + "# Results\n", "print \"The amount of heat added or removed is %f Btu\"%(delta_Q)\n", + "# We must remove the given amount of to hold the temperature consmath.tant.\n", + "# Note However the book has some mistake in calculation and reporting -172 Btu\n" ], "language": "python", "metadata": {}, @@ -336,17 +393,22 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "x_sulph = 0.6\n", "x_water = 0.4\n", "Temp = 200. #[F]\n", + "# At the 200F we have\n", "h_water = 25. #[Btu/lbm]\n", "h_sulph = -100. #[Btu/lbm]\n", "\n", + "# Calculations\n", + "# From equation 6.16 (as reporated in the book), rewritten for masses instead of moles we have \n", "h_solution = h_water*x_water+h_sulph*x_sulph # [Btu/lbm]\n", "\n", + "# Results\n", "print \"Enthalpy of the solution is %f Btu/lbm\"%(h_solution)\n" ], "language": "python", @@ -374,13 +436,22 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "x_b = 0\n", "x_a = 1\n", + "# We have\n", + "#dv_a/dx_a = 3*x_b**(2)+2*x_b\n", + "# We have the equation \n", + "# dv_b/dx_a = -(dv_a/dx_a)/(x_b/x_a)\n", + "# So\n", + "# dv_b/dx_a = -(x_a/x_b)*(3*x_b**(2)+2*x_b) \n", + "# Calculations\n", "dv_b_by_dx_a = x_a*(-3*x_b-2)\n", "\n", + "# Results\n", "print \"Value of the dv_b/dx_a at x_b =0 is %0.0f\"%(dv_b_by_dx_a)\n" ], "language": "python", diff --git a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch9.ipynb b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch9.ipynb index cadd834d..cdb65f60 100644 --- a/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch9.ipynb +++ b/Physical_And_Chemical_Equilibrium_For_Chemical_Engineers/ch9.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:33f89565d585b53e136643fa34ebfb17a9fc9d898698ec35f07daaa5d5768445" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,22 +28,26 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Value of the liquid-phase activity coefficient\n", - "And value of the liquid-phase activity coefficient\n", - "'''\n", + " \n", "\n", "import math \n", "\n", + "# Variables\n", "x_isopropanol = 0.4720\n", "x_water = 0.5280\n", + "# From the table A.7 (page 427) reported in the book the Van Laar coefficients for isopropanol-water system at 1atm are given by\n", "A = 1.0728\n", "B = 0.4750\n", "\n", + "# Calculations\n", + "# Van Laar equations are given \n", + "# math.log10(Y_a) = A*x_b**(2)/(A/B*x_a+x_b)**(2)\n", + "# math.log10(Y_b) = B*x_a**(2)/(B/A*x_b+x_a)**(2)\n", + "# We calculate Y_isopropanol and Y_water as\n", "Y_isopropanol = 10**(A*x_water**(2)/(A/B*x_isopropanol+x_water)**(2))\n", "Y_water = 10**(B*x_isopropanol**(2)/(B/A*x_water+x_isopropanol)**(2))\n", "\n", + "# Results\n", "print \" Value of the liquid-phase activity coefficient for isopropanol is %f\"%(Y_isopropanol)\n", "print \" And value of the liquid-phase activity coefficient for water is %f\"%(Y_water)\n" ], @@ -72,21 +77,26 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "The value of g_E/RT for acetone-water solution \n", - "The value of g_E/RT)/x_a*x_b) for acetone-water\n", - "'''\n", + " \n", "import math \n", "\n", + "# Variables\n", + "# Recieving the VLE data from the example 8.2, we have\n", "x_acetone = 0.05\n", "x_water = 0.95\n", + "# And the activity coefficient is given by\n", "y_acetone = 7.04\n", "y_water = 1.01\n", + "# we hve the relation g_E/RT = summation(x_i*math.log(y_i))\n", + "# let C = g_E/RT , so\n", "\n", + "# Calculations\n", "C = (x_acetone*math.log(y_acetone)+x_water*math.log(y_water))\n", + "# Now let M = (g_E/RT )/(x_acetone*x_water)\n", + "# So\n", "M = C/(x_acetone*x_water)\n", "\n", + "# Results\n", "print \"The value of g_E/RT for acetone-water solution at 1 atm pressure is %f\"%(C)\n", "print \"The value of g_E/RT)/x_a*x_b) for acetone-water solution at 1 atm pressure is %f\"%(M)\n" ], @@ -116,16 +126,21 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "y_acetone_infinity = 10.\n", "y_water_infinty = 5.\n", "Pressure = 1. #[atm]\n", "\n", + "# Calculations\n", + "# From equation 9.L and 9.M (page 224) as reported in the book, we have \n", + "# Constants in morgules equation b and c as\n", "b = math.log(y_acetone_infinity)\n", "c = math.log(y_water_infinty)\n", "\n", + "# Results\n", "print \"Values of the consmath.tants in Morgules equation for acetone-water at 1 atm are b = %f\"%(b)\n", "print \" and c = %f\"%(c)\n" ], @@ -155,30 +170,51 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "P_1 = 10. #[atm]\n", "x_a_1 = 0.1238 # mole fraction of ethanol at 10 atm pressure\n", "Temp = 273.15+85.3 # [K]\n", "R = 0.08206 #[(L*atm)/(mol*K)]\n", "P_0 = 1. #[atm]\n", + "# so\n", "delta_P = (P_1-P_0) #[atm]\n", + "# Molecular weight of ethanol and water are respectively\n", "M_ethanol = 46. #[g/mol]\n", "M_water = 18. #[g/mol]\n", "\n", + "# Calculations\n", + "# Now changing the mol fraction of ethanol in the wt fraction \n", "m_a_1 = x_a_1*M_ethanol/(x_a_1*M_ethanol+(1-x_a_1)*M_water)\n", + "# From example 8.9(page 188) we know that at this T and 1 atm and x_a_0, activity coefficient for ethanol \n", "y_ethanol_0 = 2.9235\n", + "# Now from figure 6.15(page 129), we read that at 20C and m_a_1 mass fraction ethanol ,\n", "v_ethanol_1 = 1.16 #[cm**(3)/g]\n", + "# Similarily for mass fraction corresponding to mole fraction x_a_1 \n", "v_ethanol_0 = 1.27 #[cm**(3)/]\n", + "# Difference of thes etwo values is \n", "v = v_ethanol_1-v_ethanol_0 #[cm**(3)/g]\n", "v = v*46. #[L/g]\n", + "# If we assume that this value is more or less independent of temperature, we can use it as the corresponding value at 85.3C, and compute \n", + "# From equation 7.31(page 225)\n", + "# d(math.log(y_i))/dP = (v_1-v_0)/(R*T) at consmath.tant temperature and mole fraction \n", + "# Let d(math.log(y_i))/dP = C, then\n", "C = (v_ethanol_1-v_ethanol_0)/(R*Temp)\n", "\n", + "# Also we can have \n", + "# delta_math.log(y_i) = (d(math.log(y_i))/dP)*delta_P\n", + "# or \n", + "# delta_math.log(y_i) = C*delta_P\n", + "# and delta_math.log(y_i) = math.log(y_ehmath.tanol_1)-math.log(y_ethanol_0)\n", + "# So\n", "y_ethanol_1 = math.exp(math.log(y_ethanol_0)+C*delta_P)\n", "\n", + "# Results\n", "print \"The activity coefficient of ethanol in the solution at 10 atm pressure is %f\"%(y_ethanol_1)\n", "\n", + "# Note : Answer is different because of rouding error. Please calculate manually.\n" ], "language": "python", "metadata": {}, @@ -205,26 +241,38 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "from scipy.integrate import quad \n", "\n", + "# Variables\n", "x_ethanol = 0.1238\n", "Temp_1 = 273.15+85.3 #[K]\n", "P = 1. #[atm]\n", "Temp_2 = 273.15+70 #[K]\n", "R = 8.314 #[j/(mol*K)]\n", + "# From example 8.9, at temperature 85.3C the activity coefficient is \n", "y_ethanol_1 = 2.9235\n", + "# From figure 9.5[4] (page 227) as reported in the book, we read the value of (h_i_average-h_i_0) at temperatures 90C and 70C for ethanol.\n", + "# which are respectively\n", "delta_h_2 = 0.2 #[kJ/mol]\n", "delta_h_1 = 1.0 #[kJ/mol]\n", "\n", + "# Calculations\n", + "# Taking the average of these two values we have \n", "delta_h_average = (delta_h_1+delta_h_1)/2*1000. #[J/mol]\n", + "# From the equation 7.32 (page 225) reported in the book \n", + "# d(math.log(y_i))/dT = (h_i_average-h_i_0)/(R*T**(2)) at consmath.tant pressure and mole fraction\n", + "# So\n", + "# it can be taken approximately as \n", + "# So\n", "\n", "def f7(T): \n", "\t return (1/T**(2))\n", "\n", "y_ethanol_2 = y_ethanol_1*math.exp((delta_h_average/R)* (quad(f7,Temp_1,Temp_2))[0])\n", "\n", + "# Results\n", "print \"The activity coefficient for ethanol in the solution at 70 deg C and 1 atm is %f\"%(y_ethanol_2)\n", "\n" ], @@ -253,32 +301,53 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", + "# In this solution we will give the identity to the three species as\n", + "# a- Acetone \n", + "# b- Methanol\n", + "# c- Water\n", + "# Given\n", "x_a = 0.1200\n", "x_b = 0.1280\n", "x_c = 0.7520\n", "Temp = 66.70 #[C]\n", "P = 1. #[atm] pressure\n", + "# As reported in the book that from [5] we get the following values \n", + "# acetone-methanol(a-b)\n", "A_ab = 0.2634\n", "A_ba = 0.2798\n", + "# acetone-water(a-c)\n", "A_ac = 0.9709\n", "A_ca = 0.5579\n", + "# methanol-water(b-c)\n", "A_bc = 0.3794\n", "A_cb = 0.2211\n", "\n", + "# Calculations\n", + "# Now consider the equation 9.10 (page 228) \n", + "# The first term on the right of the equation is\n", "T_1 = round(x_b**(2)*(A_ab+2*x_a*(A_ba-A_ab)),5)\n", + "# similarily the second and third terms are given respectively as \n", "T_2 = round(x_c**(2)*(A_ac+2*x_a*(A_ca-A_ac)),3)\n", "T_3 = 0.0550 #x_b*x_c*(0.5*(A_ba+A_ab+A_ac-A_bc-A_cb)+x_a*(A_bc-A_ab+A_ca-A_ac)+(x_b-x_c)*(A_bc-A_cb)-(1-2*x_a)*0.00)\n", + "# thus whole term on the right hand side is\n", "T = T_1+T_2+T_3\n", + "# So \n", "y_a = 10**(T)\n", + "# for this temperature vapour pressure of the acetone is calculated as \n", "p_acetone = 1.417 #[atm]\n", + "# So that we estimate\n", "y_acetone = x_a*y_a*p_acetone\n", "\n", + "# Results\n", "print \" yacetone : %.3f\"%y_acetone\n", "print \"The activity coefficient of acetone in the given mixture is %f\"%(y_a)\n", + "# The experimental value is y_acetone = 0.698\n", "\n", + "# Answer is different because of rounding error." ], "language": "python", "metadata": {}, @@ -309,6 +378,7 @@ "\n", "import math \n", "\n", + "# Variables\n", "T = 85.3+273.15 #[K] Temperature\n", "P = 1. #[atm] Pressure of the mixture\n", "R = 8.314 #[(Pa*m(3)/(K*mol))]\n", @@ -316,74 +386,101 @@ "y_i = 0.1238 # mole fraction of the ethanol in the vapor phase\n", "y_j = (1-y_i) # mole fraction of the water vapor in the vapor phase\n", "\n", + "# From the table A.1( table 417), the properties of water and ethanol are given as \n", + "# Critical temperatures are \n", "T_c_ii = 513.9 #[K] Critical temperature of the ethanol\n", "T_c_jj = 647.1 #[K] Criatical temperature of water\n", "\n", + "# Critical pressure are \n", "P_c_ii = 61.48 #[bar] Critical pressure of ethanol \n", "P_c_jj = 220.55 #[bar] Critical pressure of water\n", "\n", + "# A# Resultsentric factor\n", "w_ii = 0.645 # accentric factor of the ethanol \n", "w_jj = 0.345 # accentric factor of the water\n", "\n", + "# Compressibility factor are\n", "z_c_ii = 0.24 # compressibility factor of ethanol\n", "z_c_jj = 0.229 # compressibility factor of the water\n", "\n", + "# Calculations\n", + "# Critical volume are given by \n", "V_c_ii = z_c_ii*R*T_c_ii/(P_c_ii*100000)*10**(6) # critical volume the ethanol\n", "V_c_jj = z_c_jj*R*T_c_jj/(P_c_jj*100000)*10**(6) # critical volume the ethanol\n", "\n", + "# Now\n", + "# for k_ij = 0.0\n", "T_c_ij_0 = (T_c_ii*T_c_jj)**(1./2) #[K]\n", "w_ij = (w_ii + w_jj)/2.\n", "z_c_ij = (z_c_ii + z_c_jj)/2.\n", "V_c_ij = ( (V_c_ii**(1./3) + V_c_jj**(1./3))/2.)**(3)\n", "P_c_ij_0 = (z_c_ij*R*T_c_ij_0)/(V_c_ij/10.**(6.))/10.**(5) #[bar]\n", "\n", + "# again for k_ij = 0.01\n", "T_c_ij_1 = (T_c_ii*T_c_jj)**(1./2.)*(1-0.01) #[K]\n", "P_c_ij_1 = (z_c_ij*R*T_c_ij_1)/(V_c_ij/10.**(6))/10**(5) #[bar]\n", "\n", + "# Now \n", "T_r_ii = T/T_c_ii\n", "T_r_jj = T/T_c_jj\n", "T_r_ij_0 = T/T_c_ij_0\n", "T_r_ij_1 = T/T_c_ij_1\n", "\n", + "# and\n", "P_r_ii = P/P_c_ii\n", "P_r_jj = P/P_c_jj\n", "P_r_ij_0 = P/P_c_ij_0\n", "P_r_ij_1 = P/P_c_ij_1\n", "\n", + "# Now we will calculate f(T_r) for each component and mixture\n", "f_Tr_ii = ( 0.083 - 0.422/T_r_ii**(1.6) ) + w_ii*( 0.139 - 0.172/T_r_ii**(4.2))\n", "f_Tr_jj = ( 0.083 - 0.422/T_r_jj**(1.6) ) + w_jj*( 0.139 - 0.172/T_r_jj**(4.2))\n", "f_Tr_ij0 = ( 0.083 - 0.422/T_r_ij_0**(1.6) ) + w_ij*( 0.139 - 0.172/T_r_ij_0**(4.2))\n", "f_Tr_ij1 = ( 0.083 - 0.422/T_r_ij_1**(1.6) ) + w_ij*( 0.139 - 0.172/T_r_ij_1**(4.2))\n", "\n", + "# Let us define A = (P_r*f(T_r)/T_r) , so\n", "A_ii = P_r_ii*f_Tr_ii/T_r_ii\n", "A_jj = P_r_jj*f_Tr_jj/T_r_jj\n", "\n", + "# We are given\n", "v_ii = 0.975\n", "v_jj = 0.986\n", "\n", + "# Now,\n", "B_ii = ( f_Tr_ii*R*T_c_ii/P_c_ii)*(10.**(3)/10**(5)) #[L/mol]\n", "B_jj = ( f_Tr_jj*R*T_c_jj/P_c_jj)*(10.**(3)/10**(5)) #[L/mol]\n", "B_ij0 = ( f_Tr_ij0*R*T_c_ij_0/P_c_ij_0)*(10.**(3)/10**(5)) #[L/mol]\n", "B_ij1 = ( f_Tr_ij1*R*T_c_ij_1/P_c_ij_1)*(10.**(3)/10**(5)) #[L/mol]\n", "\n", + "# now we will calculate 'delta'\n", "delta_ij0 = 2*B_ij0 - B_ii - B_jj #[L/mol]\n", "delta_ij1 = 2*B_ij1 - B_ii - B_jj #[L/mol]\n", "\n", + "# We have \n", + "# b_a = B_aa + y_b**(2)*delta and b_b = B_bb + y_a**(2)*delta\n", + "# so,\n", "b_ethanol0 = B_ii + y_j**(2)*delta_ij0 #[L/mol]\n", "b_water0 = B_jj + y_i**(2)*delta_ij0 #[L/mol]\n", "b_ethanol1 = B_ii + y_j**(2)*delta_ij1 #[L/mol]\n", "b_water1 = B_jj + y_i**(2)*delta_ij1 #[L/mol]\n", "\n", + "# Now \n", + "# phi_i = exp(b_i*P/(R*T))\n", + "# So,\n", "phi_ethanol0 = math.exp((b_ethanol0*P)/(R_1*T))\n", "phi_water0 = math.exp((b_water0*P)/(R_1*T))\n", "phi_ethanol1 = math.exp((b_ethanol1*P)/(R_1*T))\n", "phi_water1 = math.exp((b_water1*P)/(R_1*T))\n", "\n", + "# and\n", + "# Y_i = phi_i/v_i\n", + "# So,\n", "Y_ethanol0 = phi_ethanol0/v_ii\n", "Y_water0 = phi_water0/v_jj\n", "Y_ethanol1 = phi_ethanol1/v_ii\n", "Y_water1 = phi_water1/v_jj\n", "\n", + "# Results\n", "print \" The results are summarize in the following table\"\n", "print \" Property \\t\\t\\t Mix ij Assuming k_ij = 0.0 \\t\\t\\t Mix ij Assuming k_ij = 0.01\"\n", "print \" phi_ethanol \\t\\t\\t\\t %f \\t\\t\\t\\t\\t %f \"%(phi_ethanol0,phi_ethanol1)\n", @@ -425,24 +522,29 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "The infinite dilution activity coefficient of n-Hexane\n", - "The infinite dilution activity coefficient of diethlyketone\n", - "'''\n", + " \n", "\n", "import math \n", "\n", + "# Variables\n", "T = 65+273.15 #[K] Temperature\n", "R = 8.314 #[(m**(3)*Pa)/(mol*K)] Universal gas consmath.tant \n", + "# From the table 9.C ( page 239 ) given in the book the molar volumes and solubility of n-hexane and diethylketone at 25 deg C are given as \n", "v_hex = 131.6 #[ml/mol] Molar volume of n-Hexane\n", "v_dketone = 106.4 #[ml/mol] Molar volume of diethylketone\n", "s_hex = 14.9 #[MPa**(0.5)] Solubility of n-Hexane\n", "s_dketone = 18.1 #[MPa**(0.5)] Solubility of diethylketone\n", "\n", + "# Calculations\n", + "# Here we will use these values with the assumption that Y_i,65C = Y_i,25C\n", + "# At infinite dilution, the volume fraction of the other species is 1.00, so, \n", + "# math.logY_a = v_a*phi_b**(2)*(delta_a - delta_b)**(2)/(R*T)\n", + "# so, for n-Hexane\n", "Y_hex = math.exp(v_hex*1**(2)*(s_hex - s_dketone)**(2)/(R*T))\n", + "# And that for diethylketone\n", "Y_dketone = math.exp(v_dketone*1**(2)*( s_dketone - s_hex )**(2)/(R*T))\n", "\n", + "# Results\n", "print \" The infinite dilution activity coefficient of n-Hexane is %f\"%(Y_hex)\n", "print \" The infinite dilution activity coefficient of diethlyketone is %f\"%(Y_dketone)\n" ], @@ -472,25 +574,29 @@ "cell_type": "code", "collapsed": false, "input": [ - "'''\n", - "find\n", - "Henry's law constant for O2\n", - "solubility of O2 \n", - "'''\n", + " \n", "import math \n", "\n", + "# Variables\n", "P = 1. #[atm]\n", "T = 25. #[C]\n", "y_i = 1.00 # amount of the oxygen in the vapour \n", + "# Umath.sing the consmath.tants for O2 in table A.2 \n", "A = 6.69147\n", "B = 319.0117\n", "C = 266.7\n", "\n", + "# Calculations\n", + "# By Antoine equation \n", + "# log10(P_i) = A-B/(T+C)\n", "P_i = 10**(A-B/(T+C)) #[mmHg]\n", "P_i = P_i/760. #[atm]\n", + "# This is extrapolated vapour pressure of O2 at 25C\n", + "# We will take this value as equal to the Henry's law consmath.tant\n", "H_i = P_i\n", "x_i = y_i*P/H_i\n", "\n", + "# Results\n", "print \" Henry's law constant for O2 is %f atm\"%(P_i)\n", "print \" solubility of O2 is %e\"%(x_i)\n" ], @@ -520,16 +626,21 @@ "cell_type": "code", "collapsed": false, "input": [ - "\n", + " \n", "import math \n", "\n", + "# Variables\n", "y_a = 1.00\n", "P = 1.00 #[atm]\n", "x_a = 0.231*10**(-4)\n", + "# Using the constants for O2 in table A.2 in the Antoine equation , we find the vapour pressure of the oxygen at 25C viz.\n", "p_a = 521.15 #[atm]\n", + "# Thus activity coefficient is calculated by rewriting the equation 8.6 and umath.sing the above values \n", "\n", + "# Calculations\n", "Y_O2 = (y_a*P)/(x_a*p_a)\n", "\n", + "# Results\n", "print \"The activity coefficient of the oxygen in the water is %f\"%(Y_O2)\n" ], "language": "python", diff --git a/Practical_C_Programming/Chapter_10_1.ipynb b/Practical_C_Programming/Chapter_10_1.ipynb index 56e12012..616dbfad 100644 --- a/Practical_C_Programming/Chapter_10_1.ipynb +++ b/Practical_C_Programming/Chapter_10_1.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:55a41a15f53fea81d9fb349d875475d12f3934656e4b83a8ff10ced1f1672515" + "signature": "sha256:e0192e34ad6ee5352df14e6445eee01302e3e7af1b8414d8a9190c3936e04b7a" }, "nbformat": 3, "nbformat_minor": 0, @@ -29,7 +29,6 @@ "collapsed": false, "input": [ "\n", - "# Variable declaration\n", "data = []\n", "twice = []\n", "\n", @@ -69,7 +68,6 @@ "input": [ "\n", "\n", - "# Variable declaration\n", "data = []\n", "twice = []\n", "\n", @@ -108,8 +106,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# Variable declaration\n", "BIG_NUMBER = 10 * 10\n", "index = 1\n", "\n", @@ -147,7 +143,6 @@ "input": [ "\n", "\n", - "# Variable declaration\n", "FIRST_PART = 7\n", "LAST_PART = 5\n", "ALL_PARTS = FIRST_PART + LAST_PART\n", @@ -182,7 +177,6 @@ "input": [ "\n", "\n", - "# Calculation and result\n", "for i in reversed (range(10)) :\n", " print ('Hi there')" ], @@ -221,7 +215,7 @@ "collapsed": false, "input": [ "\n", - "# Variable declaration\n", + "\n", "size = 10\n", "fudge = size - 2\n", "\n", @@ -255,7 +249,6 @@ "collapsed": false, "input": [ "\n", - "# Variable declaration\n", "import sys\n", "value = 1\n", "\n", @@ -291,8 +284,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# Function declaration, calculation and result\n", "def SQR (x) :\n", " return x * x\n", " \n", @@ -335,7 +326,6 @@ "input": [ "\n", "\n", - "# Variable declaration\n", "counter = 0\n", "\n", "# Function declaration, calculation and result\n", @@ -381,7 +371,6 @@ "collapsed": false, "input": [ "\n", - "# Function declaration, calculation and result\n", "def reciprocal (number) :\n", " return 1 / number\n", " \n", diff --git a/Practical_C_Programming/Chapter_11_1.ipynb b/Practical_C_Programming/Chapter_11_1.ipynb index 1dc24c59..348ea0f2 100644 --- a/Practical_C_Programming/Chapter_11_1.ipynb +++ b/Practical_C_Programming/Chapter_11_1.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:e68b678f99332c0d6ad607ce4c8f99007b9b612142be0ab04cb6c8b4b0cb5969" + "signature": "sha256:189fb021544012d2bd6866a28aeac9bea1998c8f59c87bf7f6fbc3d56515bb70" }, "nbformat": 3, "nbformat_minor": 0, @@ -29,7 +29,6 @@ "collapsed": false, "input": [ "\n", - "# Variable declaration\n", "i1 = 4\n", "i2 = 2\n", "\n", @@ -64,7 +63,6 @@ "collapsed": false, "input": [ "\n", - "# Variable declaration\n", "HIGH_SPEED = 1 << 7\n", "DIRECT_CONNECT = 1 << 8\n", "\n", @@ -108,8 +106,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# Variable declaration\n", "i = 0x80\n", "\n", "# Calculation and result\n", diff --git a/Practical_C_Programming/Chapter_2_3.ipynb b/Practical_C_Programming/Chapter_2_3.ipynb index 36e059c9..d166fe06 100644 --- a/Practical_C_Programming/Chapter_2_3.ipynb +++ b/Practical_C_Programming/Chapter_2_3.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:1bdbe534af4c41744d0b20620d61031047f924bf7d6e0c91a540c9ad26997cbe" + "signature": "sha256:69b330a048da570dabedd3e4e55c16ec334a711968bec2056bd27ef834d8f06e" }, "nbformat": 3, "nbformat_minor": 0, @@ -30,7 +30,7 @@ "input": [ "\n", "\n", - "\t# a-oxygen b-stagnant water\n", + "\n", "T = 310 \t\t\t\t\t# [K]\n", "\t# Since the solubility of oxygen in water at 310 K is extremely low, we are dealing with \tdilute solutions\n", "k_L = 3.3*10**-5 \t\t\t\t# [coefficient based on the oxygen concentration \t\t\t\t\t\tdifference in the water, m/s]\n", @@ -254,8 +254,6 @@ "input": [ "\n", "\n", - "#Variable declaration\n", - "\t# a-UF6 b-air\n", "M_a = 352 \t\t\t\t\t# [molecular weight of UF6, gram/mole]\n", "M_b = 29 \t\t\t\t\t# [gram/mole]\n", "d = 0.01 \t\t\t\t\t# [diameter, m]\n", @@ -485,8 +483,7 @@ "\n", "\n", "import math\n", - "#Variable declaration\n", - "\t# a-liquid benzene b-nitrogen\n", + "\n", "T = 300 \t\t\t\t\t\t# [K]\n", "l = 3 \t\t\t\t\t\t\t# [length of vertical plate, m]\n", "b = 1.5 \t\t\t\t\t\t# [width of vertical plate, m]\n", @@ -556,9 +553,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Variable declaration\n", - "\t# a-water b-air\n", "dp1 = 10**-3 \t\t\t\t\t# [diameter of spherical drop of water, m]\n", "Tair = 323 \t\t\t\t\t# [K]\n", "P = 101.3 \t\t\t\t\t# [kPa]\n", @@ -672,11 +666,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Variable declaratiopn\n", - "\n", - "\t# Example 2.6 using equation 2.73\n", - "\t# Values of the dimensionless parameters calculated in Example 2.6\n", "Re = 1223 \t\t\t\t# [Renoylds Number]\n", "Sc = 0.905 \t\t\t\t# [Schmidt Number]\n", "c = 0.039 \t\t\t\t# [molar density, kg/cubic m]\n", @@ -725,10 +714,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Variable declaration\n", - "\n", - "# a-water b-air\n", "D = 25.4*10**-3 \t\t\t\t# [diameter of wetted wall tower, m]\n", "Gy = 10 \t\t\t\t\t# [mass velocity, kg/square m.s]\n", "T1 = 308 \t\t\t\t\t# [K]\n", @@ -811,10 +796,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "\n", - "#Variable declaration\n", - "\t# a-water b-dry air\n", "D = 25.4*10**-3 \t\t\t# [Internal diameter of tower, m]\n", "Z = 1.5 \t\t\t\t# [length of the wetted section, m]\n", "Gy = 10 \t\t\t\t# [mass velocity of air, kg/square m.s]\n", @@ -880,8 +861,6 @@ "collapsed": false, "input": [ "\n", - "#Variable declaration\n", - "\t# a-water b-dry air\n", "Gy = 10.0 \t\t\t\t# [kg/square m.s]\n", "dp = 3.5*10**-3 \t\t\t# [diameter of spherical glass beads, m]\n", "D = 25.4*10**-3 \t\t\t# [Internal diameter of tower, m]\n", @@ -967,11 +946,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Variable declaration\n", - "\t# a-oxygen b-water\n", - "\t# To design the deaerator, We will use commercially available microporous polypropylene \thollow fibers in a module\n", - "\n", "m = 40000.0 \t\t\t\t\t# [kg/hr]\n", "Twater = 298 \t\t\t\t\t# [K]\n", "v = 0.1 \t\t\t\t\t# [superficial velocity, m/s]\n", diff --git a/Practical_C_Programming/Chapter_3_4.ipynb b/Practical_C_Programming/Chapter_3_4.ipynb index 1a74741f..a8e0779c 100644 --- a/Practical_C_Programming/Chapter_3_4.ipynb +++ b/Practical_C_Programming/Chapter_3_4.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:0893bf0eb544a1587dd8191af7502dfb1634a7c77a30f208ad67851517e5431c" + "signature": "sha256:ebedd6f3bf7c0762de88b2ec9ed84eecba39a72a5c5924ff89534f9517007ca4" }, "nbformat": 3, "nbformat_minor": 0, @@ -30,7 +30,7 @@ "input": [ "\n", "\n", - "# Result\n", + "\n", "print ('Hello World')" ], "language": "python", diff --git a/Practical_C_Programming/Chapter_7_4.ipynb b/Practical_C_Programming/Chapter_7_4.ipynb index ad153ba6..620d440f 100644 --- a/Practical_C_Programming/Chapter_7_4.ipynb +++ b/Practical_C_Programming/Chapter_7_4.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:05d2b6828dd178069989841e00a87dd5090f48e199f3c803503e5017b744fb21" + "signature": "sha256:2555ca3a1b68efa7cc762303e679c4f4dbb6d27bc5633d2ac8b64fe540cb2399" }, "nbformat": 3, "nbformat_minor": 0, @@ -133,7 +133,6 @@ "collapsed": false, "input": [ "\n", - "# Variable declaration, calculation and result\n", "import sys\n", "import random\n", "while (1) :\n", diff --git a/Practical_C_Programming/Chapter_9_4.ipynb b/Practical_C_Programming/Chapter_9_4.ipynb index 8d18a77b..39cb7cdd 100644 --- a/Practical_C_Programming/Chapter_9_4.ipynb +++ b/Practical_C_Programming/Chapter_9_4.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:312f9e5b3211fd50ff3dd7c27b81824ed2a8d6172aff8fb27752ffb6ee205caa" + "signature": "sha256:9022b72f2fc24432e92fa44cdfeb3da1fa5525a0485bb76b898e97e55f78a4d8" }, "nbformat": 3, "nbformat_minor": 0, @@ -29,7 +29,6 @@ "collapsed": false, "input": [ "\n", - "# Function declaration, calculation and result\n", "def func() :\n", " if not hasattr(func, \"permanent\") :\n", " func.permanent = 1\n", @@ -70,8 +69,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# Function declaration, calculation and result\n", "def triangle (width, height) :\n", " area = width * height / 2.0\n", " return area\n", @@ -108,7 +105,6 @@ "collapsed": false, "input": [ "\n", - "# Function declaration, calculation and result\n", "def length (string) :\n", " return len(string)\n", "\n", @@ -143,7 +139,6 @@ "input": [ "\n", "\n", - "# Function declaration, calculation and result\n", "def length (string) :\n", " return len(string)\n", "\n", diff --git a/Principles_And_Modern_Applications_Of_Mass_Transfer_Operations/Chapter8.ipynb b/Principles_And_Modern_Applications_Of_Mass_Transfer_Operations/Chapter8.ipynb index 88fe84eb..3323ea05 100644 --- a/Principles_And_Modern_Applications_Of_Mass_Transfer_Operations/Chapter8.ipynb +++ b/Principles_And_Modern_Applications_Of_Mass_Transfer_Operations/Chapter8.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:1b9281c55596391056ad444a3bcc77ac238e8c52d286c4b6044d31a9fb1335cb" + "signature": "sha256:bace9e702292e3d3629b1af1b04f785ea7b14f0684491da077287b62be815475" }, "nbformat": 3, "nbformat_minor": 0, @@ -303,8 +303,6 @@ "input": [ "\n", "\n", - "# Theoretical example\n", - "# result\n", "\n", "print \"Part A:\\nQ point: V_GS=-2V I_D=2.5mA. At V_GS=-1V, I_D=3.4mA,\"\n", "print \"At V_GS=-3V, I_D=1.8mA. So peak to peak drain current is\" \n", diff --git a/Programming_in_C/Chapter_03.ipynb b/Programming_in_C/Chapter_03.ipynb index bbc7d9cf..30f0abae 100644 --- a/Programming_in_C/Chapter_03.ipynb +++ b/Programming_in_C/Chapter_03.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:57f27b589000036417c51c927626e752909312f11d9fc5346eab037945b09afc" + "signature": "sha256:d8c363a7618c01354c29de02098f7db723d0768b8769439b908ad7302fccbc99" }, "nbformat": 3, "nbformat_minor": 0, @@ -29,7 +29,7 @@ "collapsed": false, "input": [ "\n", - "#Print Statement\n", + "\n", "print(\"Programming is Fun.\")" ], "language": "python", @@ -58,8 +58,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "#Print statement\n", "print(\"Programming is Fun.\")\n", "print(\"And Programming in Python is even more fun\")" ], @@ -89,10 +87,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "#3.3.py\n", - "#Displaying multiple Lines of output\n", "\n", - "#Print statements using escape sequence\n", "print(\"Testing...\\n..1\\n...2\\n....3\\n\")" ], "language": "python", @@ -155,7 +150,6 @@ "input": [ "\n", "\n", - "#Variable declaration\n", "value1=50\n", "value2=25\n", "\n", @@ -192,7 +186,7 @@ "input": [ "\n", "\n", - "#Variable declarations\n", + "\n", "value1=50\n", "value2=25\n", "\n", diff --git a/Satellite_Communication/chapter_3.ipynb b/Satellite_Communication/chapter_3.ipynb index e87eed02..b87a50b4 100644 --- a/Satellite_Communication/chapter_3.ipynb +++ b/Satellite_Communication/chapter_3.ipynb @@ -1,746 +1,745 @@ -{
- "metadata": {
- "name": ""
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 3: Satellite Launch and In-Orbit Operations"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.1, page no-72"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "Az=85 # Azimuth angle of injection point\n",
- "l=5.2 # latitude of launch site\n",
- "\n",
- "\n",
- "#Calculation\n",
- "cosi=math.sin(Az*math.pi/180)*math.cos(l*math.pi/180)\n",
- "i=math.acos(cosi)\n",
- "i=i*180.0/math.pi\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Inclination angle attained, i=%.1f\u00b0\"%i)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Inclination angle attained, i=7.2\u00b0\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.2, page no-73"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "delta_i=7 #orbital plane inclination\n",
- "V=3000 #velocity of satellite in circularized orbit\n",
- "\n",
- "\n",
- "#Calculation\n",
- "vp=2*V*math.sin(delta_i*math.pi/(2*180))\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Velocity thrust to make the inclination 0\u00b0 = %.0f m/s\"%vp)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Velocity thrust to make the inclination 0\u00b0 = 366 m/s\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.3, page no-73"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "#Variable Declaration\n",
- "mu=39.8*10**13 # Nm^2/kg\n",
- "P=7000.0*10**3 # Perigee distance in m\n",
- "e=0.69 # eccentricity of eliptical orbit\n",
- "w=60.0/2 # angle made by line joing centre of earth and perigee with the line of nodes\n",
- "\n",
- "\n",
- "#Calculation\n",
- "k=(e/math.sqrt(1+e))\n",
- "k=math.floor(k*100)/100\n",
- "v=2*(math.sqrt(mu/P))*k*math.sin(w*math.pi/180.0)\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"The velocity thrust required to rotate the perigee point\\n by desired amount is given by, v=%.1f m/s = %.3fkm/s\"%(v,v/1000.0))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The velocity thrust required to rotate the perigee point\n",
- " by desired amount is given by, v=3996.4 m/s = 3.996km/s\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.4, page no-74"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "A=15000*10**3 #Original apogee distance\n",
- "A1=25000*10**3 # Raised opogee distance\n",
- "P=7000*10**3 # Perigee Distance\n",
- "mu=39.8*10**13 #Nm**2/kg\n",
- "\n",
- "\n",
- "#Calculation\n",
- "A_d=A1-A\n",
- "v=math.sqrt((2*mu/P)-(2*mu/(A+P)))\n",
- "del_v=A_d*mu/(v*(A+P)**2)\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"required Thrust velocity Delta_v = %.1f m/s\"%del_v)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "required Thrust velocity Delta_v = 933.9 m/s\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.5, page no-75"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "A=15000.0*10**3 # Original apogee distance\n",
- "A1=7000.0*10**3 # Raised opogee distance\n",
- "P=7000.0*10**3 # Perigee Distance\n",
- "mu=39.8*10**13 # Nm^2/kg\n",
- "\n",
- "\n",
- "#Calculation\n",
- "A_d=A-A1\n",
- "v=math.sqrt((2*mu/P)-(2*mu/(A+P)))\n",
- "del_v=A_d*mu/(v*(A+P)**2)\n",
- "\n",
- "#Result\n",
- "print(\"required Thrust velocity Delta_v = %.1f m/s\"%del_v)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "required Thrust velocity Delta_v = 747.1 m/s\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.6, page no-76"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Variable Declaration\n",
- "A=15000.0*10**3 # Original apogee distance\n",
- "A1=16000.0*10**3 # Raised opogee distance\n",
- "P=7000.0*10**3 # Perigee Distance\n",
- "mu=39.8*10**13 # Nm**2/kg\n",
- "\n",
- "\n",
- "#Calculation\n",
- "A_d=A1-A\n",
- "v=math.sqrt((2*mu/P)-(2*mu/(A+P)))\n",
- "v=v*P/A\n",
- "del_v=A_d*mu/(v*(A+P)**2)\n",
- "\n",
- "#Result\n",
- "print(\"required Thrust velocity Delta_v = %.1f m/s\"%del_v)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "required Thrust velocity Delta_v = 200.1 m/s\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.7, page no-77"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "R=6378.0*10**3 # Radius of earth\n",
- "mu=39.8*10**13 # Nm**2/kg\n",
- "r1=500.0*10**3 # original orbit from earths surface\n",
- "r2=800.0*10**3 # orbit to be raised to thisdistance\n",
- "\n",
- "\n",
- "#Calculation\n",
- "R1=R+r1\n",
- "R2=R+r2\n",
- "delta_v=math.sqrt(2*mu*R2/(R1*(R1+R2)))-math.sqrt(mu/R1)\n",
- "delta_v_dash=math.sqrt(mu/R2)-math.sqrt(2*mu*R1/(R2*(R1+R2)))\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Two thrusts to be applied are,\\n Delta_v = %.2f m/s \\n Delta_v_dash = %.2f m/s\"%(delta_v,delta_v_dash))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Two thrusts to be applied are,\n",
- " Delta_v = 80.75 m/s \n",
- " Delta_v_dash = 79.89 m/s\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.8, page no-97"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "H=36000.0 # Height of geostationary satellite from the surface of earth\n",
- "R=6370.0 # Radius of earth in km\n",
- "\n",
- "\n",
- "#Calculation\n",
- "k=math.acos(R/(R+H))\n",
- "#k=k*180/%pi\n",
- "k=math.sin(k)\n",
- "k=math.ceil(k*1000)/1000\n",
- "d=2*(H+R)*k\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Maximum line-of-sight distance is %.2f km\"%d)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Maximum line-of-sight distance is 83807.86 km\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.9, page no-98"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "H=36000.0 # Height of geostationary satellite from the surface of earth\n",
- "R=6370.0 # Radius of earth in km\n",
- "theta=20.0 # angular separation between two satellites\n",
- "\n",
- "\n",
- "#Calculation\n",
- "D=(H+R)\n",
- "k=math.ceil(math.cos(theta*math.pi/180.0)*100)/100\n",
- "d=math.sqrt(2*D**2*(1-k))\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"The line-of-sight distance is %.4f km\"%d)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The line-of-sight distance is 14677.3985 km\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.10, page no-98"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "#Variable Declaration\n",
- "\n",
- "#IntelSat-VI location= 37 W\n",
- "# IntelSat-VII location=74 E\n",
- "theta=37+74 # angular separation between two satellites\n",
- "D=42164.0 # circular equilateral geostationary orbit in km\n",
- "\n",
- "\n",
- "#Calculation\n",
- "k=math.cos(math.pi*theta/180.0)\n",
- "#printf(\"%f\\n\",k)\n",
- "k=-0.357952\n",
- "d=math.sqrt(2*D**2*(1-k))\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Inter-satellite distance is %.2f km\"%d)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Inter-satellite distance is 69486.27 km\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.11, page no-99"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "theta_l=30.0 # earth station's location 30\u00b0W longitude\n",
- "theta_s=50.0 # satellite's location 50\u00b0W longitude\n",
- "theta_L=60.0 # earth station's location 60\u00b0N latitude\n",
- "r=42164.0 # orbital radius of the satellite in km\n",
- "R=6378.0 # Earth's radius in km\n",
- "\n",
- "A_dash=math.atan((math.tan(math.pi*(theta_s-theta_l)/180.0))/math.sin(math.pi*60/180.0))\n",
- "A_dash=A_dash*180/math.pi\n",
- "A=180+A_dash #Azimuth angle\n",
- "\n",
- "x=(180/math.pi)*math.acos(math.cos(math.pi*(theta_s-theta_l)/180.0)*math.cos(math.pi*theta_L/180))\n",
- "y=r-math.ceil(R*(math.cos(math.pi*(theta_s-theta_l)/180.0)*math.cos(math.pi*theta_L/180)))\n",
- "z=R*math.sin(math.pi*x/180)\n",
- "E=(math.atan(y/z)*180/math.pi)-x\n",
- "print(\"Azimuth angle =%.1f\u00b0\\n Elevation angle =%.1f\u00b0\"%(A,E))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Azimuth angle =202.8\u00b0\n",
- " Elevation angle =19.8\u00b0\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.12, page no-100"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "theta_l=60.0 #earth station's location 60\u00b0W longitude\n",
- "theta_s=105.0 #satellite's location 105\u00b0W longitude\n",
- "theta_L=30.0 #earth station's location 30\u00b0N latitude\n",
- "\n",
- "theta_l1=90.0 #earth station's location 90\u00b0W longitude\n",
- "theta_s1=105.0 #satellite's location 105\u00b0W longitude\n",
- "theta_L1=45.0 #earth station's location 45\u00b0N latitude\n",
- "\n",
- "c=3*10**8 # speed of light\n",
- "r=42164.0 # orbital radius of the satellite in km\n",
- "R=6378.0 # Earth's radius in km\n",
- "\n",
- "\n",
- "#Calculation\n",
- "\n",
- "x=(180/math.pi)*math.acos(math.cos(math.pi*(theta_s-theta_l)/180)*math.cos(math.pi*theta_L/180))\n",
- "y=r-math.ceil(R*(math.cos(math.pi*(theta_s-theta_l)/180)*math.cos(math.pi*theta_L/180)))\n",
- "z=R*math.sin(math.pi*x/180)\n",
- "E=(math.atan(y/z)*180/math.pi)-x\n",
- "\n",
- "x1=(180/math.pi)*math.acos(math.cos(math.pi*(theta_s1-theta_l1)/180)*math.cos(math.pi*theta_L1/180))\n",
- "y1=r-math.ceil(R*(math.cos(math.pi*(theta_s1-theta_l1)/180)*math.cos(math.pi*theta_L1/180)))\n",
- "z1=R*math.sin(math.pi*x1/180)\n",
- "E1=(math.atan(y1/z1)*180/math.pi)-x1\n",
- "E1=math.floor(E1)\n",
- "\n",
- "#calculation of slant range dx\n",
- "k=(R/r)*math.cos(math.pi*E/180)\n",
- "k=(180/math.pi)*math.asin(k)\n",
- "k=k+E\n",
- "k=math.sin(math.pi*k/180)\n",
- "k=math.ceil(k*1000)/1000\n",
- "#k=k+E\n",
- "#k=sin(k)\n",
- "dx=(R)**2+(r)**2-(2*r*R*k)\n",
- "dx=math.sqrt(dx)\n",
- "\n",
- "\n",
- "#calculation of slant range dy\n",
- "k1=(R/r)*math.cos(math.pi*E1/180)\n",
- "k1=(180/math.pi)*math.asin(k1)\n",
- "k1=k1+E1\n",
- "k1=math.floor(k1)\n",
- "k1=math.sin(math.pi*k1/180)\n",
- "k1=math.ceil(k1*1000)/1000\n",
- "dy=(R)**2+(r)**2-(2*r*R*k1)\n",
- "dy=math.sqrt(dy)\n",
- "\n",
- "tr=dy+dx\n",
- "delay=tr*10**6/c\n",
- "x=50\n",
- "td=delay+x\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Elevation angle, Ex =%.1f\u00b0\"%E)\n",
- "print(\"\\n Elevation angle, Ey =%.1f\u00b0\"%math.floor(E1))\n",
- "print(\"\\n Slant range dx of the earth station X is dx=%.2fkm\"%dx)\n",
- "print(\"\\n Slant range dy of the earth station Y is dy=%.1fkm\"%dy)\n",
- "print(\"\\n Therefore, total range to be covered is %.2fkm\"%tr)\n",
- "print(\"\\n propagation delay=%.2fms\"%delay)\n",
- "print(\"\\n\\n Time required too transmit 500 kbs of information at \\n a transmisssion speed of 10Mbps is given by 500000/10^7=%.0fms\"%(500000000.0/10**7))\n",
- "print(\"\\n\\n Total Delay= %.2fms\"%td)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Elevation angle, Ex =30.3\u00b0\n",
- "\n",
- " Elevation angle, Ey =36.0\u00b0\n",
- "\n",
- " Slant range dx of the earth station X is dx=38584.76km\n",
- "\n",
- " Slant range dy of the earth station Y is dy=38100.8km\n",
- "\n",
- " Therefore, total range to be covered is 76685.57km\n",
- "\n",
- " propagation delay=255.62ms\n",
- "\n",
- "\n",
- " Time required too transmit 500 kbs of information at \n",
- " a transmisssion speed of 10Mbps is given by 500000/10^7=50ms\n",
- "\n",
- "\n",
- " Total Delay= 305.62ms\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.13, page no-102"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "da=38000.0 # slant range of satellite A\n",
- "db=36000.0 # slant range of satellite B\n",
- "beeta=60.0 # difference between longitudes of two satellites\n",
- "R=42164.0 # radius of the orbit of satellites\n",
- "\n",
- "\n",
- "#Calculation\n",
- "theta=(da**2+db**2-2*(R**2)*(1-math.cos(math.pi*beeta/180)))/(2*da*db)\n",
- "theta=(180/math.pi)*math.acos(theta)\n",
- "d=math.sqrt(2*(R**2)*(1-math.cos(math.pi*beeta/180)))\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Angular spacing between two satellites viewed by earth station is,\\n theta= %.1f\u00b0\"%theta)\n",
- "print(\"\\nInter-satellite distance , d=%.0fkm\"%d)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Angular spacing between two satellites viewed by earth station is,\n",
- " theta= 69.4\u00b0\n",
- "\n",
- "Inter-satellite distance , d=42164km\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.14, page no-107"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "r=42164.0 # orbital radius of the satellite in km\n",
- "R=6378.0 # Earth's radius in km\n",
- "\n",
- "#refer to Figure 3.53\n",
- "\n",
- "#Calculation\n",
- "\n",
- "#for E=0\u00b0\n",
- "alfa=math.asin(R/r)*(180/math.pi)\n",
- "alfa=math.floor(alfa*10)/10\n",
- "theta=90-alfa\n",
- "#in the right angle triangle OAC,\n",
- "k=math.sin(math.pi*alfa/180)\n",
- "k=math.floor(k*1000)/1000\n",
- "oc=R*k\n",
- "oc=math.ceil(oc*10)/10\n",
- "A=2*math.pi*R*(R-oc)\n",
- "\n",
- "\n",
- "#for E=10\u00b0\n",
- "E=10\n",
- "alfa1=math.asin((R/r)*math.cos(math.pi*E/180))*(180/math.pi)\n",
- "#alfa1=ceil(alfa1*100)/100\n",
- "theta1=90-alfa1-E\n",
- "#in the right angle triangle OAC,\n",
- "k1=math.sin(math.pi*(alfa1+E)/180)\n",
- "k1=math.floor(k1*1000)/1000\n",
- "oc1=R*k1\n",
- "oc1=math.floor(oc1*10)/10\n",
- "A1=2*math.pi*R*(R-oc1)\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"for E=0\u00b0,\\n covered surface area is %.1f km^2\"%A)\n",
- "print(\"\\n\\n for E=10\u00b0,\\n covered surface area is %.1f km^2\"%A1)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "for E=0\u00b0,\n",
- " covered surface area is 216997546.7 km^2\n",
- "\n",
- "\n",
- " for E=10\u00b0,\n",
- " covered surface area is 174314563.3 km^2\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 3.15, page no-108"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#variable declaration\n",
- "theta=30 #satellite inclination to the equitorial plan\n",
- "#the extreme latitudes covered in northern and southern hemisphere are the same as orbit inclination\n",
- "\n",
- "print(\"Extreme Northern latitude covered = %.0f\u00b0 N\"%theta)\n",
- "print(\"\\n Extreme Southern latitude covered = %.0f\u00b0 S\"%theta)\n",
- "print(\"\\n\\n In fact, the ground track would sweep\\n all latitudes between %d\u00b0N and %d\u00b0S\"%(theta,theta))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Extreme Northern latitude covered = 30\u00b0 N\n",
- "\n",
- " Extreme Southern latitude covered = 30\u00b0 S\n",
- "\n",
- "\n",
- " In fact, the ground track would sweep\n",
- " all latitudes between 30\u00b0N and 30\u00b0S\n"
- ]
- }
- ],
- "prompt_number": 16
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:eb32c126a333b2cfa51753626f865ad3fb2b120400bc606b82fb97538f18ae74" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 3: Satellite Launch and In-Orbit Operations" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.1, page no-72" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "Az=85 # Azimuth angle of injection point\n", + "l=5.2 # latitude of launch site\n", + "\n", + "\n", + "#Calculation\n", + "cosi=math.sin(Az*math.pi/180)*math.cos(l*math.pi/180)\n", + "i=math.acos(cosi)\n", + "i=i*180.0/math.pi\n", + "\n", + "\n", + "#Result\n", + "print(\"Inclination angle attained, i=%.1f\u00b0\"%i)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Inclination angle attained, i=7.2\u00b0\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.2, page no-73" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "delta_i=7 #orbital plane inclination\n", + "V=3000 #velocity of satellite in circularized orbit\n", + "\n", + "\n", + "#Calculation\n", + "vp=2*V*math.sin(delta_i*math.pi/(2*180))\n", + "\n", + "\n", + "#Result\n", + "print(\"Velocity thrust to make the inclination 0\u00b0 = %.0f m/s\"%vp)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Velocity thrust to make the inclination 0\u00b0 = 366 m/s\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.3, page no-73" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "mu=39.8*10**13 # Nm^2/kg\n", + "P=7000.0*10**3 # Perigee distance in m\n", + "e=0.69 # eccentricity of eliptical orbit\n", + "w=60.0/2 # angle made by line joing centre of earth and perigee with the line of nodes\n", + "\n", + "\n", + "#Calculation\n", + "k=(e/math.sqrt(1+e))\n", + "k=math.floor(k*100)/100\n", + "v=2*(math.sqrt(mu/P))*k*math.sin(w*math.pi/180.0)\n", + "\n", + "\n", + "#Result\n", + "print(\"The velocity thrust required to rotate the perigee point\\n by desired amount is given by, v=%.1f m/s = %.3fkm/s\"%(v,v/1000.0))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The velocity thrust required to rotate the perigee point\n", + " by desired amount is given by, v=3996.4 m/s = 3.996km/s\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.4, page no-74" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "A=15000*10**3 #Original apogee distance\n", + "A1=25000*10**3 # Raised opogee distance\n", + "P=7000*10**3 # Perigee Distance\n", + "mu=39.8*10**13 #Nm**2/kg\n", + "\n", + "\n", + "#Calculation\n", + "A_d=A1-A\n", + "v=math.sqrt((2*mu/P)-(2*mu/(A+P)))\n", + "del_v=A_d*mu/(v*(A+P)**2)\n", + "\n", + "\n", + "#Result\n", + "print(\"required Thrust velocity Delta_v = %.1f m/s\"%del_v)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "required Thrust velocity Delta_v = 933.9 m/s\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.5, page no-75" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "A=15000.0*10**3 # Original apogee distance\n", + "A1=7000.0*10**3 # Raised opogee distance\n", + "P=7000.0*10**3 # Perigee Distance\n", + "mu=39.8*10**13 # Nm^2/kg\n", + "\n", + "\n", + "#Calculation\n", + "A_d=A-A1\n", + "v=math.sqrt((2*mu/P)-(2*mu/(A+P)))\n", + "del_v=A_d*mu/(v*(A+P)**2)\n", + "\n", + "#Result\n", + "print(\"required Thrust velocity Delta_v = %.1f m/s\"%del_v)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "required Thrust velocity Delta_v = 747.1 m/s\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.6, page no-76" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable Declaration\n", + "A=15000.0*10**3 # Original apogee distance\n", + "A1=16000.0*10**3 # Raised opogee distance\n", + "P=7000.0*10**3 # Perigee Distance\n", + "mu=39.8*10**13 # Nm**2/kg\n", + "\n", + "\n", + "#Calculation\n", + "A_d=A1-A\n", + "v=math.sqrt((2*mu/P)-(2*mu/(A+P)))\n", + "v=v*P/A\n", + "del_v=A_d*mu/(v*(A+P)**2)\n", + "\n", + "#Result\n", + "print(\"required Thrust velocity Delta_v = %.1f m/s\"%del_v)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "required Thrust velocity Delta_v = 200.1 m/s\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.7, page no-77" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "R=6378.0*10**3 # Radius of earth\n", + "mu=39.8*10**13 # Nm**2/kg\n", + "r1=500.0*10**3 # original orbit from earths surface\n", + "r2=800.0*10**3 # orbit to be raised to thisdistance\n", + "\n", + "\n", + "#Calculation\n", + "R1=R+r1\n", + "R2=R+r2\n", + "delta_v=math.sqrt(2*mu*R2/(R1*(R1+R2)))-math.sqrt(mu/R1)\n", + "delta_v_dash=math.sqrt(mu/R2)-math.sqrt(2*mu*R1/(R2*(R1+R2)))\n", + "\n", + "\n", + "#Result\n", + "print(\"Two thrusts to be applied are,\\n Delta_v = %.2f m/s \\n Delta_v_dash = %.2f m/s\"%(delta_v,delta_v_dash))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Two thrusts to be applied are,\n", + " Delta_v = 80.75 m/s \n", + " Delta_v_dash = 79.89 m/s\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.8, page no-97" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "H=36000.0 # Height of geostationary satellite from the surface of earth\n", + "R=6370.0 # Radius of earth in km\n", + "\n", + "\n", + "#Calculation\n", + "k=math.acos(R/(R+H))\n", + "#k=k*180/%pi\n", + "k=math.sin(k)\n", + "k=math.ceil(k*1000)/1000\n", + "d=2*(H+R)*k\n", + "\n", + "\n", + "#Result\n", + "print(\"Maximum line-of-sight distance is %.2f km\"%d)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum line-of-sight distance is 83807.86 km\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.9, page no-98" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "H=36000.0 # Height of geostationary satellite from the surface of earth\n", + "R=6370.0 # Radius of earth in km\n", + "theta=20.0 # angular separation between two satellites\n", + "\n", + "\n", + "#Calculation\n", + "D=(H+R)\n", + "k=math.ceil(math.cos(theta*math.pi/180.0)*100)/100\n", + "d=math.sqrt(2*D**2*(1-k))\n", + "\n", + "\n", + "#Result\n", + "print(\"The line-of-sight distance is %.4f km\"%d)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The line-of-sight distance is 14677.3985 km\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.10, page no-98" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "\n", + "theta=37+74 # angular separation between two satellites\n", + "D=42164.0 # circular equilateral geostationary orbit in km\n", + "\n", + "\n", + "#Calculation\n", + "k=math.cos(math.pi*theta/180.0)\n", + "#printf(\"%f\\n\",k)\n", + "k=-0.357952\n", + "d=math.sqrt(2*D**2*(1-k))\n", + "\n", + "\n", + "#Result\n", + "print(\"Inter-satellite distance is %.2f km\"%d)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Inter-satellite distance is 69486.27 km\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.11, page no-99" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "theta_l=30.0 # earth station's location 30\u00b0W longitude\n", + "theta_s=50.0 # satellite's location 50\u00b0W longitude\n", + "theta_L=60.0 # earth station's location 60\u00b0N latitude\n", + "r=42164.0 # orbital radius of the satellite in km\n", + "R=6378.0 # Earth's radius in km\n", + "\n", + "A_dash=math.atan((math.tan(math.pi*(theta_s-theta_l)/180.0))/math.sin(math.pi*60/180.0))\n", + "A_dash=A_dash*180/math.pi\n", + "A=180+A_dash #Azimuth angle\n", + "\n", + "x=(180/math.pi)*math.acos(math.cos(math.pi*(theta_s-theta_l)/180.0)*math.cos(math.pi*theta_L/180))\n", + "y=r-math.ceil(R*(math.cos(math.pi*(theta_s-theta_l)/180.0)*math.cos(math.pi*theta_L/180)))\n", + "z=R*math.sin(math.pi*x/180)\n", + "E=(math.atan(y/z)*180/math.pi)-x\n", + "print(\"Azimuth angle =%.1f\u00b0\\n Elevation angle =%.1f\u00b0\"%(A,E))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Azimuth angle =202.8\u00b0\n", + " Elevation angle =19.8\u00b0\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.12, page no-100" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "theta_l=60.0 #earth station's location 60\u00b0W longitude\n", + "theta_s=105.0 #satellite's location 105\u00b0W longitude\n", + "theta_L=30.0 #earth station's location 30\u00b0N latitude\n", + "\n", + "theta_l1=90.0 #earth station's location 90\u00b0W longitude\n", + "theta_s1=105.0 #satellite's location 105\u00b0W longitude\n", + "theta_L1=45.0 #earth station's location 45\u00b0N latitude\n", + "\n", + "c=3*10**8 # speed of light\n", + "r=42164.0 # orbital radius of the satellite in km\n", + "R=6378.0 # Earth's radius in km\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "x=(180/math.pi)*math.acos(math.cos(math.pi*(theta_s-theta_l)/180)*math.cos(math.pi*theta_L/180))\n", + "y=r-math.ceil(R*(math.cos(math.pi*(theta_s-theta_l)/180)*math.cos(math.pi*theta_L/180)))\n", + "z=R*math.sin(math.pi*x/180)\n", + "E=(math.atan(y/z)*180/math.pi)-x\n", + "\n", + "x1=(180/math.pi)*math.acos(math.cos(math.pi*(theta_s1-theta_l1)/180)*math.cos(math.pi*theta_L1/180))\n", + "y1=r-math.ceil(R*(math.cos(math.pi*(theta_s1-theta_l1)/180)*math.cos(math.pi*theta_L1/180)))\n", + "z1=R*math.sin(math.pi*x1/180)\n", + "E1=(math.atan(y1/z1)*180/math.pi)-x1\n", + "E1=math.floor(E1)\n", + "\n", + "#calculation of slant range dx\n", + "k=(R/r)*math.cos(math.pi*E/180)\n", + "k=(180/math.pi)*math.asin(k)\n", + "k=k+E\n", + "k=math.sin(math.pi*k/180)\n", + "k=math.ceil(k*1000)/1000\n", + "#k=k+E\n", + "#k=sin(k)\n", + "dx=(R)**2+(r)**2-(2*r*R*k)\n", + "dx=math.sqrt(dx)\n", + "\n", + "\n", + "#calculation of slant range dy\n", + "k1=(R/r)*math.cos(math.pi*E1/180)\n", + "k1=(180/math.pi)*math.asin(k1)\n", + "k1=k1+E1\n", + "k1=math.floor(k1)\n", + "k1=math.sin(math.pi*k1/180)\n", + "k1=math.ceil(k1*1000)/1000\n", + "dy=(R)**2+(r)**2-(2*r*R*k1)\n", + "dy=math.sqrt(dy)\n", + "\n", + "tr=dy+dx\n", + "delay=tr*10**6/c\n", + "x=50\n", + "td=delay+x\n", + "\n", + "\n", + "#Result\n", + "print(\"Elevation angle, Ex =%.1f\u00b0\"%E)\n", + "print(\"\\n Elevation angle, Ey =%.1f\u00b0\"%math.floor(E1))\n", + "print(\"\\n Slant range dx of the earth station X is dx=%.2fkm\"%dx)\n", + "print(\"\\n Slant range dy of the earth station Y is dy=%.1fkm\"%dy)\n", + "print(\"\\n Therefore, total range to be covered is %.2fkm\"%tr)\n", + "print(\"\\n propagation delay=%.2fms\"%delay)\n", + "print(\"\\n\\n Time required too transmit 500 kbs of information at \\n a transmisssion speed of 10Mbps is given by 500000/10^7=%.0fms\"%(500000000.0/10**7))\n", + "print(\"\\n\\n Total Delay= %.2fms\"%td)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Elevation angle, Ex =30.3\u00b0\n", + "\n", + " Elevation angle, Ey =36.0\u00b0\n", + "\n", + " Slant range dx of the earth station X is dx=38584.76km\n", + "\n", + " Slant range dy of the earth station Y is dy=38100.8km\n", + "\n", + " Therefore, total range to be covered is 76685.57km\n", + "\n", + " propagation delay=255.62ms\n", + "\n", + "\n", + " Time required too transmit 500 kbs of information at \n", + " a transmisssion speed of 10Mbps is given by 500000/10^7=50ms\n", + "\n", + "\n", + " Total Delay= 305.62ms\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.13, page no-102" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "da=38000.0 # slant range of satellite A\n", + "db=36000.0 # slant range of satellite B\n", + "beeta=60.0 # difference between longitudes of two satellites\n", + "R=42164.0 # radius of the orbit of satellites\n", + "\n", + "\n", + "#Calculation\n", + "theta=(da**2+db**2-2*(R**2)*(1-math.cos(math.pi*beeta/180)))/(2*da*db)\n", + "theta=(180/math.pi)*math.acos(theta)\n", + "d=math.sqrt(2*(R**2)*(1-math.cos(math.pi*beeta/180)))\n", + "\n", + "\n", + "#Result\n", + "print(\"Angular spacing between two satellites viewed by earth station is,\\n theta= %.1f\u00b0\"%theta)\n", + "print(\"\\nInter-satellite distance , d=%.0fkm\"%d)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Angular spacing between two satellites viewed by earth station is,\n", + " theta= 69.4\u00b0\n", + "\n", + "Inter-satellite distance , d=42164km\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.14, page no-107" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "r=42164.0 # orbital radius of the satellite in km\n", + "R=6378.0 # Earth's radius in km\n", + "\n", + "#refer to Figure 3.53\n", + "\n", + "#Calculation\n", + "\n", + "#for E=0\u00b0\n", + "alfa=math.asin(R/r)*(180/math.pi)\n", + "alfa=math.floor(alfa*10)/10\n", + "theta=90-alfa\n", + "#in the right angle triangle OAC,\n", + "k=math.sin(math.pi*alfa/180)\n", + "k=math.floor(k*1000)/1000\n", + "oc=R*k\n", + "oc=math.ceil(oc*10)/10\n", + "A=2*math.pi*R*(R-oc)\n", + "\n", + "\n", + "#for E=10\u00b0\n", + "E=10\n", + "alfa1=math.asin((R/r)*math.cos(math.pi*E/180))*(180/math.pi)\n", + "#alfa1=ceil(alfa1*100)/100\n", + "theta1=90-alfa1-E\n", + "#in the right angle triangle OAC,\n", + "k1=math.sin(math.pi*(alfa1+E)/180)\n", + "k1=math.floor(k1*1000)/1000\n", + "oc1=R*k1\n", + "oc1=math.floor(oc1*10)/10\n", + "A1=2*math.pi*R*(R-oc1)\n", + "\n", + "\n", + "#Result\n", + "print(\"for E=0\u00b0,\\n covered surface area is %.1f km^2\"%A)\n", + "print(\"\\n\\n for E=10\u00b0,\\n covered surface area is %.1f km^2\"%A1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "for E=0\u00b0,\n", + " covered surface area is 216997546.7 km^2\n", + "\n", + "\n", + " for E=10\u00b0,\n", + " covered surface area is 174314563.3 km^2\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.15, page no-108" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#variable declaration\n", + "theta=30 #satellite inclination to the equitorial plan\n", + "\n", + "\n", + "print(\"Extreme Northern latitude covered = %.0f\u00b0 N\"%theta)\n", + "print(\"\\n Extreme Southern latitude covered = %.0f\u00b0 S\"%theta)\n", + "print(\"\\n\\n In fact, the ground track would sweep\\n all latitudes between %d\u00b0N and %d\u00b0S\"%(theta,theta))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Extreme Northern latitude covered = 30\u00b0 N\n", + "\n", + " Extreme Southern latitude covered = 30\u00b0 S\n", + "\n", + "\n", + " In fact, the ground track would sweep\n", + " all latitudes between 30\u00b0N and 30\u00b0S\n" + ] + } + ], + "prompt_number": 16 + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Satellite_Communication/chapter_5.ipynb b/Satellite_Communication/chapter_5.ipynb index 7e2ed39c..130c2bfd 100644 --- a/Satellite_Communication/chapter_5.ipynb +++ b/Satellite_Communication/chapter_5.ipynb @@ -1,605 +1,604 @@ -{
- "metadata": {
- "name": ""
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "chapter 5: Communication Techniques"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.1, page no-174 "
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "\n",
- "\n",
- "#for case (a)\n",
- "\n",
- "#Variable Declaration\n",
- "m=0.5 #modulation index\n",
- "\n",
- "#Calculation\n",
- "#for AM\n",
- "pt1=(1+(m**2)/2.0)\n",
- "#for SSBSC\n",
- "pt2=(m**2)/4.0\n",
- "#% power saving\n",
- "p=(pt1-pt2)*100/pt1\n",
- "p=math.floor(p*10)/10\n",
- "\n",
- "#Result\n",
- "print(\"Percentage power saving is %.1f%%\"%p)\n",
- "\n",
- "#for case (b)\n",
- "\n",
- "#Variable Declaration\n",
- "m=1 #modulation index\n",
- "\n",
- "#Calculation\n",
- "#for AM\n",
- "pt1=(1+(m**2)/2.0)\n",
- "#for SSBSC\n",
- "pt2=(m**2)/4.0\n",
- "#% power saving\n",
- "p=(pt1-pt2)*100/pt1\n",
- "p=math.floor(p*10)/10\n",
- "\n",
- "#Result\n",
- "print(\"\\n Percentage power saving is %.1f%%\"%p)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Percentage power saving is 94.4%\n",
- "\n",
- " Percentage power saving is 83.3%\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.2, page no-174 "
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Variable Declaration\n",
- "pc=500 #energy of carrier signal\n",
- "m=0.6 #AM modulation index\n",
- "\n",
- "\n",
- "#Calculation\n",
- "\n",
- "#for (a)\n",
- "pt=pc*(1+(m**2)/2)\n",
- "\n",
- "#for (b)\n",
- "pt2=pc*(m**2)/4\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"(a)\\n A3E is the double side band AM with full carrier.\\n Therefore, Pt= %.0f W\\n\\n (b)\\n J3E is an SSBSC system.\\n Therefore, Pt= %.0f W\"%(pt,pt2))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(a)\n",
- " A3E is the double side band AM with full carrier.\n",
- " Therefore, Pt= 590 W\n",
- "\n",
- " (b)\n",
- " J3E is an SSBSC system.\n",
- " Therefore, Pt= 45 W\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.3, page no-175 "
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "m=0.6 #60% modulation\n",
- "\n",
- "\n",
- "#Calculation\n",
- "#for A3E\n",
- "pt1=(1+(m**2)/2)\n",
- "#for J3E\n",
- "pt2=(m**2)/4\n",
- "#% power saving\n",
- "p=(pt1-pt2)*100/pt1\n",
- "p=math.ceil(p*10)/10\n",
- "\n",
- "#Result\n",
- "print(\"Percentage power saving is %.2f%%\"%p)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Percentage power saving is 92.40%\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.4, page no-175 "
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Variable Declaration\n",
- "#multiplication of two signals gives AM with frequency component(wc-wm) and (wc+wm) and its BW is 2wm\n",
- "bw=0.5/100 #bw is 0.5% of carrier freq. \n",
- "\n",
- "\n",
- "#Calculation\n",
- "wc=2/bw\n",
- "\n",
- "#Result\n",
- "print(\"Wc = %.0f*Wm\"%wc)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Wc = 400*Wm\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.5, page no-190 "
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "#Variable Declaration\n",
- "#comparing given equation with stanard equation\n",
- "m=6.0 #Modulation Index\n",
- "wc=7.8*10**8 #unmodulated carrier frequency\n",
- "wm=1450 #Modulating frequency\n",
- "\n",
- "\n",
- "#Calculation\n",
- "fc=wc/(2*math.pi)\n",
- "fm=wm/(2*math.pi)\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Unmodulated carrier frequency, fc = %.2f MHz \\n The modulation index m = %d \\n Modulating frequency, fm = %.2f Hz\"%(fc/10**6,m,fm))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Unmodulated carrier frequency, fc = 124.14 MHz \n",
- " The modulation index m = 6 \n",
- " Modulating frequency, fm = 230.77 Hz\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.7, page no-191 "
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Variable Declaration\n",
- "#comparing given equation with stanard equation\n",
- "mf=150 #modulation index\n",
- "fm=1 # modulating frequency in KHz\n",
- "\n",
- "\n",
- "#Calculation\n",
- "fd=mf*fm\n",
- "bw=2*(mf+1)*fm\n",
- "\n",
- "#Result\n",
- "print(\"frequency deviation = %.0f kHz\\n Bandwidth = %.0f kHz \\n\\n Expression for instantaneous frequency is given by, \\n f = 10^8-150*(10^3)*sin(2*3.14*10^3*t)\"%(fd,bw))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "frequency deviation = 150 kHz\n",
- " Bandwidth = 302 kHz \n",
- "\n",
- " Expression for instantaneous frequency is given by, \n",
- " f = 10^8-150*(10^3)*sin(2*3.14*10^3*t)\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.8, page no-191 "
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Variable Declaration\n",
- "fd=50 #frequency deviation in kHz\n",
- "fm=1.0 #modulating frequency in kHz for case 1\n",
- "fm2=100.0 #modulating frequency in kHz for case 2\n",
- "\n",
- "\n",
- "#Calculation\n",
- "#for case 1\n",
- "m=fd/fm\n",
- "bw=2*(m+1)*fm\n",
- "#for case 2\n",
- "m2=fd/fm2\n",
- "bw2=2*(m2+1)*fm2\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"For first case\\n Modulation index = %.0f \\n Bandwidth = %.0f kHz \\n\\n For second case\\n Modulation index = %.1f \\n Bandwidth = %.0f kHz\"%(m,bw,m2,bw2))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": []
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.9, page no-192 "
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Variable Declaration\n",
- "bw=20*10**3 #bandwidth in Hz\n",
- "fm=1* 10**3 #modulating frequency in Hz\n",
- "\n",
- "\n",
- "#Calculation\n",
- "mf=(bw/(2*fm))-1\n",
- "new_mf=mf*6\n",
- "new_fm=0.5 #kHz\n",
- "new_bw=2*(new_mf+1)*new_fm\n",
- "\n",
- "#Result\n",
- "print(\"mf=%.0f\\n New modulation index = %.0f\\n New bandwidth = %.0f kHz\"%(mf,new_mf,new_bw))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "mf=9\n",
- " New modulation index = 54\n",
- " New bandwidth = 55 kHz\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.10, page no-192"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Variable Declaration\n",
- "fd=75.0 #Maximum allowed frequency deviation in kHz\n",
- "fm=15.0 #Highest modulating frequency in kHz\n",
- "\n",
- "\n",
- "#Calculation\n",
- "D=fd/fm\n",
- "bw=2*(D+1)*fm\n",
- "\n",
- "#Result\n",
- "print(\"Deviation Ratio, D = %.0f\\n Bandwidth = %.0f kHz\"%(D,bw))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Deviation Ratio, D = 5\n",
- " Bandwidth = 180 kHz\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.11, page no-199"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "#Variable Declaration\n",
- "fm=3200.0 #highest frequency component in message signal\n",
- "k=48000.0 #channel capacity in b/s\n",
- "\n",
- "#Calculation\n",
- "fs=2*fm\n",
- "n=k/fs\n",
- "n=math.floor(n)\n",
- "\n",
- "#Result\n",
- "print(\"n = %.0f\\n L = 2^7 = %.0f\\n fs = %.3f kHz\"%(n,2**7,(k/7)/1000))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 7\n",
- " L = 2^7 = 128\n",
- " fs = 6.857 kHz\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.12, page no-199"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Variable Declaration\n",
- "#re-arranging equation and comparing it with standard equation we have,\n",
- "f=2500 #Highest frequency component in the signal in Hz\n",
- "\n",
- "#result\n",
- "print(\"Nyquist rate = 2 x f\\n\\t = %.0f Hz = %.0f kHz\"%(2*f,2*f/1000))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Nyquist rate = 2 x f\n",
- "\t = 5000 Hz = 5 kHz\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.13, page no-199"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "l=128 #no of Quantizing levels\n",
- "fs=10000.0 #sampling frequency in Hz\n",
- "\n",
- "\n",
- "#Calculation\n",
- "n=7 #math.log2(l)\n",
- "t=1/(n*fs)\n",
- "\n",
- "#Result\n",
- "print(\"Number of bits per sample (n) = %.0f\\n Time duration of one bit of binary encoded signal is %.3f micro second\"%(n,t*10**6))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Number of bits per sample (n) = 7\n",
- " Time duration of one bit of binary encoded signal is 14.286 micro second\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.15, page no-208"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "f1=2.4 #first signal frequency\n",
- "f2=3.2 #2nd signal frequency\n",
- "f3=3.4 #3rd signal frequency\n",
- "\n",
- "#minimum sampling rate for each of the signals would be twice the highest frequency component\n",
- "\n",
- "\n",
- "sr=3*(f3*2)\n",
- "st=10**6/(sr*10**3)\n",
- "print(\"Sampling rate of the composite signal = %.1f kHz \\nSampling interval of the composite signal = %.0f micro second\"%(sr,st))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sampling rate of the composite signal = 20.4 kHz \n",
- "Sampling interval of the composite signal = 49 micro second\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 5.16, page no-209"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "bw=3.2 # voice channel band limited frequency in kHz\n",
- "r=1.2 # 1.2 times the Nyquist rate\n",
- "n=24.0 # no of voice channel\n",
- "b=8.0 # 8-bit PCM\n",
- "sr=2*bw*r\n",
- "p=10**6/(sr*10**3)\n",
- "N=(n*b)+1\n",
- "bit_d=p/N\n",
- "bit_d=math.ceil(bit_d*1000)/1000\n",
- "tr=1/bit_d\n",
- "\n",
- "print(\"Number of bits in each frame = %.0f \\nBit duration = %.3f micro second \\nTransmission rate = %.3f Mbps\"%(N,bit_d,math.ceil(tr*1000)/1000))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Number of bits in each frame = 193 \n",
- "Bit duration = 0.675 micro second \n",
- "Transmission rate = 1.482 Mbps\n"
- ]
- }
- ],
- "prompt_number": 21
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:0567df6d143de5413d3406fc62e3bde7360c6adec18cda1ddb49a1255bcf929f" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "chapter 5: Communication Techniques" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.1, page no-174 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "\n", + "\n", + "\n", + "\n", + "#Variable Declaration\n", + "m=0.5 #modulation index\n", + "\n", + "#Calculation\n", + "#for AM\n", + "pt1=(1+(m**2)/2.0)\n", + "#for SSBSC\n", + "pt2=(m**2)/4.0\n", + "#% power saving\n", + "p=(pt1-pt2)*100/pt1\n", + "p=math.floor(p*10)/10\n", + "\n", + "#Result\n", + "print(\"Percentage power saving is %.1f%%\"%p)\n", + "\n", + "#for case (b)\n", + "\n", + "#Variable Declaration\n", + "m=1 #modulation index\n", + "\n", + "#Calculation\n", + "#for AM\n", + "pt1=(1+(m**2)/2.0)\n", + "#for SSBSC\n", + "pt2=(m**2)/4.0\n", + "#% power saving\n", + "p=(pt1-pt2)*100/pt1\n", + "p=math.floor(p*10)/10\n", + "\n", + "#Result\n", + "print(\"\\n Percentage power saving is %.1f%%\"%p)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Percentage power saving is 94.4%\n", + "\n", + " Percentage power saving is 83.3%\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.2, page no-174 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable Declaration\n", + "pc=500 #energy of carrier signal\n", + "m=0.6 #AM modulation index\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "#for (a)\n", + "pt=pc*(1+(m**2)/2)\n", + "\n", + "#for (b)\n", + "pt2=pc*(m**2)/4\n", + "\n", + "\n", + "#Result\n", + "print(\"(a)\\n A3E is the double side band AM with full carrier.\\n Therefore, Pt= %.0f W\\n\\n (b)\\n J3E is an SSBSC system.\\n Therefore, Pt= %.0f W\"%(pt,pt2))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a)\n", + " A3E is the double side band AM with full carrier.\n", + " Therefore, Pt= 590 W\n", + "\n", + " (b)\n", + " J3E is an SSBSC system.\n", + " Therefore, Pt= 45 W\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.3, page no-175 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "m=0.6 #60% modulation\n", + "\n", + "\n", + "#Calculation\n", + "#for A3E\n", + "pt1=(1+(m**2)/2)\n", + "#for J3E\n", + "pt2=(m**2)/4\n", + "#% power saving\n", + "p=(pt1-pt2)*100/pt1\n", + "p=math.ceil(p*10)/10\n", + "\n", + "#Result\n", + "print(\"Percentage power saving is %.2f%%\"%p)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Percentage power saving is 92.40%\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.4, page no-175 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable Declaration\n", + "\n", + "bw=0.5/100 #bw is 0.5% of carrier freq. \n", + "\n", + "\n", + "#Calculation\n", + "wc=2/bw\n", + "\n", + "#Result\n", + "print(\"Wc = %.0f*Wm\"%wc)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Wc = 400*Wm\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.5, page no-190 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "\n", + "m=6.0 #Modulation Index\n", + "wc=7.8*10**8 #unmodulated carrier frequency\n", + "wm=1450 #Modulating frequency\n", + "\n", + "\n", + "#Calculation\n", + "fc=wc/(2*math.pi)\n", + "fm=wm/(2*math.pi)\n", + "\n", + "\n", + "#Result\n", + "print(\"Unmodulated carrier frequency, fc = %.2f MHz \\n The modulation index m = %d \\n Modulating frequency, fm = %.2f Hz\"%(fc/10**6,m,fm))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Unmodulated carrier frequency, fc = 124.14 MHz \n", + " The modulation index m = 6 \n", + " Modulating frequency, fm = 230.77 Hz\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.7, page no-191 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "mf=150 #modulation index\n", + "fm=1 # modulating frequency in KHz\n", + "\n", + "\n", + "#Calculation\n", + "fd=mf*fm\n", + "bw=2*(mf+1)*fm\n", + "\n", + "#Result\n", + "print(\"frequency deviation = %.0f kHz\\n Bandwidth = %.0f kHz \\n\\n Expression for instantaneous frequency is given by, \\n f = 10^8-150*(10^3)*sin(2*3.14*10^3*t)\"%(fd,bw))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "frequency deviation = 150 kHz\n", + " Bandwidth = 302 kHz \n", + "\n", + " Expression for instantaneous frequency is given by, \n", + " f = 10^8-150*(10^3)*sin(2*3.14*10^3*t)\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.8, page no-191 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable Declaration\n", + "fd=50 #frequency deviation in kHz\n", + "fm=1.0 #modulating frequency in kHz for case 1\n", + "fm2=100.0 #modulating frequency in kHz for case 2\n", + "\n", + "\n", + "#Calculation\n", + "#for case 1\n", + "m=fd/fm\n", + "bw=2*(m+1)*fm\n", + "#for case 2\n", + "m2=fd/fm2\n", + "bw2=2*(m2+1)*fm2\n", + "\n", + "\n", + "#Result\n", + "print(\"For first case\\n Modulation index = %.0f \\n Bandwidth = %.0f kHz \\n\\n For second case\\n Modulation index = %.1f \\n Bandwidth = %.0f kHz\"%(m,bw,m2,bw2))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.9, page no-192 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable Declaration\n", + "bw=20*10**3 #bandwidth in Hz\n", + "fm=1* 10**3 #modulating frequency in Hz\n", + "\n", + "\n", + "#Calculation\n", + "mf=(bw/(2*fm))-1\n", + "new_mf=mf*6\n", + "new_fm=0.5 #kHz\n", + "new_bw=2*(new_mf+1)*new_fm\n", + "\n", + "#Result\n", + "print(\"mf=%.0f\\n New modulation index = %.0f\\n New bandwidth = %.0f kHz\"%(mf,new_mf,new_bw))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "mf=9\n", + " New modulation index = 54\n", + " New bandwidth = 55 kHz\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.10, page no-192" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Variable Declaration\n", + "fd=75.0 #Maximum allowed frequency deviation in kHz\n", + "fm=15.0 #Highest modulating frequency in kHz\n", + "\n", + "\n", + "#Calculation\n", + "D=fd/fm\n", + "bw=2*(D+1)*fm\n", + "\n", + "#Result\n", + "print(\"Deviation Ratio, D = %.0f\\n Bandwidth = %.0f kHz\"%(D,bw))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Deviation Ratio, D = 5\n", + " Bandwidth = 180 kHz\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.11, page no-199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "fm=3200.0 #highest frequency component in message signal\n", + "k=48000.0 #channel capacity in b/s\n", + "\n", + "#Calculation\n", + "fs=2*fm\n", + "n=k/fs\n", + "n=math.floor(n)\n", + "\n", + "#Result\n", + "print(\"n = %.0f\\n L = 2^7 = %.0f\\n fs = %.3f kHz\"%(n,2**7,(k/7)/1000))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "n = 7\n", + " L = 2^7 = 128\n", + " fs = 6.857 kHz\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.12, page no-199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "f=2500 #Highest frequency component in the signal in Hz\n", + "\n", + "#result\n", + "print(\"Nyquist rate = 2 x f\\n\\t = %.0f Hz = %.0f kHz\"%(2*f,2*f/1000))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Nyquist rate = 2 x f\n", + "\t = 5000 Hz = 5 kHz\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.13, page no-199" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "l=128 #no of Quantizing levels\n", + "fs=10000.0 #sampling frequency in Hz\n", + "\n", + "\n", + "#Calculation\n", + "n=7 #math.log2(l)\n", + "t=1/(n*fs)\n", + "\n", + "#Result\n", + "print(\"Number of bits per sample (n) = %.0f\\n Time duration of one bit of binary encoded signal is %.3f micro second\"%(n,t*10**6))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number of bits per sample (n) = 7\n", + " Time duration of one bit of binary encoded signal is 14.286 micro second\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.15, page no-208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "f1=2.4 #first signal frequency\n", + "f2=3.2 #2nd signal frequency\n", + "f3=3.4 #3rd signal frequency\n", + "\n", + "t\n", + "\n", + "\n", + "sr=3*(f3*2)\n", + "st=10**6/(sr*10**3)\n", + "print(\"Sampling rate of the composite signal = %.1f kHz \\nSampling interval of the composite signal = %.0f micro second\"%(sr,st))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sampling rate of the composite signal = 20.4 kHz \n", + "Sampling interval of the composite signal = 49 micro second\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.16, page no-209" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "bw=3.2 # voice channel band limited frequency in kHz\n", + "r=1.2 # 1.2 times the Nyquist rate\n", + "n=24.0 # no of voice channel\n", + "b=8.0 # 8-bit PCM\n", + "sr=2*bw*r\n", + "p=10**6/(sr*10**3)\n", + "N=(n*b)+1\n", + "bit_d=p/N\n", + "bit_d=math.ceil(bit_d*1000)/1000\n", + "tr=1/bit_d\n", + "\n", + "print(\"Number of bits in each frame = %.0f \\nBit duration = %.3f micro second \\nTransmission rate = %.3f Mbps\"%(N,bit_d,math.ceil(tr*1000)/1000))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number of bits in each frame = 193 \n", + "Bit duration = 0.675 micro second \n", + "Transmission rate = 1.482 Mbps\n" + ] + } + ], + "prompt_number": 21 + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Satellite_Communication/chapter_7.ipynb b/Satellite_Communication/chapter_7.ipynb index 1ed28d5b..45cec90e 100644 --- a/Satellite_Communication/chapter_7.ipynb +++ b/Satellite_Communication/chapter_7.ipynb @@ -1,746 +1,746 @@ -{
- "metadata": {
- "name": ""
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "chapter 7: Satellite Link Design Fundamentals"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.1, page no-249"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "#Variable Declaration\n",
- "d=36000 *10**3 #distance of geostationary satellite from earth's surface\n",
- "Gt=100 # Antenna gain of 20dB\n",
- "Pt=10 # Power radiated by earth station\n",
- "\n",
- "#Calculation\n",
- "Prd=Pt*Gt/(4*math.pi*d**2)\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Prd = %.4f * 10 ^-12 W/m^2\\nPower received by the receiving antenna is given by Pr = %.3f pW\"%(Prd*10**12,Prd*10**13))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Prd = 0.0614 * 10 ^-12 W/m^2\n",
- "Power received by the receiving antenna is given by Pr = 0.614 pW\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.2, page no-262"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "c=3*10**8 #speed of light \n",
- "R=10000 #path length\n",
- "f=4.0 # operating frequencyin GHz\n",
- "EIRP=50 #in dB\n",
- "gr=20 #antenna gain in dB\n",
- "rp=-120 # received power in dB\n",
- "\n",
- "\n",
- "#Calculation\n",
- "\n",
- "#(a)\n",
- "lamda=c/(f*10**9)\n",
- "pl=20*math.log10(4*math.pi*R/lamda)\n",
- "\n",
- "#(b)\n",
- "Lp=EIRP+gr-rp\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"(a)\\n Operating wavelength = %.3f m\\n Path loss(in dB) = %.2f dB\"%(lamda,pl))\n",
- "print(\"\\n\\n (b)\\n Path loss = %.0fdB\"%Lp)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(a)\n",
- " Operating wavelength = 0.075 m\n",
- " Path loss(in dB) = 124.48 dB\n",
- "\n",
- "\n",
- " (b)\n",
- " Path loss = 190dB\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.3, page no-262"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "#Variable Declaration\n",
- "p=75 # rotation of plane of polarization\n",
- "\n",
- "#Polarization rotation is inversaly propotional to square of the operating frequency\n",
- "\n",
- "f= 5.0 #frequency increased by factor \n",
- "x=f**2 #rotation angle will decrease by aa factor of 25\n",
- "\n",
- "\n",
- "#Calculation\n",
- "k=math.pi/180.0\n",
- "p_ex=p/x\n",
- "Apr=-20*math.log10(math.cos(p*k))\n",
- "Apr2=-20*math.log10(math.cos((p_ex)*k))\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"For polarization mismatch angle = 75\u00b0\\n Attenuation = %.2f dB\"%Apr)\n",
- "print(\"\\n\\n For polarization mismatch angle = 3\u00b0 \\n Attenuation = %.3f dB\"%Apr2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "For polarization mismatch angle = 75\u00b0\n",
- " Attenuation = 11.74 dB\n",
- "\n",
- "\n",
- " For polarization mismatch angle = 3\u00b0 \n",
- " Attenuation = 0.012 dB\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.4, page no-270"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Variable Declaration\n",
- "g1=30 #gain of RF stage in dB\n",
- "t1=20 #Noise temperature in K\n",
- "g2=10 #down converter gain in dB\n",
- "t2=360 #noise temperature in K\n",
- "g3=15 #gain of IF stage in dB\n",
- "t3=1000 #noise temperature in K\n",
- "t=290 #reference temperature in K\n",
- "G1=1000.0 #30 dB equivalent gain\n",
- "\n",
- "\n",
- "#Calculation\n",
- "Te=t1+(t2/G1)+t3/(G1*g2)\n",
- "F=1+Te/t\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Effective noise temperature, Te = %.2fK\"%Te)\n",
- "print(\"\\n\\nSystem Noise Figure, F = %.2f\"%F)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Effective noise temperature, Te = 20.46K\n",
- "\n",
- "\n",
- "System Noise Figure, F = 1.07\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.5, page no-271"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Variable Declaration\n",
- "g1=30 #gain of RF stage in dB\n",
- "t1=20 #Noise temperature in K\n",
- "g2=10 #down converter gain in dB\n",
- "t2=360.0 #noise temperature in K\n",
- "g3=15 #gain of IF stage in dB\n",
- "t3=1000 #noise temperature in K\n",
- "t=290.0 #reference temperature in K\n",
- "G1=1000.0 #30 dB equivalent gain\n",
- "\n",
- "\n",
- "#Calculation\n",
- "F1=1+t1/t\n",
- "F2=1+t2/t\n",
- "F3=1+t3/t\n",
- "F=F1+((F2-1)/G1)+(F3-1)/(G1*g2)\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Noise Figure specificatios of the three stages are as follow,\\n\\n F1 = %.3f\\n F2 = %.2f\\n F3 = %.2f\"%(F1,F2,F3))\n",
- "print(\"\\n\\n The overall noise figure is, F = %.2f\"%F)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Noise Figure specificatios of the three stages are as follow,\n",
- "\n",
- " F1 = 1.069\n",
- " F2 = 2.24\n",
- " F3 = 4.45\n",
- "\n",
- "\n",
- " The overall noise figure is, F = 1.07\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.6, page no-272"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "#Variable Declaration\n",
- "L=1.778 #Loss factor of the feeder 2.5dB equivalent\n",
- "ts=30 #Noise temperature of sattelite receiver in K\n",
- "t=50 #Noise temperature in K\n",
- "ti=290.0 # reference temperature in K\n",
- "\n",
- "\n",
- "#Calculation\n",
- "x=t/L\n",
- "y=ti*(L-1)/L\n",
- "Te=x+y+ts\n",
- "F1=1+(ts/ti)\n",
- "F2=1+(Te/ti)\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"contribution of antenna noise temperature when\\n referred to the input of the receiver is %.1f K\"%x)\n",
- "print(\"\\n\\n Contribution of feeder noise when referred to the\\n input of the receiver is %.1f\"%y)\n",
- "print(\"\\n\\n1. Noise figure in first case = %.3f = %.3f dB\"%(F1,10*math.log10(F1)))#answer in book is different 0.426dB\n",
- "print(\"\\n\\n2. Noise figure in second case = %.3f = %.2f dB\"%(F2,10*math.log10(F2)))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "contribution of antenna noise temperature when\n",
- " referred to the input of the receiver is 28.1 K\n",
- "\n",
- "\n",
- " Contribution of feeder noise when referred to the\n",
- " input of the receiver is 126.9\n",
- "\n",
- "\n",
- "1. Noise figure in first case = 1.103 = 0.428 dB\n",
- "\n",
- "\n",
- "2. Noise figure in second case = 1.638 = 2.14 dB\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.7, page no-272"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "#Variable Declaration\n",
- "Ta=40 #Antenna Noise temperature\n",
- "Ti=290.0 #Reference temperature in K\n",
- "T=50.0 #Effecitve input noise temperatuire\n",
- "\n",
- "#Calculation\n",
- "Tf=Ti\n",
- "L=(Ta-Tf)/(T-Tf)\n",
- "L=math.ceil(L*10**4)/10**4\n",
- "\n",
- "#Result\n",
- "print(\"Loss factor = %.4f = %.3f dB\"%(L,10*math.log10(L)))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Loss factor = 1.0417 = 0.177 dB\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.8, page no-273"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "\n",
- "#Variable Declaration\n",
- "Ta=50 #Antenna Noise temperature\n",
- "Tf=300 #Thermodynamic temperature of the feeder\n",
- "Te=50 # Effecitve input noise temperatuire\n",
- "\n",
- "\n",
- "#Calculation for (a)\n",
- "Lf=1.0\n",
- "T=(Ta/Lf)+(Tf*(Lf-1)/Lf)+Te\n",
- "\n",
- "#Result for (a)\n",
- "print(\"(a)\\n System noise temperature = %.0fK\"%T)\n",
- "\n",
- "#Calculation for (b)\n",
- "Lf=1.413\n",
- "T=(Ta/Lf)+(Tf*(Lf-1)/Lf)+Te\n",
- "\n",
- "#Result for (b)\n",
- "print(\"\\n\\n (b)\\n System noise temperature = %.3fK\"%(math.ceil(T*10**3)/10**3))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(a)\n",
- " System noise temperature = 100K\n",
- "\n",
- "\n",
- " (b)\n",
- " System noise temperature = 173.072K\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.9, page no-278"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "\n",
- "#Variable Declaration\n",
- "e=35 #EIRP radiated by satellite in dBW\n",
- "g=50 #receiver antenna gain in dB\n",
- "e1=30 #EIRP of interfacing satellite in dBW\n",
- "theeta=4 #line-of-sight between earth station and interfacing sattelite\n",
- "\n",
- "\n",
- "#Calculation\n",
- "x=(e-e1)+(g-32+25*math.log10(theeta))\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"carrier-to-interface (C/I) = %.2f dB\"%x)\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "carrier-to-interface (C/I) = 38.05 dB\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.10, page no-279"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "\n",
- "#Variable Declaration\n",
- "ea=80 #EIRP value of earth station A in dBW\n",
- "eb=75 #EIRP value of earth station B in dBW\n",
- "g=50 #transmit antenna gain in dB\n",
- "gra=20 #receiver antenna gain for earth station A in dB\n",
- "grb=15 #receiver antenna gain for earth station B in dB\n",
- "theeta=4 #viewing angle of the sattelite from two earth station\n",
- "\n",
- "\n",
- "#Calculation\n",
- "eirp_d=eb-g+32-25*math.log10(theeta)\n",
- "c_by_i=ea-eirp_d+(gra-grb)\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"carrier-to-interference ratio at the satellite due to\\n inteference caused by Eart station B is, (C/I) = %.0f dB \"%c_by_i)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "carrier-to-interference ratio at the satellite due to\n",
- " inteference caused by Eart station B is, (C/I) = 43 dB \n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.11, page no-279"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "\n",
- "#Variable Declaration\n",
- "\n",
- "#carrier sinal strength at sattelite by uplink\n",
- "u=10000.0 # equivalent to 40dB\n",
- "\n",
- "#carrier sinal strength at eart station by downlink \n",
- "d=3162.28 #equivalent to 35dB\n",
- "\n",
- "\n",
- "#Calculation\n",
- "x=1/((1/u)+(1/d))\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"Total carrier-to-interference ratio is %.2f = %.1f dB\"%(x,10*math.log10(x)))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Total carrier-to-interference ratio is 2402.53 = 33.8 dB\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.12, Page no.280"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "#Variable Declaration\n",
- "theeta=5.0 #Angle form by slant ranges of two satellites\n",
- "dA=42100.0*10**3 #Slant range of satellite A\n",
- "dB=42000.0*10**3 #Slant range of satellite B\n",
- "r=42164.0*10**3 #radius of geostationary orbit\n",
- "\n",
- "\n",
- "#Calculation\n",
- "beeta=((dA**2+dB**2-math.cos(theeta*math.pi/180)*2*dA*dB)/(2*r**2))\n",
- "beeta=math.ceil(beeta*10**3)/10**3\n",
- "beeta=(180/math.pi)*math.acos(1-beeta)\n",
- "\n",
- "#Result\n",
- "print(\"Longitudinal separation between two satellites is %.3f\u00b0\"%beeta)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Longitudinal separation between two satellites is 5.126\u00b0\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.13, Page no.281"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "\n",
- "#Variable Declaration\n",
- "Ga=60.0 #Antenna Gain in dB\n",
- "Ta= 60.0 #Noise teperature of Antenna\n",
- "L1=1.12 #Feeder Loss equivalent to dB\n",
- "T1=290.0 #Noise teperature of stage 1\n",
- "G2=10**6 #Gain of stage 2 in dB\n",
- "T2=140.0 #Noise teperature of stage 2\n",
- "T3=10000.0 #Noise teperature of stage 3\n",
- "G=Ga-0.5 #input of low noise amplifier\n",
- "\n",
- "\n",
- "#Calculation\n",
- "Ts=(Ta/L1)+(T1*(L1-1)/L1)+T2+(T3/G2)\n",
- "Ts=math.floor(Ts*100)/100\n",
- "x=G-10*math.log10(Ts)\n",
- "\n",
- "#Result\n",
- "print(\"Tsi = %.2fK\\n\\n G/T(in dB/K)= %.0f dB/K\"%(Ts,x))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Tsi = 224.65K\n",
- "\n",
- " G/T(in dB/K)= 36 dB/K\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.14, Page no.282"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "\n",
- "#Variable Declaration\n",
- "Ga=60.0 #Amplifier Gain in dB\n",
- "Ta= 60.0 #Noise teperature of Antenna\n",
- "L1=1.12 #Feeder Loss equivalent to dB\n",
- "T1=290.0 #Noise teperature of stage 1\n",
- "G2=10**6 #Gain of stage 2 in dB\n",
- "T2=140.0 #Noise teperature of stage 2\n",
- "T3=10000.0 #Noise teperature of stage 3\n",
- "G=Ga-0.5 #input of low noise amplifier\n",
- "\n",
- "\n",
- "#Calculation\n",
- "T=Ta+T1*(L1-1)+L1*(T2+(T3/G2))\n",
- "x=G-10*math.log10(T)\n",
- "\n",
- "\n",
- "#Result\n",
- "print(\"T = %.1fK\\n\\n G/T = %.0f dB/k\"%(T,math.ceil(x)))\n",
- "print(\"\\n\\n It is evident from the solutions of the problems 13 and 14\\n that G/T ratio is invarient regardless of the reference point in agreement \\n with a statement made earlier in the text.\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": "*"
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 7.15, Page no.286"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import math\n",
- "#Variable Declaration\n",
- "f=6.0*10**9 # uplink frequency\n",
- "eirp=80.0 # Earth station EIRP in dBW\n",
- "r=35780.0 # Earth station satellite distance\n",
- "l=2.0 # attenuation due to atomospheric factors in dB\n",
- "e=0.8 # satellite antenna's aperture efficiency\n",
- "a=0.5 # satellite antenna's aperture area\n",
- "T=190.0 # Satellite receiver's effective noise temperature \n",
- "bw=20.0*10**6 # Satellite receiver's bandwidth\n",
- "cn=25.0 # received carrier-to-noise ratioin dB\n",
- "c=3.0*10**8 # speed of light\n",
- "\n",
- "#Calculation\n",
- "k=1.38*10**-23\n",
- "lamda=c/f\n",
- "G=e*4*math.pi*a/lamda**2\n",
- "G=math.ceil(G*100)/100\n",
- "Gd=10*math.log10(G)\n",
- "p=10*math.log10(k*T*bw)\n",
- "pl=20*math.log10(4*math.pi*r*10**3/lamda)\n",
- "rp=eirp-l-pl+Gd\n",
- "rp=math.floor(rp*100)/100\n",
- "rc=math.floor((rp-p)*100)/100\n",
- "lm=rc-cn\n",
- "\n",
- "#Result\n",
- "print(\"Satellite Antenna gain, G = %.2f = %.2f dB \\n Receivers Noise Power = %.1f dB\\n free-space path loss = %.2f dB \\n received power at satellite = %.2f dB \\n receiver carrier = %.2f is stronger than noise.\\n It is %.2f dB more than the required threshold value.\\n Hence, link margin = %.2f dB\"%(G,Gd,p,pl,rp,rc,lm,lm))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Satellite Antenna gain, G = 2010.62 = 33.03 dB \n",
- " Receivers Noise Power = -132.8 dB\n",
- " free-space path loss = 199.08 dB \n",
- " received power at satellite = -88.05 dB \n",
- " receiver carrier = 44.75 is stronger than noise.\n",
- " It is 19.75 dB more than the required threshold value.\n",
- " Hence, link margin = 19.75 dB\n"
- ]
- }
- ],
- "prompt_number": 1
- }
- ],
- "metadata": {}
- }
- ]
+{ + "metadata": { + "name": "", + "signature": "sha256:d8e48debe58189bda0ba7970010a7f3d133d055f445572e1b90b2e8739a1cc2b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "chapter 7: Satellite Link Design Fundamentals" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.1, page no-249" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "d=36000 *10**3 #distance of geostationary satellite from earth's surface\n", + "Gt=100 # Antenna gain of 20dB\n", + "Pt=10 # Power radiated by earth station\n", + "\n", + "#Calculation\n", + "Prd=Pt*Gt/(4*math.pi*d**2)\n", + "\n", + "\n", + "#Result\n", + "print(\"Prd = %.4f * 10 ^-12 W/m^2\\nPower received by the receiving antenna is given by Pr = %.3f pW\"%(Prd*10**12,Prd*10**13))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Prd = 0.0614 * 10 ^-12 W/m^2\n", + "Power received by the receiving antenna is given by Pr = 0.614 pW\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.2, page no-262" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "c=3*10**8 #speed of light \n", + "R=10000 #path length\n", + "f=4.0 # operating frequencyin GHz\n", + "EIRP=50 #in dB\n", + "gr=20 #antenna gain in dB\n", + "rp=-120 # received power in dB\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "#(a)\n", + "lamda=c/(f*10**9)\n", + "pl=20*math.log10(4*math.pi*R/lamda)\n", + "\n", + "#(b)\n", + "Lp=EIRP+gr-rp\n", + "\n", + "\n", + "#Result\n", + "print(\"(a)\\n Operating wavelength = %.3f m\\n Path loss(in dB) = %.2f dB\"%(lamda,pl))\n", + "print(\"\\n\\n (b)\\n Path loss = %.0fdB\"%Lp)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a)\n", + " Operating wavelength = 0.075 m\n", + " Path loss(in dB) = 124.48 dB\n", + "\n", + "\n", + " (b)\n", + " Path loss = 190dB\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.3, page no-262" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "p=75 # rotation of plane of polarization\n", + "\n", + "#Polarization rotation is inversaly propotional to square of the operating frequency\n", + "\n", + "f= 5.0 #frequency increased by factor \n", + "x=f**2 #rotation angle will decrease by aa factor of 25\n", + "\n", + "\n", + "#Calculation\n", + "k=math.pi/180.0\n", + "p_ex=p/x\n", + "Apr=-20*math.log10(math.cos(p*k))\n", + "Apr2=-20*math.log10(math.cos((p_ex)*k))\n", + "\n", + "\n", + "#Result\n", + "print(\"For polarization mismatch angle = 75\u00b0\\n Attenuation = %.2f dB\"%Apr)\n", + "print(\"\\n\\n For polarization mismatch angle = 3\u00b0 \\n Attenuation = %.3f dB\"%Apr2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "For polarization mismatch angle = 75\u00b0\n", + " Attenuation = 11.74 dB\n", + "\n", + "\n", + " For polarization mismatch angle = 3\u00b0 \n", + " Attenuation = 0.012 dB\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.4, page no-270" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable Declaration\n", + "g1=30 #gain of RF stage in dB\n", + "t1=20 #Noise temperature in K\n", + "g2=10 #down converter gain in dB\n", + "t2=360 #noise temperature in K\n", + "g3=15 #gain of IF stage in dB\n", + "t3=1000 #noise temperature in K\n", + "t=290 #reference temperature in K\n", + "G1=1000.0 #30 dB equivalent gain\n", + "\n", + "\n", + "#Calculation\n", + "Te=t1+(t2/G1)+t3/(G1*g2)\n", + "F=1+Te/t\n", + "\n", + "\n", + "#Result\n", + "print(\"Effective noise temperature, Te = %.2fK\"%Te)\n", + "print(\"\\n\\nSystem Noise Figure, F = %.2f\"%F)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Effective noise temperature, Te = 20.46K\n", + "\n", + "\n", + "System Noise Figure, F = 1.07\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.5, page no-271" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable Declaration\n", + "g1=30 #gain of RF stage in dB\n", + "t1=20 #Noise temperature in K\n", + "g2=10 #down converter gain in dB\n", + "t2=360.0 #noise temperature in K\n", + "g3=15 #gain of IF stage in dB\n", + "t3=1000 #noise temperature in K\n", + "t=290.0 #reference temperature in K\n", + "G1=1000.0 #30 dB equivalent gain\n", + "\n", + "\n", + "#Calculation\n", + "F1=1+t1/t\n", + "F2=1+t2/t\n", + "F3=1+t3/t\n", + "F=F1+((F2-1)/G1)+(F3-1)/(G1*g2)\n", + "\n", + "\n", + "#Result\n", + "print(\"Noise Figure specificatios of the three stages are as follow,\\n\\n F1 = %.3f\\n F2 = %.2f\\n F3 = %.2f\"%(F1,F2,F3))\n", + "print(\"\\n\\n The overall noise figure is, F = %.2f\"%F)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Noise Figure specificatios of the three stages are as follow,\n", + "\n", + " F1 = 1.069\n", + " F2 = 2.24\n", + " F3 = 4.45\n", + "\n", + "\n", + " The overall noise figure is, F = 1.07\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.6, page no-272" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "L=1.778 #Loss factor of the feeder 2.5dB equivalent\n", + "ts=30 #Noise temperature of sattelite receiver in K\n", + "t=50 #Noise temperature in K\n", + "ti=290.0 # reference temperature in K\n", + "\n", + "\n", + "#Calculation\n", + "x=t/L\n", + "y=ti*(L-1)/L\n", + "Te=x+y+ts\n", + "F1=1+(ts/ti)\n", + "F2=1+(Te/ti)\n", + "\n", + "\n", + "#Result\n", + "print(\"contribution of antenna noise temperature when\\n referred to the input of the receiver is %.1f K\"%x)\n", + "print(\"\\n\\n Contribution of feeder noise when referred to the\\n input of the receiver is %.1f\"%y)\n", + "print(\"\\n\\n1. Noise figure in first case = %.3f = %.3f dB\"%(F1,10*math.log10(F1)))#answer in book is different 0.426dB\n", + "print(\"\\n\\n2. Noise figure in second case = %.3f = %.2f dB\"%(F2,10*math.log10(F2)))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "contribution of antenna noise temperature when\n", + " referred to the input of the receiver is 28.1 K\n", + "\n", + "\n", + " Contribution of feeder noise when referred to the\n", + " input of the receiver is 126.9\n", + "\n", + "\n", + "1. Noise figure in first case = 1.103 = 0.428 dB\n", + "\n", + "\n", + "2. Noise figure in second case = 1.638 = 2.14 dB\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.7, page no-272" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "Ta=40 #Antenna Noise temperature\n", + "Ti=290.0 #Reference temperature in K\n", + "T=50.0 #Effecitve input noise temperatuire\n", + "\n", + "#Calculation\n", + "Tf=Ti\n", + "L=(Ta-Tf)/(T-Tf)\n", + "L=math.ceil(L*10**4)/10**4\n", + "\n", + "#Result\n", + "print(\"Loss factor = %.4f = %.3f dB\"%(L,10*math.log10(L)))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Loss factor = 1.0417 = 0.177 dB\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.8, page no-273" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "\n", + "#Variable Declaration\n", + "Ta=50 #Antenna Noise temperature\n", + "Tf=300 #Thermodynamic temperature of the feeder\n", + "Te=50 # Effecitve input noise temperatuire\n", + "\n", + "\n", + "#Calculation for (a)\n", + "Lf=1.0\n", + "T=(Ta/Lf)+(Tf*(Lf-1)/Lf)+Te\n", + "\n", + "#Result for (a)\n", + "print(\"(a)\\n System noise temperature = %.0fK\"%T)\n", + "\n", + "#Calculation for (b)\n", + "Lf=1.413\n", + "T=(Ta/Lf)+(Tf*(Lf-1)/Lf)+Te\n", + "\n", + "#Result for (b)\n", + "print(\"\\n\\n (b)\\n System noise temperature = %.3fK\"%(math.ceil(T*10**3)/10**3))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a)\n", + " System noise temperature = 100K\n", + "\n", + "\n", + " (b)\n", + " System noise temperature = 173.072K\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.9, page no-278" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "\n", + "#Variable Declaration\n", + "e=35 #EIRP radiated by satellite in dBW\n", + "g=50 #receiver antenna gain in dB\n", + "e1=30 #EIRP of interfacing satellite in dBW\n", + "theeta=4 #line-of-sight between earth station and interfacing sattelite\n", + "\n", + "\n", + "#Calculation\n", + "x=(e-e1)+(g-32+25*math.log10(theeta))\n", + "\n", + "\n", + "#Result\n", + "print(\"carrier-to-interface (C/I) = %.2f dB\"%x)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "carrier-to-interface (C/I) = 38.05 dB\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.10, page no-279" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "\n", + "#Variable Declaration\n", + "ea=80 #EIRP value of earth station A in dBW\n", + "eb=75 #EIRP value of earth station B in dBW\n", + "g=50 #transmit antenna gain in dB\n", + "gra=20 #receiver antenna gain for earth station A in dB\n", + "grb=15 #receiver antenna gain for earth station B in dB\n", + "theeta=4 #viewing angle of the sattelite from two earth station\n", + "\n", + "\n", + "#Calculation\n", + "eirp_d=eb-g+32-25*math.log10(theeta)\n", + "c_by_i=ea-eirp_d+(gra-grb)\n", + "\n", + "\n", + "#Result\n", + "print(\"carrier-to-interference ratio at the satellite due to\\n inteference caused by Eart station B is, (C/I) = %.0f dB \"%c_by_i)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "carrier-to-interference ratio at the satellite due to\n", + " inteference caused by Eart station B is, (C/I) = 43 dB \n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.11, page no-279" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "\n", + "#Variable Declaration\n", + "\n", + "\n", + "u=10000.0 # equivalent to 40dB\n", + "\n", + "#carrier sinal strength at eart station by downlink \n", + "d=3162.28 #equivalent to 35dB\n", + "\n", + "\n", + "#Calculation\n", + "x=1/((1/u)+(1/d))\n", + "\n", + "\n", + "#Result\n", + "print(\"Total carrier-to-interference ratio is %.2f = %.1f dB\"%(x,10*math.log10(x)))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total carrier-to-interference ratio is 2402.53 = 33.8 dB\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.12, Page no.280" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "theeta=5.0 #Angle form by slant ranges of two satellites\n", + "dA=42100.0*10**3 #Slant range of satellite A\n", + "dB=42000.0*10**3 #Slant range of satellite B\n", + "r=42164.0*10**3 #radius of geostationary orbit\n", + "\n", + "\n", + "#Calculation\n", + "beeta=((dA**2+dB**2-math.cos(theeta*math.pi/180)*2*dA*dB)/(2*r**2))\n", + "beeta=math.ceil(beeta*10**3)/10**3\n", + "beeta=(180/math.pi)*math.acos(1-beeta)\n", + "\n", + "#Result\n", + "print(\"Longitudinal separation between two satellites is %.3f\u00b0\"%beeta)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Longitudinal separation between two satellites is 5.126\u00b0\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.13, Page no.281" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "\n", + "#Variable Declaration\n", + "Ga=60.0 #Antenna Gain in dB\n", + "Ta= 60.0 #Noise teperature of Antenna\n", + "L1=1.12 #Feeder Loss equivalent to dB\n", + "T1=290.0 #Noise teperature of stage 1\n", + "G2=10**6 #Gain of stage 2 in dB\n", + "T2=140.0 #Noise teperature of stage 2\n", + "T3=10000.0 #Noise teperature of stage 3\n", + "G=Ga-0.5 #input of low noise amplifier\n", + "\n", + "\n", + "#Calculation\n", + "Ts=(Ta/L1)+(T1*(L1-1)/L1)+T2+(T3/G2)\n", + "Ts=math.floor(Ts*100)/100\n", + "x=G-10*math.log10(Ts)\n", + "\n", + "#Result\n", + "print(\"Tsi = %.2fK\\n\\n G/T(in dB/K)= %.0f dB/K\"%(Ts,x))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Tsi = 224.65K\n", + "\n", + " G/T(in dB/K)= 36 dB/K\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.14, Page no.282" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "Ga=60.0 #Amplifier Gain in dB\n", + "Ta= 60.0 #Noise teperature of Antenna\n", + "L1=1.12 #Feeder Loss equivalent to dB\n", + "T1=290.0 #Noise teperature of stage 1\n", + "G2=10**6 #Gain of stage 2 in dB\n", + "T2=140.0 #Noise teperature of stage 2\n", + "T3=10000.0 #Noise teperature of stage 3\n", + "G=Ga-0.5 #input of low noise amplifier\n", + "\n", + "\n", + "#Calculation\n", + "T=Ta+T1*(L1-1)+L1*(T2+(T3/G2))\n", + "x=G-10*math.log10(T)\n", + "\n", + "\n", + "#Result\n", + "print(\"T = %.1fK\\n\\n G/T = %.0f dB/k\"%(T,math.ceil(x)))\n", + "print(\"\\n\\n It is evident from the solutions of the problems 13 and 14\\n that G/T ratio is invarient regardless of the reference point in agreement \\n with a statement made earlier in the text.\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.15, Page no.286" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Variable Declaration\n", + "f=6.0*10**9 # uplink frequency\n", + "eirp=80.0 # Earth station EIRP in dBW\n", + "r=35780.0 # Earth station satellite distance\n", + "l=2.0 # attenuation due to atomospheric factors in dB\n", + "e=0.8 # satellite antenna's aperture efficiency\n", + "a=0.5 # satellite antenna's aperture area\n", + "T=190.0 # Satellite receiver's effective noise temperature \n", + "bw=20.0*10**6 # Satellite receiver's bandwidth\n", + "cn=25.0 # received carrier-to-noise ratioin dB\n", + "c=3.0*10**8 # speed of light\n", + "\n", + "#Calculation\n", + "k=1.38*10**-23\n", + "lamda=c/f\n", + "G=e*4*math.pi*a/lamda**2\n", + "G=math.ceil(G*100)/100\n", + "Gd=10*math.log10(G)\n", + "p=10*math.log10(k*T*bw)\n", + "pl=20*math.log10(4*math.pi*r*10**3/lamda)\n", + "rp=eirp-l-pl+Gd\n", + "rp=math.floor(rp*100)/100\n", + "rc=math.floor((rp-p)*100)/100\n", + "lm=rc-cn\n", + "\n", + "#Result\n", + "print(\"Satellite Antenna gain, G = %.2f = %.2f dB \\n Receivers Noise Power = %.1f dB\\n free-space path loss = %.2f dB \\n received power at satellite = %.2f dB \\n receiver carrier = %.2f is stronger than noise.\\n It is %.2f dB more than the required threshold value.\\n Hence, link margin = %.2f dB\"%(G,Gd,p,pl,rp,rc,lm,lm))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Satellite Antenna gain, G = 2010.62 = 33.03 dB \n", + " Receivers Noise Power = -132.8 dB\n", + " free-space path loss = 199.08 dB \n", + " received power at satellite = -88.05 dB \n", + " receiver carrier = 44.75 is stronger than noise.\n", + " It is 19.75 dB more than the required threshold value.\n", + " Hence, link margin = 19.75 dB\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] }
\ No newline at end of file diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch1.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch1.ipynb index 7b82a76b..5ac1363a 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch1.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch1.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:4e45f4199722574c1e72ad7420d88b009a90aed0de40180b69c61cfde130a1dd" + "signature": "sha256:1f4ff165c5b37e972fbde6114f5c4644c7b325a65e411fa21e1921b02d662bf7" }, "nbformat": 3, "nbformat_minor": 0, @@ -57,7 +57,6 @@ "input": [ "\n", "\n", - "# prints \"Hello, World!\":\n", "print \"Hel\" + \"lo, Wo\" + \"rld!\" \n", "\n" ], @@ -80,7 +79,6 @@ "input": [ "\n", "\n", - "# prints \"Hello, World!\":\n", "print \"Hello, W\" + 'o' + \"rld\" + '!' " ], "language": "python", @@ -102,7 +100,6 @@ "input": [ "\n", "\n", - "# prints \"The Millennium ends Dec 31 2000.\":\n", "print \"The Millennium ends Dec %d %d \" %(31,2000)" ], "language": "python", @@ -124,7 +121,6 @@ "input": [ "\n", "\n", - "# prints \"m = 44 and n = 77\":\n", "\n", "m = 44 # assigns the value 44 to the variable m\n", "print \"m = %d \" % m,\n", @@ -150,7 +146,6 @@ "input": [ "\n", "\n", - "# prints \"n = 44:\n", "n=44\n", "print \"n = %d\" % n" ], @@ -173,7 +168,6 @@ "input": [ "\n", "\n", - "# Python does not have semicolons so wont give any errors.\n", "n=44\n", "print \"n = %d\" % n " ], @@ -195,8 +189,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# prints \"m = ?? and n = 44\":\n", "m = 0 #In python we do not have declaration of variables, we just initialize it and use it.\n", "n=44\n", "print \"m = %d and n = %d\" %(m,n)" @@ -219,7 +211,6 @@ "collapsed": false, "input": [ "\n", - "# defines constants; has no output:\n", "BEEP = '\\b'\n", "MAXINT = 2147483647\n", "N = MAXINT/2\n", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch10.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch10.ipynb index febb60a4..20eeb516 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch10.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch10.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:bbd6687393c06a730c7f5060250758a1f9af1de5ce96291cc9b90cec582f1aa5" + "signature": "sha256:6ab29bd91e48ed72112d302e0e8b3ba6e41a906b6302b14581de985939de5731" }, "nbformat": 3, "nbformat_minor": 0, @@ -238,7 +238,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -303,7 +303,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -376,7 +376,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch11.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch11.ipynb index 34fb61dc..d65c28e3 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch11.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch11.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:bdd5f9e441ccb7e3a87f4d8c5492d0aa1d228caba299fc1b0c667abb12780a1e" + "signature": "sha256:e48eb1ccc0a3bcda7cfb3c8c85a4d3a8e98cd5fdd1c8b0533a2ba81289b5dcbf" }, "nbformat": 3, "nbformat_minor": 0, @@ -106,7 +106,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -175,7 +175,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -277,7 +277,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + "\n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -382,7 +382,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + "\n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -461,7 +461,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -533,7 +533,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -606,7 +606,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -669,7 +669,25 @@ ] } ], - "prompt_number": 7 + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 }, { "cell_type": "code", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch2.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch2.ipynb index 52984e73..b03e0beb 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch2.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch2.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:43f850ff4e8965af5c5db1b79b7b4f60c3104eca56084bd90dc829928ca10593" + "signature": "sha256:b7fd8e305f82250735b733aadfdbd451b8947aadb96283663ae0092c6c46c8ec" }, "nbformat": 3, "nbformat_minor": 0, @@ -13,7 +13,6 @@ "collapsed": false, "input": [ "\n", - "# prints the value of a boolean variable:\n", "flag=False\n", "print \"flag = %r\" % flag\n", "flag = True\n", @@ -39,7 +38,7 @@ "input": [ "\n", "\n", - "# prints the character and its internally stored\n", + "\n", "c='A'\n", "print \"c = \" + c + \", int(c) = %d\" % ord(c)\n", "c='t'\n", @@ -71,7 +70,7 @@ "input": [ "\n", "import sys\n", - "# defines the constants SHRT_MIN, etc.\n", + "\n", "print 'maximum limit int : ',\n", "print sys.maxint\n", "print 'float info'\n", @@ -97,7 +96,6 @@ "collapsed": false, "input": [ "\n", - "# tests operators +, -, *, /, and %:\n", "m=54\n", "n=20\n", "print \"m = %d and n = %d\" %(m,n)\n", @@ -131,7 +129,7 @@ "input": [ "\n", "\n", - "# shows the difference between m++ and ++m:\n", + "\n", "m = 44\n", "m += 1\n", "n = m\n", @@ -160,8 +158,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# tests arithmetic assignment operators:\n", "n=22\n", "print \"n = %d\" % n\n", "n += 9 # adds 9 to n\n", @@ -198,7 +194,7 @@ "collapsed": false, "input": [ "\n", - "# tests the floating-point operators +, -, *, and /:\n", + "\n", "x=54.0\n", "y=20.0\n", "print \"x = %f and y = %f\" %(x,y)\n", @@ -230,7 +226,7 @@ "input": [ "\n", "import sys\n", - "# prints the storage sizes of the fundamental types:\n", + "\n", "print \"Number of bytes used:\\n\"\n", "\n", "print \" char: %d \" % sys.getsizeof('a')\n", @@ -262,7 +258,7 @@ "input": [ "\n", "import sys\n", - "# prints the storage sizes of the fundamental types:\n", + "\n", "fbits = 8*sys.getsizeof(float(123))\n", "\n", "# each byte contains 8 bits\n", @@ -287,7 +283,6 @@ "collapsed": false, "input": [ "\n", - "# casts a double value as an int:\n", "v = 1234.56789\n", "n = int(v);\n", "print \"v = %f, n = %d\" %(v,n)" @@ -310,7 +305,6 @@ "collapsed": false, "input": [ "\n", - "# prints promoted vales of 65 from char to double:\n", "c='A'\n", "print \"char c = \" + c\n", "k=c;\n", @@ -347,7 +341,6 @@ "collapsed": false, "input": [ "\n", - "# prints n until it overflows:\n", "n=1000\n", "print \"n = %d\" % n\n", "n *= 1000 # multiplies n by 1000\n", @@ -378,7 +371,6 @@ "collapsed": false, "input": [ "\n", - "# prints x until it overflows:\n", "x=1000.0\n", "print \"x = %f\" % x\n", "x *= x # multiplies n by itself; i.e., it squares x\n", @@ -412,7 +404,7 @@ "collapsed": false, "input": [ "\n", - "# illustrates round-off error::\n", + "\n", "x = 1000/3.0\n", "print \"x = %f\" %x # x = 1000/3\n", "y = x - 333.0\n", @@ -448,7 +440,7 @@ "\n", "import math\n", "\n", - "# implements the quadratic formula\n", + "\n", "a = float(raw_input(\"Enter the coefficients of a quadratic equation:\\n a : \"))\n", "b = float(raw_input('b : '))\n", "c = float(raw_input('c : '))\n", @@ -521,8 +513,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# prints double values in scientific e-format:\n", "x = float(raw_input(\"Enter float: \"))\n", "print \"Its reciprocal is: \",\n", "print 1/x " @@ -553,9 +543,7 @@ "collapsed": false, "input": [ "\n", - "# illustrates the scope of variables:\n", - "x = 11\n", - "# ERROR: this is not in the scope of x\n", + "x = 11 \n", "if True:\n", " x = 22 # OK: this is in the scope of x\n", " y = 33 # ERROR: this is not in the scope of y\n", @@ -574,7 +562,7 @@ "collapsed": false, "input": [ "\n", - "# this x is global\n", + "\n", "x = 11\n", "\n", "if True:\n", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch4.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch4.ipynb index 3c0afba2..64e8a763 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch4.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch4.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:f4ac3c8a3319ce3724a4367884b8f78c4152f64a5f7a4c1bcc6365ff895fb824" + "signature": "sha256:7bd00720050ed2a3657363e38f1e369105d66f3738b7a484e8db28626c8d8a4e" }, "nbformat": 3, "nbformat_minor": 0, @@ -911,7 +911,7 @@ "input": [ "\n", "import math\n", - "# defines pow() and log()\n", + "\n", "\n", "print \"Enter a positive integer: \"\n", "n = int(raw_input())\n", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb index e3de2713..f2c1f873 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:24e76f61ba45b924df39848fa855d4479d9e602e3e0935f26f67699be40eb3ff" + "signature": "sha256:08f28df467a1f0a941ab1bf603885e6d5dd4e19b6b21d49fd2ef0604a23f5de2" }, "nbformat": 3, "nbformat_minor": 0, @@ -14,8 +14,7 @@ "input": [ "\n", "import math\n", - "\n", - "# tests the sqrt() function:\n", + ":\n", "for i in range(0,6):\n", " print \"\\t %d \\t %f\" %(i,math.sqrt(i))" ], @@ -43,7 +42,7 @@ "input": [ "\n", "import math\n", - "# tests the identity sin 2x = 2 sin x cos x:\n", + "\n", "x = 0\n", "while x < 2:\n", " print \"%f \\t\\t %f \\t %f\" %(x,math.sin(2*x),2*math.sin(x)*math.cos(x))\n", @@ -80,7 +79,7 @@ "\n", "\n", "def cube(x):\n", - " # returns cube of x:\n", + " \n", " return x*x*x\n", "\n" ], @@ -96,10 +95,10 @@ "\n", "\n", "def cube(x):\n", - " # returns cube of x:\n", + " \n", " return x*x*x\n", "\n", - "# tests the cube() function:\n", + "\n", "n=1\n", "while (n != 0):\n", " n = int(raw_input())\n", @@ -177,7 +176,7 @@ "input": [ "\n", "def maximum(x,y):\n", - " # returns larger of the two given integers:\n", + " \n", " if (x < y):\n", " return y\n", " else:\n", @@ -250,7 +249,7 @@ "input": [ "\n", "def maximum(x,y):\n", - " # returns larger of the two given integers:\n", + " \n", " if (x < y):\n", " return y\n", " else:\n", @@ -323,7 +322,6 @@ "input": [ "\n", "\n", - "# returns larger of the two given integers:\n", "\n", "m = 1\n", "n = 1\n", @@ -476,7 +474,7 @@ "\n", "\n", "def perm(n,k):\n", - " # returns P(n,k), the number of permutations of k from n:\n", + " \n", " if (n < 0 or k < 0 or k > n):\n", " return 0\n", " return fact(n)/fact(n-k)\n", @@ -514,7 +512,7 @@ "\n", "\n", "def printDate(m,d,y):\n", - " # prints the given date in literal form:\n", + " \n", " if (m < 1 or m > 12 or d < 1 or d > 31 or y < 0):\n", " print \"Error: parameter out of range.\\n\"\n", " return\n", @@ -630,7 +628,7 @@ "def ispunct(s):\n", " return all(c in string.punctuation for c in s)\n", "def printCharCategory(c):\n", - " # prints the category to which the given character belongs:\n", + " \n", " print \"The character [\" + c + \"] is a \",\n", " if(c.isdigit()):\n", " print \"digit.\\n\"\n", @@ -934,7 +932,7 @@ "\n", "import math\n", "def isPrime(n):\n", - " # returns True if n is prime, False otherwise:\n", + "\n", " sqrtn = math.sqrt(n)\n", " if (n < 2):\n", " return False\n", @@ -974,7 +972,7 @@ "input": [ "\n", "def isLeapYear(y):\n", - " # returns true iff y is a leap year:\n", + " \n", " return (y % 4 == 0 and y % 100 != 0 or y % 400 == 0)\n", "\n", "# tests the isLeapYear() function:\n", @@ -1059,7 +1057,7 @@ "\n", "\n", "def age():\n", - " # prompts the user to input his/her age, and returns that value:\n", + " \n", " while (True):\n", " print \"How old are you: \"\n", " n = int(raw_input())\n", @@ -1148,7 +1146,7 @@ "\n", "\n", "def swap(x,y):\n", - " # exchanges the values of x and y:\n", + " \n", " x[0],y[0] = y[0],x[0]\n", "\n", "a = [22.2]\n", @@ -1181,7 +1179,6 @@ " x[0]= 88\n", " y[0] = 99\n", "\n", - "# tests the f() function:\n", "a = [22]\n", "b = [44]\n", "print \"a = %.2f , b = %.2f \" %(a[0],b[0])\n", @@ -1212,7 +1209,7 @@ "\n", "\n", "def computeCircle(r):\n", - " # returns the area and circumference of a circle with radius r:\n", + " \n", " PI = 3.141592653589793\n", " area = PI*r*r\n", " circumference = 2*PI*r\n", @@ -1296,10 +1293,10 @@ "input": [ "\n", "def cube(x):\n", - " # returns cube of x:\n", + " \n", " return x*x*x\n", "\n", - "# tests the cube() function:\n", + ":\n", "print cube(4)\n", "x = int(raw_input())\n", "y = cube(2*x-3)\n", @@ -1408,8 +1405,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# prints the quotient of two input integers:\n", "print \"Enter two integers: \"\n", "n = int(raw_input())\n", "d = int(raw_input())\n", @@ -1461,7 +1456,7 @@ "input": [ "\n", "def reciprocal(x):\n", - " #returns the reciprocal of x:\n", + " \n", " if (x == 0):\n", " import sys\n", " sys.exit(1); # terminate the program\n", @@ -1497,11 +1492,11 @@ "input": [ "\n", "def p(x,a0,a1=0,a2=0,a3=0):\n", - " # returns a0 + a1*x + a2*x^2 + a3*x^3:\n", + "\n", " return (a0 + (a1 + (a2 + a3*x)*x)*x)\n", "\n", "\n", - "# tests the p() function:\n", + "\n", "x = 2.0003\n", "print \"p(x,7) = %f\" % p(x,7)\n", "print \"p(x,7,6) = %f\" % p(x,7,6)\n", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch6.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch6.ipynb index 191b1c78..0ed8b9bb 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch6.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch6.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:002670bb2c70e6ed5cc1d52c3936c4a90e901b6c8d78abcf5af4402c27118a1a" + "signature": "sha256:d63f30088951026ca8431b2db000283f5d2b32b8fd4852f840cfd94c7913a4ff" }, "nbformat": 3, "nbformat_minor": 0, @@ -45,7 +45,7 @@ "\n", "SIZE=5 # defines the size N for 5 elements\n", "a = []\n", - "# declares the array's elements as type double\n", + "\n", "print \"Enter \" , SIZE , \" numbers:\\t\"\n", "for i in range(SIZE):\n", " a.append(float(raw_input()))\n", @@ -186,7 +186,7 @@ "import numpy\n", "SIZE = 4\n", "a = numpy.zeros(4)\n", - "# declares the array's elements as type float\n", + "\n", "for i in range(SIZE):\n", " print \"\\ta[\" , i , \"] = \" , a[i]\n" ], @@ -479,7 +479,7 @@ "input": [ "\n", "def sort(a,n):\n", - " # bubble sort:\n", + " \n", " n = len(a)\n", " for i in range(n):\n", " # bubble up max{a[0..n-i]}:\n", @@ -519,8 +519,7 @@ "\n", "\n", "def index(x,a,n):\n", - " # PRECONDITION: a[0] <= a[1] <= ... <= a[n-1];\n", - " # binary search:\n", + " \n", " lo=0\n", " hi=n-1\n", " while (lo <= hi):\n", @@ -559,7 +558,7 @@ "\n", "\n", "def isNondecreasing(a,n):\n", - " # returns true iff a[0] <= a[1] <= ... <= a[n-1]:\n", + " \n", " for i in range(1,n):\n", " if (a[i]<a[i-1]):\n", " return False\n", @@ -590,7 +589,7 @@ "\n", "\n", "def isNondecreasing(a,n):\n", - " # returns true iff a[0] <= a[1] <= ... <= a[n-1]:\n", + " \n", " for i in range(1,n):\n", " if (a[i]<a[i-1]):\n", " return False\n", diff --git a/Surveying_Volume_3/Chapter_1_.ipynb b/Surveying_Volume_3/Chapter_1_.ipynb index 863599de..da68e1c2 100644 --- a/Surveying_Volume_3/Chapter_1_.ipynb +++ b/Surveying_Volume_3/Chapter_1_.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:34f1fb57a7660b9339f74e6fbb3f9bfcb7a1b64529d9da2cc37598b495c31a85" + "signature": "sha256:4905c8953e99a0af987b7c0ce644a5ad7cb3e945c4ca11d9468aa082d89ca9a1" }, "nbformat": 3, "nbformat_minor": 0, @@ -1648,7 +1648,7 @@ "input": [ "\n", "\n", - "#part 1\n", + "\n", "#initialisation of variable\n", "from math import pi,tan,sqrt,sin,cos,acos,atan\n", "def deg_to_dms(deg):\n", diff --git a/Transport_Phenomena/ch1.ipynb b/Transport_Phenomena/ch1.ipynb index 70dd9d5b..b9a93390 100644 --- a/Transport_Phenomena/ch1.ipynb +++ b/Transport_Phenomena/ch1.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:6878a09d345c6e36356d1de04735bdf1caaedc539dfc6eb9c2d7616f776f15b1" + "signature": "sha256:ce6e9d0d17f0f2b259533af75fac21794edd07ab7eee18f5c3ded9c896867c58" }, "nbformat": 3, "nbformat_minor": 0, @@ -79,11 +79,6 @@ "\n", "from numpy import *\n", "\n", - "# the three unknowns are x,y,z\n", - "# the three equations are-\n", - "# x+y+z = 1500\n", - "# (1) 0.05*x+0.15*y+0.40*z = 1500*0.25\n", - "# (2) 0.95*x+0.00*y+0.452*z = 1500*0.50\n", "# Variables\n", "a = array([[1, 1, 1],[0.05, 0.15, 0.40],[0.95, 0 ,0.452]])\n", "d = array([[1500.],[1500.*0.25],[1500.*0.50]])\n", diff --git a/Transport_Phenomena/ch10.ipynb b/Transport_Phenomena/ch10.ipynb index 46cf9990..52d5c043 100644 --- a/Transport_Phenomena/ch10.ipynb +++ b/Transport_Phenomena/ch10.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:d6e9db7edbf67f47d9db227a91c9a3e69bd0ea385086a570b1e5ec45fa366eb2" + "signature": "sha256:7eb8614514dad908ca3ae3d51b35064678df2b9a8e0304fe51fa17e462cfc000" }, "nbformat": 3, "nbformat_minor": 0, @@ -573,7 +573,6 @@ "\n", "import math\n", "\n", - "# Note : all variables values are taken from 10.9\n", "# variables \n", "w1 = 4.74 #kg/sec\n", "w2 = 7.59 #kg/sec\n", |