summaryrefslogtreecommitdiff
path: root/Structured_Programing_with_C++_by_Kjell_Backman
diff options
context:
space:
mode:
authorkinitrupti2017-05-12 18:53:46 +0530
committerkinitrupti2017-05-12 18:53:46 +0530
commit6279fa19ac6e2a4087df2e6fe985430ecc2c2d5d (patch)
tree22789c9dbe468dae6697dcd12d8e97de4bcf94a2 /Structured_Programing_with_C++_by_Kjell_Backman
parentd36fc3b8f88cc3108ffff6151e376b619b9abb01 (diff)
downloadPython-Textbook-Companions-6279fa19ac6e2a4087df2e6fe985430ecc2c2d5d.tar.gz
Python-Textbook-Companions-6279fa19ac6e2a4087df2e6fe985430ecc2c2d5d.tar.bz2
Python-Textbook-Companions-6279fa19ac6e2a4087df2e6fe985430ecc2c2d5d.zip
Removed duplicates
Diffstat (limited to 'Structured_Programing_with_C++_by_Kjell_Backman')
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/Chapter1.ipynb104
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/Chapter2.ipynb288
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/Chapter3.ipynb540
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/Chapter4.ipynb563
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/Chapter5.ipynb745
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/Chapter6.ipynb549
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/Chapter7.ipynb478
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/Chapter8.ipynb352
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/Chapter9.ipynb274
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/README.txt10
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/screenshots/1.pngbin0 -> 52546 bytes
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/screenshots/2.pngbin0 -> 50577 bytes
-rwxr-xr-xStructured_Programing_with_C++_by_Kjell_Backman/screenshots/3.pngbin0 -> 75264 bytes
13 files changed, 3903 insertions, 0 deletions
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/Chapter1.ipynb b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter1.ipynb
new file mode 100755
index 00000000..4a8d6e2e
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter1.ipynb
@@ -0,0 +1,104 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:c86efa8d98a193b995064bd56ef312e9a7c9cee5247409d33d46defcf953f275"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 1 : Introduction to Programming"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1, Page No 21"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print \"Hello world\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Hello world\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.2, Page No 22"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "dblPrice = float(raw_input(\"Enter Price Per Unit : \"))\n",
+ "iNo = int(raw_input(\"Enter Quantity : \"))\n",
+ "dblTotal = dblPrice * iNo\n",
+ "print \"The Total Price Is : %d\" % dblTotal "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Price Per Unit : 100\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Quantity : 10\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Total Price Is : 1000\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/Chapter2.ipynb b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter2.ipynb
new file mode 100755
index 00000000..d373f52c
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter2.ipynb
@@ -0,0 +1,288 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:8f653af2e0b44c81d67d541bdc64870a18188d9d1a401e0b96b1b859a01ca59f"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapeter 2 : Variables"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.1, Page No 29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iNo = raw_input(\"Specify Quantity: \")\n",
+ "print iNo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Specify Quantity: 10\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "10\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.2, Page No 31"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iNo = raw_input(\"Specify Quantity: \")\n",
+ "print \"You entered\", iNo"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "specify quantity22\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "You entered 22\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.3, Page No 32"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iNo = raw_input(\"specify quantity: \")\n",
+ "dPrice = raw_input(\"Specify unit Price: \")\n",
+ "print \"You entered the quantity \", iNo , \" and the price \" , dPrice"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "specify quantity: 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Specify unit Price: 12.45\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "You entered the quantity 5 and the price 12.45\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.4, Page No 36"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "dTaxPerc = 25.0\n",
+ "iNo = int(raw_input(\"Specify Quantity: \"))\n",
+ "dUnitPr = float(raw_input(\"Specify Unit Price: \"))\n",
+ "dPriceExTax = dUnitPr * iNo\n",
+ "dTax = dPriceExTax * dTaxPerc / 100\n",
+ "dCustPrice = dPriceExTax + dTax\n",
+ "print \"INVOICE\"\n",
+ "print \"========\"\n",
+ "print \"Quantity: \", iNo\n",
+ "print \"Price per Unit: \", dUnitPr\n",
+ "print \"Total Price: \", dCustPrice\n",
+ "print \"Tax: \",dTax"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Specify Quantity: 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Specify Unit Price: 12.4\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "INVOICE\n",
+ "========\n",
+ "Quantity: 5\n",
+ "Price per Unit: 12.4\n",
+ "Total Price: 77.5\n",
+ "Tax: 15.5\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.5, Page No 38"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iNoOfSec = int(raw_input(\"Speicfy No. of Seconds: \"))\n",
+ "iNoOfMin = iNoOfSec / 60\n",
+ "iSecLeft = iNoOfSec % 60\n",
+ "iNoOfHours = iNoOfMin / 60\n",
+ "iMinLeft = iNoOfMin % 60\n",
+ "print \"Number of hours = \", iNoOfHours\n",
+ "print \"Number of Minutes = \", iNoOfMin\n",
+ "print \"Number of Seconds = \", iSecLeft"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Speicfy No. of Seconds: 10000\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number of hours = 2\n",
+ "Number of Minutes = 166\n",
+ "Number of Seconds = 40\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.6, Page No 41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import random\n",
+ "iNo = 5\n",
+ "iRoll1 = random.randint(0,100) % 6 + 1\n",
+ "iRoll2 = random.randint(0,100) % 6 + 1\n",
+ "iRoll3 = random.randint(0,100) % 6 + 1\n",
+ "iRoll4 = random.randint(0,100) % 6 + 1\n",
+ "iRoll5 = random.randint(0,100) % 6 + 1\n",
+ "dAverage = float(iRoll1 + iRoll2 + iRoll3 + iRoll4 + iRoll5) / iNo;\n",
+ "print \"Number of Rolls: \", iNo\n",
+ "print \"Average Score: \", dAverage"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number of Rolls: 5\n",
+ "Average Score: 3.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/Chapter3.ipynb b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter3.ipynb
new file mode 100755
index 00000000..bca740d6
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter3.ipynb
@@ -0,0 +1,540 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:16d6a5d7a0f2261d7c4bbdc27385a261d6311ef3eb7e569b90710460f45fff6c"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 3 : Selections and Loops"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.1, Page No 48"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "dLimit = 500\n",
+ "iNo = int(raw_input(\"Specify Quantity : \"))\n",
+ "dUnitPrice = float(raw_input(\"Specify Unit Price : \"))\n",
+ "dGross = iNo * dUnitPrice\n",
+ "if(dGross > dLimit):\n",
+ " dDisc = 10\n",
+ "else:\n",
+ " dDisc = 0;\n",
+ "dNet = (100 - dDisc) * dGross / 100\n",
+ "print \"Total Price : %d\" % dNet"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Specify Quantity : 100\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Specify Unit Price : 10\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Total Price : 900\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.2, Page No 54"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "dNo1 = int(raw_input(\"Enter Number 1 : \"))\n",
+ "dNo2 = int(raw_input(\"Enter Number 2 : \"))\n",
+ "\n",
+ "print \"1. Greatest\"\n",
+ "print \"2. Least\"\n",
+ "print \"3. Average\"\n",
+ "\n",
+ "iOpt = int(raw_input(\"Select : \"))\n",
+ "\n",
+ "if iOpt == 1:\n",
+ " if dNo1 > dNo2:\n",
+ " print dNo1\n",
+ " else:\n",
+ " print dNo2\n",
+ " print \" is the greatest\"\n",
+ "elif iOpt == 2:\n",
+ " if dNo1 < dNo2:\n",
+ " print dNo1\n",
+ " else:\n",
+ " print dNo2\n",
+ " print \" is the least\"\n",
+ "elif iOpt == 3:\n",
+ " print \"The average is : \" , (dNo1 + dNo2)/2\n",
+ "else:\n",
+ " print \"wrong Choice\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Number 1 : 10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Number 2 : 15\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1. Greatest\n",
+ "2. Least\n",
+ "3. Average\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Select : 1\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "15\n",
+ " is the greatest\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.3, Page No 58"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iLimit = int(raw_input(\"Enter limit : \"))\n",
+ "iSum = 0\n",
+ "for i in range(1,iLimit+1):\n",
+ " iSum = iSum + i\n",
+ "\n",
+ "print \"The Sum Is : \" , iSum"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Example 3.4, Page No 61"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print \"Calculation Of Product\"\n",
+ "\n",
+ "for i in range(1,37):\n",
+ " for j in range(1,37):\n",
+ " if (i * j) == 36:\n",
+ " print i , \" and \" , j"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Calculation Of Product\n",
+ "1 and 36\n",
+ "2 and 18\n",
+ "3 and 12\n",
+ "4 and 9\n",
+ "6 and 6\n",
+ "9 and 4\n",
+ "12 and 3\n",
+ "18 and 2\n",
+ "36 and 1\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.5, Page No 62"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import random\n",
+ "\n",
+ "iRoll = 0\n",
+ "iNoOfRolls = 0\n",
+ "\n",
+ "while iRoll != 6:\n",
+ " iRoll = random.randint(1,200) % 6 + 1\n",
+ " iNoOfRolls = iNoOfRolls + 1\n",
+ "\n",
+ "print iNoOfRolls"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "8\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.6, Page No 63"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Do while concept is not in python thats way the program is implemented using WHILE\n",
+ "import random\n",
+ "\n",
+ "iRoll = 0\n",
+ "iNoOfRolls = 0\n",
+ "\n",
+ "while iRoll != 6:\n",
+ " iRoll = random.randint(1,200) % 6 +1\n",
+ " iNoOfRolls = iNoOfRolls + 1\n",
+ "\n",
+ "print iNoOfRolls"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.7, Page No 64"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import random\n",
+ "\n",
+ "iCounter = 0\n",
+ "iRoll1 = random.randint(1,200) % 6 + 1\n",
+ "iRoll2 = random.randint(1,200) % 6 + 1\n",
+ " \n",
+ "\n",
+ "while iRoll1 != iRoll2:\n",
+ " iRoll1 = random.randint(1,200) % 6 + 1\n",
+ " iRoll2 = random.randint(1,200) % 6 + 1\n",
+ " iCounter = iCounter + 1\n",
+ "\n",
+ "print \"The rolls were = \" , iRoll1\n",
+ "print \"Number of attempts = \" , iCounter"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The rolls were = 4\n",
+ "Number of attempts = 2\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.8, Page No 64"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iSum = 0\n",
+ "i = 0\n",
+ "iNo = raw_input(\"Enter a number : \")\n",
+ "\n",
+ "while iNo.isdigit():\n",
+ " iSum = iSum + int(iNo)\n",
+ " i = i + 1\n",
+ " iNo = raw_input(\"Enter one more number : \")\n",
+ "\n",
+ "print \"Average = \" , (float)((iSum)/i)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter a number : 4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter one more number : 6\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter one more number : 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter one more number : c\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Average = 5.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.9, Page No 66"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import random\n",
+ "iNO = 0\n",
+ "for i in range(1,14):\n",
+ " iNo = random.randint(1,200) % 3\n",
+ " if iNo == 0:\n",
+ " print \"1\"\n",
+ " elif iNo == 1:\n",
+ " print \"X\"\n",
+ " elif iNO == 2:\n",
+ " print \"2\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "X\n",
+ "X\n",
+ "X\n",
+ "X\n",
+ "1\n",
+ "1\n",
+ "X\n",
+ "1\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.10, Page No 68"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iNo = 0\n",
+ "iRoot = 1\n",
+ "while iNo < 2 and iRoot <=100:\n",
+ " LP = iRoot * (iRoot - 6) * (iRoot + 8)\n",
+ " if LP == 0:\n",
+ " iNo = iNo + 1\n",
+ " print iRoot\n",
+ " iRoot = iRoot + 1"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.11, Page No 69"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "while 1 == 1:\n",
+ " dNo = int(raw_input(\"Enter a number : \"))\n",
+ " if dNo <= 0:\n",
+ " break\n",
+ " print \"The square root of the number is \",math.sqrt(dNo)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter a number : 100\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The square root of the number is 10.0\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter a number : 0\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/Chapter4.ipynb b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter4.ipynb
new file mode 100755
index 00000000..aff2c5eb
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter4.ipynb
@@ -0,0 +1,563 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:a27de4c3e22de467837d62cdd94a3b4f20a866984babfe11880e076feb1374ad"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 4 : Arrays"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.1, Page No 79"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Declarations\n",
+ "\n",
+ "iNoOfDays = 31\n",
+ "dSum = 0\n",
+ "dblTempApr=[[0 for col in range(31)] for row in range(31)]\n",
+ "\n",
+ "\n",
+ "#Entry and calculation\n",
+ "\n",
+ "for i in range(1,iNoOfDays):\n",
+ " dblTempApr[i] = raw_input(\"Temperature Day %d: \" % i)\n",
+ " dSum += dblTempApr[i]\n",
+ "\n",
+ "dAvg = dSum / iNoOfDays\n",
+ "\n",
+ "#Printout\n",
+ "\n",
+ "print \"Average temperature: %f\" % dAvg\n",
+ "print \"Temperatures exceeding average: \"\n",
+ "\n",
+ "for i in range(1,iNoOfDays):\n",
+ " if (dblTempApr[i] > dAvg):\n",
+ " print \"Day no.: %d\" % i,\n",
+ " print \" temp: %d\" % dblTempApr[i]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 1: 32\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 2: 33\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 3: 35\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 4: 36\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 5: 34\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 6: 32\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 7: 31\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 8: 29\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 9: 28\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 10: 27\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 11: 25\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 12: 26\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 13: 35\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 14: 36\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 15: 35\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 16: 50\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 17: 40\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 18: 42\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 19: 44\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 20: 43\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 21: 41\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 22: 38\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 23: 37\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 24: 3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 25: 36\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 26: 35\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 27: 45\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 28: 32\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 29: 21\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Temperature Day 30: 15\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Average temperature: 32.000000\n",
+ "Temperatures exceeding average: \n",
+ "Day no.: 2 temp: 33\n",
+ "Day no.: 3 temp: 35\n",
+ "Day no.: 4 temp: 36\n",
+ "Day no.: 5 temp: 34\n",
+ "Day no.: 13 temp: 35\n",
+ "Day no.: 14 temp: 36\n",
+ "Day no.: 15 temp: 35\n",
+ "Day no.: 16 temp: 50\n",
+ "Day no.: 17 temp: 40\n",
+ "Day no.: 18 temp: 42\n",
+ "Day no.: 19 temp: 44\n",
+ "Day no.: 20 temp: 43\n",
+ "Day no.: 21 temp: 41\n",
+ "Day no.: 22 temp: 38\n",
+ "Day no.: 23 temp: 37\n",
+ "Day no.: 25 temp: 36\n",
+ "Day no.: 26 temp: 35\n",
+ "Day no.: 27 temp: 45\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.2, Page No 83"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Declaration\n",
+ "\n",
+ "iMaxNo = 100\n",
+ "dLimit = 5000\n",
+ "perc1 = 0.1\n",
+ "perc2 = 0.15\n",
+ "sales = [[0 for col in range(1)] for row in range(iMaxNo)]\n",
+ "\n",
+ "#Initialize array\n",
+ "\n",
+ "for i in range(0,iMaxNo):\n",
+ " sales[i] = 0\n",
+ "\n",
+ "#Enter Salesman info\n",
+ "nr=input(\"Enter Salesman no. : \")\n",
+ "dAmount=input(\"Enter sales amount: \")\n",
+ "\n",
+ "while (nr and dAmount):\n",
+ " if(nr<1 or nr>iMaxNo or dAmount<0):\n",
+ " print \"Input error\"\n",
+ " break;\n",
+ " else:\n",
+ " sales[nr-1]+= dAmount\n",
+ " nr=int(raw_input(\"Enter Salesman no. : \"))\n",
+ " dAmount=float(raw_input(\"Enter sales amount: \"))\n",
+ "\n",
+ "#Print summary\n",
+ "\n",
+ "print \"Number Amount Fee\"\n",
+ "print \"====== ====== ===\"\n",
+ "\n",
+ "for i in range(0,iMaxNo):\n",
+ " if (sales[i] > 0):\n",
+ " if(sales[i] <= dLimit):\n",
+ " dFee = perc1 * sales[i]\n",
+ " else:\n",
+ " dFee = perc1 * dLimit + perc2*(sales[i] - dLimit)\n",
+ " j=i;\n",
+ " j=j+1;\n",
+ " print \"%4d\" % j,\n",
+ " print \"%13d\" % sales[i],\n",
+ " print \"%10.0f\" % dFee"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Salesman no. : 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter sales amount: 1000\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Salesman no. : 2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter sales amount: 2000\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Salesman no. : 3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter sales amount: 3000\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Salesman no. : 4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter sales amount: 4000\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Salesman no. : 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter sales amount: 5000\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Salesman no. : 6\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter sales amount: 00\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number Amount Fee\n",
+ "====== ====== ===\n",
+ " 1 1000 100\n",
+ " 2 2000 200\n",
+ " 3 3000 300\n",
+ " 4 4000 400\n",
+ " 5 5000 500\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.3, Page No 92"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Declaration\n",
+ "l=0\n",
+ "r=30\n",
+ "iFound=0\n",
+ "# Array is in sorted form\n",
+ "iProdid= [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]\n",
+ "\n",
+ "iSrch = raw_input(\"Enter the searched product id: \")\n",
+ "\n",
+ "if(iSrch == iProdid[0]):\n",
+ " iPos = 0\n",
+ " iFound= 1\n",
+ "\n",
+ "if (iSrch == iProdid[30]):\n",
+ " iPos = 30\n",
+ " iFound = 1\n",
+ "\n",
+ "while not (iFound):\n",
+ " iMid = (int)(l + ((r-l)/2))\n",
+ " if(iSrch == iProdid[iMid]):\n",
+ " iFound = 1\n",
+ " iPos = iMid\n",
+ "\n",
+ " if(iSrch > iProdid[iMid]):\n",
+ " l=iMid\n",
+ " else:\n",
+ " r=iMid"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the searched product id: 15\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/Chapter5.ipynb b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter5.ipynb
new file mode 100755
index 00000000..bf5b3697
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter5.ipynb
@@ -0,0 +1,745 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:708386728a0ddd9fd0fa033f85042eb5d454abc98a33806d4ca4cc0500a010f0"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 5 : Strings"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.1, Page No. 97"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print \"Menu\"\n",
+ "print \"=====\"\n",
+ "print \"A. Order\"\n",
+ "print \"B. Invoice\"\n",
+ "print \"C. Warehouse\"\n",
+ "print \"D. Finance\"\n",
+ "cSel = raw_input(\"Select: \")\n",
+ "if cSel=='A' :\n",
+ " print \"You Selected Order\"\n",
+ "elif cSel=='B' :\n",
+ " print \"You Selected Invoice\"\n",
+ "elif cSel=='C':\n",
+ " print \"You Selected Warehouse\"\n",
+ "elif cSel=='D' :\n",
+ " print \"You Selected Finance\"\n",
+ "else :\n",
+ " print \"Erroneous Choice\"\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Menu\n",
+ "=====\n",
+ "A. Order\n",
+ "B. Invoice\n",
+ "C. Warehouse\n",
+ "D. Finance\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Select: A\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "You Selected Order\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.2, Page No.99"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import sys\n",
+ "cSal = 'A'\n",
+ "while cSal!='X':\n",
+ " print \"Menu\"\n",
+ " print \"=====\"\n",
+ " print \"A. Order\"\n",
+ " print \"B. Invoice\"\n",
+ " print \"C. Warehouse\"\n",
+ " print \"D. Finance\"\n",
+ " print \"X. Exit\"\n",
+ " cSel = raw_input(\"Select: \")\n",
+ "\n",
+ " \n",
+ " if cSel=='A' :\n",
+ " print \"You Selected Order\"\n",
+ " elif cSel=='B' :\n",
+ " print \"You Selected Invoice\"\n",
+ " elif cSel=='C':\n",
+ " print \"You Selected Warehouse\"\n",
+ " elif cSel=='D' :\n",
+ " print \"You Selected Finance\"\n",
+ " elif cSel=='X':\n",
+ " sys.exit()\n",
+ " else :\n",
+ " print \"Erroneous Choice\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Menu\n",
+ "=====\n",
+ "A. Order\n",
+ "B. Invoice\n",
+ "C. Warehouse\n",
+ "D. Finance\n",
+ "X. Exit\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Select: A\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "You Selected Order\n",
+ "Menu\n",
+ "=====\n",
+ "A. Order\n",
+ "B. Invoice\n",
+ "C. Warehouse\n",
+ "D. Finance\n",
+ "X. Exit\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Select: B\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "You Selected Invoice\n",
+ "Menu\n",
+ "=====\n",
+ "A. Order\n",
+ "B. Invoice\n",
+ "C. Warehouse\n",
+ "D. Finance\n",
+ "X. Exit\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Select: X\n"
+ ]
+ },
+ {
+ "ename": "SystemExit",
+ "evalue": "",
+ "output_type": "pyerr",
+ "traceback": [
+ "An exception has occurred, use %tb to see the full traceback.\n",
+ "\u001b[1;31mSystemExit\u001b[0m\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stderr",
+ "text": [
+ "To exit: use 'exit', 'quit', or Ctrl-D.\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.3, Page No. 102"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "x = 'X' \n",
+ "blank = ' '\n",
+ "for i in range(10, -1, -1):\n",
+ " for j in range(i):\n",
+ " print blank,\n",
+ " print x,\n",
+ " for j in range(10-i):\n",
+ " print x, x,\n",
+ " print ''\n",
+ "for i in range(2):\n",
+ " for j in range(10):\n",
+ " print blank,\n",
+ " print x"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " X \n",
+ " X X X \n",
+ " X X X X X \n",
+ " X X X X X X X \n",
+ " X X X X X X X X X \n",
+ " X X X X X X X X X X X \n",
+ " X X X X X X X X X X X X X \n",
+ " X X X X X X X X X X X X X X X \n",
+ " X X X X X X X X X X X X X X X X X \n",
+ " X X X X X X X X X X X X X X X X X X X \n",
+ "X X X X X X X X X X X X X X X X X X X X X \n",
+ " X\n",
+ " X\n"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.4, Page No. 105"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import sys\n",
+ "cName = raw_input(\"Enter your name: \")\n",
+ "print \"Your name is \" , cName\n",
+ "print \"Your name is \" , len(cName), \" Characters long\"\n",
+ "print \"Your entire string is \" , sys.getsizeof(cName), \" characters long\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter your name: John Smith\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Your name is John Smith\n",
+ "Your name is 10 Characters long\n",
+ "Your entire string is 31 characters long\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.5, Page No. 106"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "cName=range(30)\n",
+ "cName = raw_input(\"Enter your name in lower case: \")\n",
+ "iLen = len(cName)\n",
+ "for ltr in cName:\n",
+ " print ltr.lower(),\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter your name in lower case: ABCD\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a b c d\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.6, Page No. 107"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "cName = raw_input(\"Enter your name: \")\n",
+ "iLen = len(cName)\n",
+ "cInt = []\n",
+ "cInt.append(cName[0])\n",
+ "for i in range(1, iLen):\n",
+ " if cName[i] == ' ':\n",
+ " cInt.append(cName[i+1])\n",
+ "print \"Your Initials are \", ''.join(cInt)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter your name: Kjell Backman\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Your Initials are KB\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.7, Page No. 109"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "cName1 = raw_input(\"Enter a Name: \")\n",
+ "cName2 = raw_input(\"Enter another Name: \")\n",
+ "if cName1 > cName2 :\n",
+ " print cName1 , cName2\n",
+ "else :\n",
+ " print cName2 , cName1"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter a Name: abcd\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter another Name: abcx\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "abcx abcd\n"
+ ]
+ }
+ ],
+ "prompt_number": 33
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.8, Page No. 110"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print \"Enter 5 names: \"\n",
+ "names = []\n",
+ "for i in range(5):\n",
+ " names.append(raw_input(\"name \" + str(i+1) + \": \"))\n",
+ "names.sort()\n",
+ "for i in range(5):\n",
+ " print names[i]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter 5 names: \n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "name 1: hardik\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "name 2: Parth\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "name 3: Nikunj\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "name 4: Vaibhav\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "name 5: Chirag\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Chirag\n",
+ "Nikunj\n",
+ "Parth\n",
+ "Vaibhav\n",
+ "hardik\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.9, Page No.113"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "cName = raw_input(\"Enter Your Name: \")\n",
+ "for i in range(29):\n",
+ " if cName[i] == ' ':\n",
+ " break\n",
+ "cFirst=cName[0:i]\n",
+ "print cFirst\n",
+ "cSur=cName[i+1:]\n",
+ "print cSur\n",
+ "cSur=cSur+\" \"\n",
+ "cSur=cSur+cFirst\n",
+ "print cSur\n",
+ "cSur=cSur[::-1]\n",
+ "print cSur"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Your Name: John Smith\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "John\n",
+ "Smith\n",
+ "Smith John\n",
+ "nhoJ htimS\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.10, Page No.115"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "cEncrypt = []\n",
+ "cName = []\n",
+ "cName = raw_input(\"Enter Your Name: \")\n",
+ "iLen = len(cName)\n",
+ "for i in range(iLen):\n",
+ " asc=ord(cName[i])\n",
+ " asc=asc+1\n",
+ " cEncrypt.append(chr(asc))\n",
+ "print ''.join(cEncrypt)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Your Name: JohnSmith\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "KpioTnjui\n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.11, Page No. 116"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import random\n",
+ "iLen = random.randint(0,100)%3+5\n",
+ "cPw=[]\n",
+ "for i in range(iLen):\n",
+ " val=random.randint(0,122)%26+65\n",
+ " cPw.append(chr(val))\n",
+ "print ''.join(cPw)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "ZXZUOY\n"
+ ]
+ }
+ ],
+ "prompt_number": 37
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.12, Page No. 119"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "cText=[]\n",
+ "cEncrypt=[]\n",
+ "cTemp1=[]\n",
+ "cText=raw_input(\"\\nWrite a text in upper case: \")\n",
+ "iLen= len(cText)\n",
+ "for i in range(iLen):\n",
+ " print cText[i]\n",
+ " car=ord(cText[i])\n",
+ " cEncrypt.append(car)\n",
+ "print ''.join(str(cEncrypt))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Write a text in upper case: hellow\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "h\n",
+ "e\n",
+ "l\n",
+ "l\n",
+ "o\n",
+ "w\n",
+ "[104, 101, 108, 108, 111, 119]\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import random\n",
+ "cKey=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n",
+ "cKey=list(cKey)\n",
+ "cEncrypt=range(50)\n",
+ "for i in range(26):\n",
+ " j=random.randint(0,100)%26\n",
+ " cTemp=cKey[i]\n",
+ " cKey[i]=cKey[j]\n",
+ " cKey[j]=cTemp\n",
+ "cKey=\"\".join(map(str,cKey))\n",
+ "cText=raw_input(\"\\nWrite a text in upper case: \")\n",
+ "iLen= len(cText)\n",
+ "for i in range(iLen):\n",
+ " cEncrypt[i]=cKey[ord(cText[i])-65]\n",
+ "cEncrypt=cEncrypt[::iLen]\n",
+ "print \"\".join(map(str,cEncrypt))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Write a text in upper case: JOHNSMITH\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "R918273645\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/Chapter6.ipynb b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter6.ipynb
new file mode 100755
index 00000000..6ee5ccef
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter6.ipynb
@@ -0,0 +1,549 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:3541583e6368ad0fd94057f7e595031de565be72b75fadedd8abb1168ccd2728"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 6 : Functions"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.1, Page No 126"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def dAverage(x1,x2):\n",
+ " av = (x1+x2)/2\n",
+ " return av\n",
+ "\n",
+ "print \"Enter two numbers:\"\n",
+ "dNo1= float(raw_input(\"\"))\n",
+ "dNo2= float(raw_input(\"\"))\n",
+ "dAvg= dAverage(dNo1,dNo2)\n",
+ "print \"The average is: \",dAvg"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter two numbers:\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "30\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "20\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The average is: 25.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.2, Page No 127"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def min(x,y):\n",
+ " if (x<y):\n",
+ " return x\n",
+ " else:\n",
+ " return y\n",
+ " \n",
+ "print \"Enter Three integer: \"\n",
+ "a=int(raw_input(\"\"))\n",
+ "b=int(raw_input(\"\"))\n",
+ "c=int(raw_input(\"\"))\n",
+ "m=min(a,b)\n",
+ "m=min(m,c)\n",
+ "print m"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Three integer: \n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.3, Page No 129"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def min(x,y):\n",
+ " if(x<y):\n",
+ " return x\n",
+ " else:\n",
+ " return y\n",
+ "t=0\n",
+ "iNos=range(5)\n",
+ "for t in range(5):\n",
+ " print \"Enter integer no\",t+1,\":\"\n",
+ " iNos[t]=int(raw_input(\"\"))\n",
+ "\n",
+ "m=iNos[0]\n",
+ "\n",
+ "for t in range(5):\n",
+ " m=min(iNos[t],m)\n",
+ "\n",
+ "print m,\"is the least integer\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter integer no 1 :\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "10\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter integer no 2 :\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter integer no 3 :\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter integer no 4 :\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter integer no 5 :\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "7\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3 is the least integer\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.4, Page No 131"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def iLgth(s):\n",
+ " n=0\n",
+ " while(s[n] != '\\0'):\n",
+ " n=n+1\n",
+ " return n\n",
+ "\n",
+ "cWord=range(30)\n",
+ "cWord=raw_input(\"Enter a word:\")\n",
+ "cWord=cWord + '\\0' #by default string array don't appen NULL character hence, it is manually appended\n",
+ "iLen=iLgth(cWord)\n",
+ "print \"Length of the word is: \",iLen"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter a word:bhavin mehta\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Length of the word is: 12\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.5, Page No 134"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def dDiscount(iQty,dLinePrice):\n",
+ " if(dLinePrice>1000):\n",
+ " return 0.15\n",
+ " elif(dLinePrice>500 or iQty>10):\n",
+ " return 0.10\n",
+ " else:\n",
+ " return 0\n",
+ "\n",
+ "def dPrice(iNo,dUnitPrice):\n",
+ " dTax=0.25\n",
+ " dLinePr=iNo*dUnitPrice\n",
+ " dDiscPerc=dDiscount(iNo,dLinePr)\n",
+ " return dLinePr*(1-dDiscPerc)*(1+dTax)\n",
+ "\n",
+ "print \"Enter quantity and unit price: \"\n",
+ "iQuantity=int(raw_input(\"\"))\n",
+ "dUnitPrice=float(raw_input(\"\"))\n",
+ "\n",
+ "print \"To be paid\", dPrice(iQuantity,dUnitPrice)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter quantity and unit price: \n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "30\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "50\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "To be paid 1593.75\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.6, Page No 137"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def replace1(s,c,cnew):\n",
+ " n=0\n",
+ " s = list(s)\n",
+ " while(s[n]!='\\0'):\n",
+ " if(s[n]==c):\n",
+ " s[n]=cnew\n",
+ " n=n+1\n",
+ " print \"\".join(map(str,s))\n",
+ "a=\"C:/Mydocumnets/Sheets\\0\"\n",
+ "print a\n",
+ "replace1(a,'/','-')"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "C:/Mydocumnets/Sheets\u0000\n",
+ "C:-Mydocumnets-Sheets\u0000\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.7, Page No 139"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def word(s):\n",
+ " i=0\n",
+ " j=len(s)\n",
+ " while(i<j):\n",
+ " if((s[i]>='a' and s[i]<='z')or(s[i]>='A' and s[i]<='Z')):\n",
+ " i=i+1\n",
+ " else:\n",
+ " return 0;\n",
+ " return 1;\n",
+ "\n",
+ "str=range(100)\n",
+ "str=raw_input(\"Enter word: \")\n",
+ "while(str):\n",
+ " if(word(str)):\n",
+ " print \"A word\"\n",
+ " else:\n",
+ " print \"No word\"\n",
+ " str=raw_input(\"Enter word: \")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter word: john\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "A word\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter word: smith\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "A word\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter word: john smith\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "No word\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter word: \n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.8, Page No 143"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#import myfunc we have created this header file and its going to work as header file user has to make it\n",
+ "print \"To be paid: \" + str(dPrice(10,700))\n",
+ "\n",
+ "# Code for myfunc Header file is here\n",
+ "\n",
+ "\"\"\"\n",
+ "def underline(n):\n",
+ " for i in range(n):\n",
+ " print \"=\",\n",
+ "def dDiscount(iQty,dLinePrice):\n",
+ " if(dLinePrice > 1000):\n",
+ " return 0.15\n",
+ " elif(dLinePrice>500 or iQty>10):\n",
+ " return 0.10\n",
+ " else:\n",
+ " return 0\n",
+ "def dPrice(iNo,dUnitPrice):\n",
+ " dTax = 0.25\n",
+ " dLinePr = iNo * dUnitPrice\n",
+ " dDiscPerc = dDiscount(iNo,dLinePr)\n",
+ " return dLinePr * (1-dDiscPerc) * (1+dTax)\n",
+ "\"\"\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/Chapter7.ipynb b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter7.ipynb
new file mode 100755
index 00000000..c4850700
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter7.ipynb
@@ -0,0 +1,478 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:81ebacbcf46be2a85cdba0d8109c34324595901036a67c9025bbb5cab58aa894"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 7 : Files"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.1, Page No 157"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "outfile = open(\"prodfile1.txt\",\"w\")\n",
+ "cProd = raw_input(\"Enter product, (only Enter to exit:\")\n",
+ "while (len(cProd) > 0):\n",
+ " outfile.writelines(cProd)\n",
+ " outfile.writelines(\"\\n\")\n",
+ " cProd = raw_input(\"Enter product, (only Enter to exit:\")\n",
+ "outfile.close()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product, (only Enter to exit:wheel\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product, (only Enter to exit:handlebars\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product, (only Enter to exit:saddle\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product, (only Enter to exit:bike\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product, (only Enter to exit:moped\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product, (only Enter to exit:\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Examle 7.2 Page No 159"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "infile = open(\"prodfile1.txt\",\"r\")\n",
+ "while (1):\n",
+ " cProd = infile.readline()\n",
+ " if(cProd):\n",
+ " print cProd\n",
+ " else:\n",
+ " break\n",
+ "infile.close()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "wheel\n",
+ "\n",
+ "handlebars\n",
+ "\n",
+ "saddle\n",
+ "\n",
+ "bike\n",
+ "\n",
+ "moped\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.3, Page No 160"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "cProd = raw_input(\"Enter new product \")\n",
+ "outfile = open(\"prodfile.txt1\",\"a\")\n",
+ "outfile.writelines(cProd)\n",
+ "outfile.close() "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter new product Spoke\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.4, Page No 161"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iProdId = 1\n",
+ "outfile = open(\"prodfile.txt\",\"w\")\n",
+ "while (iProdId != 0):\n",
+ " iProdId = int(raw_input(\"Enter product id: \"))\n",
+ " dPrice = float(raw_input(\"...and price: \"))\n",
+ " if(iProdId > 0):\n",
+ " outfile.writelines(str(iProdId) + '\\n' + str(dPrice) + '\\n')\n",
+ "outfile.close()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product id: 2345\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "...and price: 245.5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product id: 4512\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "...and price: 450.2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product id: 3902\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "...and price: 320.7\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product id: 2478\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "...and price: 75.9\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product id: 0\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "...and price: 0\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.5, Page No 163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iFound = 0\n",
+ "infile = open(\"prodfile.txt\",\"r\")\n",
+ "iSrch = int(raw_input(\"Enter product id: \"))\n",
+ "while(1):\n",
+ " iProdId = infile.readline()\n",
+ " if(iProdId == \"\"):\n",
+ " break\n",
+ " iProdId = int(iProdId)\n",
+ " dPrice = float(infile.readline())\n",
+ " if(iProdId == iSrch):\n",
+ " print \"The price is:\" , dPrice\n",
+ " iFound = 1\n",
+ " break\n",
+ "if(not iFound):\n",
+ " print \"Product missing\"\n",
+ "infile.close()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter product id: 1234\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Product missing\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.6, Page No 166"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def sort(cList,n):\n",
+ " for v in range(0,n-1):\n",
+ " for h in range(v+1,n):\n",
+ " if(cList[h]<cList[v]):\n",
+ " temp = cList[v]\n",
+ " cList[v] = cList[h]\n",
+ " cList[h] = temp\n",
+ "i = 0\n",
+ "infile = open(\"prodfile1.txt\",\"r\")\n",
+ "cProd = infile.readlines()\n",
+ "infile.close()\n",
+ "while(i < len(cProd)):\n",
+ " i = i + 1\n",
+ "iNo = i\n",
+ "sort(cProd,iNo)\n",
+ "for j in range(0,iNo):\n",
+ " print cProd[j]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Bike\n",
+ "\n",
+ "Handlebars\n",
+ "\n",
+ "Moped\n",
+ "\n",
+ "Saddle\n",
+ "\n",
+ "Spoke\n",
+ "\n",
+ "Wheel\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.7, Page No 169"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import os\n",
+ "infile = open(\"prodfile.txt\",\"r\")\n",
+ "outfile = open(\"temp.txt\",\"w\")\n",
+ "iSrch = int(raw_input(\"Specify product id: \"))\n",
+ "while(1):\n",
+ " iProdId = infile.readline()\n",
+ " if(iProdId == \"\"):\n",
+ " break\n",
+ " iProdId = int(iProdId)\n",
+ " dPrice = float(infile.readline())\n",
+ " if(iProdId == iSrch):\n",
+ " dPrice = float(raw_input(\"Specify the new price: \"))\n",
+ " outfile.writelines(str(iProdId) + '\\n' + str(dPrice) + '\\n')\n",
+ "infile.close()\n",
+ "outfile.close()\n",
+ "os.remove(\"prodfile.txt\")\n",
+ "os.rename(\"temp.txt\",\"prodfile.txt\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Specify product id: 2345\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Specify the new price: 33.33\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.8, Page No 171"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import os\n",
+ "cNewName = raw_input(\"Specify new file name: \")\n",
+ "infile = open(\"prodfile.txt\",\"r\")\n",
+ "outfile = open(cNewName,\"w\")\n",
+ "if(not os.path.exists(cNewName)):\n",
+ " print \"The file could not be created\"\n",
+ "outfile.writelines(infile.readlines())\n",
+ "infile.close()\n",
+ "outfile.close()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Specify new file name: tryal.txt\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/Chapter8.ipynb b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter8.ipynb
new file mode 100755
index 00000000..0d779089
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter8.ipynb
@@ -0,0 +1,352 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:95ddab2248de9e7055a4dff19cd18b277d7ba7ab8ace5be6bff568b621024b03"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "\n",
+ "Chapter 8 : Pointers"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.1, Page No 179"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from ctypes import *\n",
+ "\n",
+ "iNo=c_int\n",
+ "pNo = id(iNo)\n",
+ "dPrice=dTotal=float\n",
+ "pPrice=id(dPrice)\n",
+ "pTotal=id(dTotal)\n",
+ "cName=range(20)\n",
+ "pName=id(cName)\n",
+ "pName = raw_input(\"Enter your name: \")\n",
+ "pNo = int(raw_input(\"Enter quantity: \"))\n",
+ "pPrice = float(raw_input(\"and price: \"))\n",
+ "pTotal = pNo * pPrice\n",
+ "print \"Dear \" + pName + \", your price is \" + str(pTotal) + \" kr.\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter your name: chirag\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter quantity: 10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "and price: 100\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Dear chirag, your price is 1000.0 kr.\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.2, Page No 182"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iSal=[14000,15000,16000,17000,18000,19000]\n",
+ "pSal = id(iSal)\n",
+ "dTax=[0.32,0.34,0.35,0.36,0.365,0.37]\n",
+ "pTax=id(dTax)\n",
+ "print \"Salary Tax\"\n",
+ "for i in range(6):\n",
+ " print str(iSal[i])+\" \",str(iSal[i]*dTax[i])\n",
+ " i=i+1"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Salary Tax\n",
+ "14000 4480.0\n",
+ "15000 5100.0\n",
+ "16000 5600.0\n",
+ "17000 6120.0\n",
+ "18000 6570.0\n",
+ "19000 7030.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.3, Page No 185"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def find(s):\n",
+ " for p in range(len(s)):\n",
+ " if(s[p]=='@'):\n",
+ " print \"It is an email address\"\n",
+ " p=p+1\n",
+ "\n",
+ "#cString=range(9)\n",
+ "pString=id(cString)\n",
+ "cString=raw_input(\"Enter A text: \")\n",
+ "find(cString)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter A text: hello@gmail.com\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "It is an email address\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.4, Page No 188"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iNumber=int(raw_input(\"How many product will be entered? \"))\n",
+ "\n",
+ "for i in range(iNumber):\n",
+ " pNo = id(iNumber)\n",
+ " print pNo\n",
+ " pNO = pNo + 1\n",
+ "pNo = pNo - iNumber\n",
+ "for i in range(iNumber):\n",
+ " print id(pNO)\n",
+ " pNo = pNO + 1\n",
+ "pNo = pNo - iNumber\n",
+ "del pNo "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "How many product will be entered? 5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3848360\n",
+ "3848360\n",
+ "3848360\n",
+ "3848360\n",
+ "3848360\n",
+ "51980880\n",
+ "51980880\n",
+ "51980880\n",
+ "51980880\n",
+ "51980880\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.5, Page No 189"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "iNo = 5\n",
+ "cName = range(iNo)\n",
+ "print \"Enter the name of 5 course mates: \"\n",
+ "for i in range(iNo):\n",
+ " print \"Mate no. \" ,i+1\n",
+ " temp = raw_input(\"Mate name: \")\n",
+ " cName.append(temp)\n",
+ "for j in range(iNo):\n",
+ " print cName[j]\n",
+ "for k in range(iNo):\n",
+ " del cName[k] "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the name of 5 course mates: \n",
+ "Mate no. 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mate name: a\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mate no. 2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mate name: b\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mate no. 3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mate name: c\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mate no. 4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mate name: d\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mate no. 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mate name: e\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "0\n",
+ "1\n",
+ "2\n",
+ "3\n",
+ "4\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/Chapter9.ipynb b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter9.ipynb
new file mode 100755
index 00000000..724e3c4e
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/Chapter9.ipynb
@@ -0,0 +1,274 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:3c26b0f763ca451c03b73133e1c2db791af8fb7ada7862c248f0876f5e8843fe"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 9 : Structures"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.1, Page No 194"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Prod:\n",
+ " def __init__(self, cName, iId, dPrice, iNo, cSupp):\n",
+ " self.cName = cName\n",
+ " self.iId = iId\n",
+ " self.dPrice = dPrice\n",
+ " self.iNo = iNo\n",
+ " self.cSupp = cSupp\n",
+ " def println(self):\n",
+ " print self.cName + \"\\t \",\n",
+ " print str(self.iId) + \"\\t \",\n",
+ " print str(self.dPrice) + \"\\t \",\n",
+ " print str(self.iNo) + \"\\t \",\n",
+ " print self.cSupp + \"\\t\\n\",\n",
+ "if __name__ == '__main__':\n",
+ " prodOne = Prod(\"Olive Oil\",1001,120.50,250,\"Frescati Oil S/A\")\n",
+ " print \"Enter information for product\"\n",
+ " cName = raw_input(\"Start with the product name: \")\n",
+ " iId = int(raw_input(\"The product id: \"))\n",
+ " dPrice = float(raw_input(\"The price: \"))\n",
+ " iNo = int(raw_input(\"How many items are there in stock: \"))\n",
+ " cSupp = raw_input(\"Who supplies the product: \")\n",
+ " prodTwo = Prod(cName,iId,dPrice,iNo,cSupp)\n",
+ " print \"Productname \\t Product id \\t Price \\t Quantity \\t Supplier\\n\"\n",
+ " prodOne.println()\n",
+ " prodTwo.println()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter information for product\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Start with the product name: Coconut Oil\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The product id: 1002\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The price: 120.50\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "How many items are there in stock: 230\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Who supplies the product: Frescati Oil S/A\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Productname \t Product id \t Price \t Quantity \t Supplier\n",
+ "\n",
+ "Olive Oil\t 1001\t 120.5\t 250\t Frescati Oil S/A\t\n",
+ "Coconut Oil\t 1002\t 120.5\t 230\t Frescati Oil S/A\t\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.2, Page No 200"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Prod:\n",
+ " def __init__(self, cName, iId, dPrice, iNo, cSupp):\n",
+ " self.cName = cName\n",
+ " self.iId = iId\n",
+ " self.dPrice = dPrice\n",
+ " self.iNo = iNo\n",
+ " self.cSupp = cSupp\n",
+ "def printOnScreen(prodOne1):\n",
+ " print prodOne1.cName + \"\\t \",\n",
+ " print str(prodOne1.iId) + \"\\t \",\n",
+ " print str(prodOne1.dPrice) + \"\\t \",\n",
+ " print str(prodOne1.iNo) + \"\\t \",\n",
+ " print prodOne1.cSupp + \"\\t\\n\",\n",
+ "\n",
+ "if __name__ == '__main__':\n",
+ " prodOne = Prod(\"Olive Oil\",1001,120.50,250,\"Frescati Oil S/A\")\n",
+ " printOnScreen(prodOne)\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Olive Oil\t 1001\t 120.5\t 250\t Frescati Oil S/A\t\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.3, Page No 202"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Prod:\n",
+ " def __init__(self, cName, iId, dPrice, iNo, cSupp):\n",
+ " self.cName = cName\n",
+ " self.iId = iId\n",
+ " self.dPrice = dPrice\n",
+ " self.iNo = iNo\n",
+ " self.cSupp = cSupp\n",
+ "def printOnScreen(p,n):\n",
+ " for i in range(n):\n",
+ " print p[i].cName + \"\\t \",\n",
+ " print str(p[i].iId) + \"\\t \",\n",
+ " print str(p[i].dPrice) + \"\\t \",\n",
+ " print str(p[i].iNo) + \"\\t \",\n",
+ " print p[i].cSupp + \"\\t\\n\",\n",
+ "if __name__ == '__main__':\n",
+ " sProds = []\n",
+ " sProds.append(Prod(\"Food Oil\",101,12.50,100,\"Felix Ltd\"))\n",
+ " sProds.append(Prod(\"Baby Oil\",102,23.75,25,\"Baby Prod\"))\n",
+ " sProds.append(Prod(\"Boiler Oil\",103,6100,123000,\"Shell\"))\n",
+ " printOnScreen(sProds,3)\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Food Oil\t 101\t 12.5\t 100\t Felix Ltd\t\n",
+ "Baby Oil\t 102\t 23.75\t 25\t Baby Prod\t\n",
+ "Boiler Oil\t 103\t 6100\t 123000\t Shell\t\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.4, Page No 205"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Prod:\n",
+ " def __init__(self, cName, iId, dPrice, iNo, cSupp):\n",
+ " self.cName = cName\n",
+ " self.iId = iId\n",
+ " self.dPrice = dPrice\n",
+ " self.iNo = iNo\n",
+ " self.cSupp = cSupp\n",
+ "def printOnScreen(p,n):\n",
+ " for i in range(n):\n",
+ " print p[i].cName + \"\\t \",\n",
+ " print str(p[i].iId) + \"\\t \",\n",
+ " print str(p[i].dPrice) + \"\\t \",\n",
+ " print str(p[i].iNo) + \"\\t \",\n",
+ " print p[i].cSupp + \"\\t\\n\",\n",
+ "if __name__ == '__main__':\n",
+ " sProds = []\n",
+ " sProds.append(Prod(\"Food Oil\",101,12.50,100,\"Felix Ltd\"))\n",
+ " sProds.append(Prod(\"Baby Oil\",102,23.75,25,\"Baby Prod\"))\n",
+ " sProds.append(Prod(\"Boiler Oil\",103,6100,123000,\"Shell\"))\n",
+ " pProds = id(sProds)\n",
+ " printOnScreen(sProds,3)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Food Oil\t 101\t 12.5\t 100\t Felix Ltd\t\n",
+ "Baby Oil\t 102\t 23.75\t 25\t Baby Prod\t\n",
+ "Boiler Oil\t 103\t 6100\t 123000\t Shell\t\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/README.txt b/Structured_Programing_with_C++_by_Kjell_Backman/README.txt
new file mode 100755
index 00000000..ac28cf27
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/README.txt
@@ -0,0 +1,10 @@
+Contributed By: Chirag Kotak
+Course: mca
+College/Institute/Organization: Shri Brahmanand Institute of Management and Computer Science
+Department/Designation: Computer Science
+Book Title: Structured Programing with C++
+Author: Kjell Backman
+Publisher: Ventus Publishing ApS
+Year of publication: 2012
+Isbn: 978-87-403-0099-4
+Edition: 1st Edition \ No newline at end of file
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/screenshots/1.png b/Structured_Programing_with_C++_by_Kjell_Backman/screenshots/1.png
new file mode 100755
index 00000000..7040411e
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/screenshots/1.png
Binary files differ
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/screenshots/2.png b/Structured_Programing_with_C++_by_Kjell_Backman/screenshots/2.png
new file mode 100755
index 00000000..667e163b
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/screenshots/2.png
Binary files differ
diff --git a/Structured_Programing_with_C++_by_Kjell_Backman/screenshots/3.png b/Structured_Programing_with_C++_by_Kjell_Backman/screenshots/3.png
new file mode 100755
index 00000000..1ab51d18
--- /dev/null
+++ b/Structured_Programing_with_C++_by_Kjell_Backman/screenshots/3.png
Binary files differ