summaryrefslogtreecommitdiff
path: root/C++_Programming_In_Easy_Steps
diff options
context:
space:
mode:
authorhardythe12015-01-30 12:30:05 +0530
committerhardythe12015-01-30 12:30:05 +0530
commit62aa228e2519ac7b7f1aef53001f2f2e988a6eb1 (patch)
tree7b632b21341f832c3d3b1352dabceaefb36c9a7b /C++_Programming_In_Easy_Steps
parent9add422993fb2649287260bc91d429a07d1810d5 (diff)
downloadPython-Textbook-Companions-62aa228e2519ac7b7f1aef53001f2f2e988a6eb1.tar.gz
Python-Textbook-Companions-62aa228e2519ac7b7f1aef53001f2f2e988a6eb1.tar.bz2
Python-Textbook-Companions-62aa228e2519ac7b7f1aef53001f2f2e988a6eb1.zip
added books
Diffstat (limited to 'C++_Programming_In_Easy_Steps')
-rwxr-xr-xC++_Programming_In_Easy_Steps/Chapter1.ipynb200
-rwxr-xr-xC++_Programming_In_Easy_Steps/Chapter10.ipynb137
-rwxr-xr-xC++_Programming_In_Easy_Steps/Chapter2.ipynb419
-rwxr-xr-xC++_Programming_In_Easy_Steps/Chapter3.ipynb352
-rwxr-xr-xC++_Programming_In_Easy_Steps/Chapter4.ipynb335
-rwxr-xr-xC++_Programming_In_Easy_Steps/Chapter5.ipynb381
-rwxr-xr-xC++_Programming_In_Easy_Steps/Chapter6.ipynb342
-rwxr-xr-xC++_Programming_In_Easy_Steps/Chapter7.ipynb429
-rwxr-xr-xC++_Programming_In_Easy_Steps/Chapter8.ipynb603
-rwxr-xr-xC++_Programming_In_Easy_Steps/Chapter9.ipynb316
-rwxr-xr-xC++_Programming_In_Easy_Steps/README.txt10
-rwxr-xr-xC++_Programming_In_Easy_Steps/screenshots/1.pngbin0 -> 40907 bytes
-rwxr-xr-xC++_Programming_In_Easy_Steps/screenshots/2.pngbin0 -> 16108 bytes
-rwxr-xr-xC++_Programming_In_Easy_Steps/screenshots/3.pngbin0 -> 13177 bytes
14 files changed, 3524 insertions, 0 deletions
diff --git a/C++_Programming_In_Easy_Steps/Chapter1.ipynb b/C++_Programming_In_Easy_Steps/Chapter1.ipynb
new file mode 100755
index 00000000..ba2c8125
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/Chapter1.ipynb
@@ -0,0 +1,200 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:accfa65c82343aeed5f184613989e8f303b6335bf19049dd322738d1012e1aff"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 1 : Getting Started"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1, Page No 12"
+ ]
+ },
+ {
+ "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 17"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "letter = 'A'\n",
+ "number = 100\n",
+ "decimal = 7.5\n",
+ "pi = 3.14159\n",
+ "isTrue = \"false\"\n",
+ "print \"char letter: \",letter\n",
+ "print \"int number: \",number\n",
+ "print \"float decimal: \",decimal\n",
+ "print \"double pi: \",pi\n",
+ "print \"bool isTrue: \",isTrue"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "char letter: A\n",
+ "int number: 100\n",
+ "float decimal: 7.5\n",
+ "double pi: 3.14159\n",
+ "bool isTrue: false\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.3, Page No 19"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "nums = [1.5,2.75,3.25]\n",
+ "name = ['m','i','k','e','\\0']\n",
+ "coords = [(1,2,3),(4,5,6)]\n",
+ "print \"nums[0]: \",nums[0]\n",
+ "print \"nums[1]: \",nums[1]\n",
+ "print \"nums[2]: \",nums[2]\n",
+ "print \"name[0]: \",name[0]\n",
+ "print \"Test stirng: \", \"\".join(name)\n",
+ "print \"coords[0][2]: \",coords[0][2]\n",
+ "print \"coords[1][2]: \",coords[1][2]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "nums[0]: 1.5\n",
+ "nums[1]: 2.75\n",
+ "nums[2]: 3.25\n",
+ "name[0]: m\n",
+ "Test stirng: mike\u0000\n",
+ "coords[0][2]: 3\n",
+ "coords[1][2]: 6\n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.4, Page No 21"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# ipython does not support vector array"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.5, Page No 23"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "PI = 3.1415926536\n",
+ "print \"6\\\" circle circumference: \" ,(PI * 6)\n",
+ "#ENUM IS NOT IN PYTHON SO DECLARED DIRECTLY\n",
+ "RED = 1\n",
+ "YELLOW = 2\n",
+ "GREEN = 3\n",
+ "BROWN = 4\n",
+ "BLUE = 5\n",
+ "PINK = 5\n",
+ "BLACK = 6\n",
+ "print \"I shot a red worth: \",RED\n",
+ "print \"Then a blue worth: \",BLUE\n",
+ "print \"Total scored: \",(RED+BLUE)\n",
+ "#typedef and enum is not in python so declared directly\n",
+ "neutral = \"NEGATIVE \"\n",
+ "live = \"POSITIVE\"\n",
+ "print \"Neutral wire: \", neutral\n",
+ "print \"Live wire: \", live"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6\" circle circumference: 18.8495559216\n",
+ "I shot a red worth: 1\n",
+ "Then a blue worth: 5\n",
+ "Total scored: 6\n",
+ "Neutral wire: NEGATIVE \n",
+ "Live wire: POSITIVE\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/C++_Programming_In_Easy_Steps/Chapter10.ipynb b/C++_Programming_In_Easy_Steps/Chapter10.ipynb
new file mode 100755
index 00000000..7e4467fb
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/Chapter10.ipynb
@@ -0,0 +1,137 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:f8a96fa9f559e8169a19de38e190920c7c87ad5a2ecae3d068468c11c8ecc55d"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 10 : Programming visually"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 10.1, Page No 171"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import random\n",
+ "nums = range(50)\n",
+ "for i in range(1,50):\n",
+ " nums[i] = i\n",
+ "for i in range(1,50):\n",
+ " j = random.randrange(1,49, 1)\n",
+ " k = nums[i]\n",
+ " nums[i] = nums[j]\n",
+ " nums[j] = k\n",
+ "print \"Your six lucky numbers are: \"\n",
+ "for i in range(1,7):\n",
+ " print nums[i],\" \",\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Your six lucky numbers are: \n",
+ "30 5 38 20 7 29 \n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 10.2, Page No 173"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "from Tkinter import *\n",
+ "from PIL import Image, ImageTk\n",
+ "import random\n",
+ "\n",
+ "def getBtnClick():\n",
+ " nums = range(50)\n",
+ " for i in range(1,50):\n",
+ " nums[i] = i\n",
+ " for i in range(1,50):\n",
+ " j = random.randrange(1,49, 1)\n",
+ " k = nums[i]\n",
+ " nums[i] = nums[j]\n",
+ " nums[j] = k\n",
+ " label1.config(text = nums[0])\n",
+ " label2.config(text = nums[1])\n",
+ " label3.config(text = nums[2])\n",
+ " label4.config(text = nums[3])\n",
+ " label5.config(text = nums[4])\n",
+ " label6.config(text = nums[5])\n",
+ " getBtn.config(state=DISABLED)\n",
+ " resetBtn.config(state=NORMAL)\n",
+ "def resetBtnClick():\n",
+ " label1.config(text = \"...\")\n",
+ " label2.config(text = \"...\")\n",
+ " label3.config(text = \"...\")\n",
+ " label4.config(text = \"...\")\n",
+ " label5.config(text = \"...\")\n",
+ " label6.config(text = \"...\")\n",
+ " resetBtn.config(state=DISABLED)\n",
+ " getBtn.config(state=NORMAL)\n",
+ "root = Tk()\n",
+ "root.title(\"Lotto number generator\")\n",
+ "image = Image.open(\"lotto.gif\")\n",
+ "photo = ImageTk.PhotoImage(image)\n",
+ "label0 = Label(image=photo)\n",
+ "label0.image = photo\n",
+ "label0.grid(row=0,column=0,rowspan=2)\n",
+ "\n",
+ "label1 = Label(text=\"...\")\n",
+ "label1.grid(row=0,column=1,padx=5,pady=5)\n",
+ "label2 = Label(text=\"...\")\n",
+ "label2.grid(row=0,column=2,padx=5,pady=5)\n",
+ "label3 = Label(text=\"...\")\n",
+ "label3.grid(row=0,column=3,padx=5,pady=5)\n",
+ "label4 = Label(text=\"...\")\n",
+ "label4.grid(row=0,column=4,padx=5,pady=5)\n",
+ "label5 = Label(text=\"...\")\n",
+ "label5.grid(row=0,column=5,padx=5,pady=5)\n",
+ "label6 = Label(text=\"...\")\n",
+ "label6.grid(row=0,column=6,padx=5,pady=5)\n",
+ "\n",
+ "getBtn = Button(text=\"Get My Lucky Numbers\",command=getBtnClick)\n",
+ "getBtn.grid(row=1,column=2,columnspan=2)\n",
+ "resetBtn = Button(text=\"Reset\",state=DISABLED,command=resetBtnClick)\n",
+ "resetBtn.grid(row=1,column=4,columnspan=3)\n",
+ "root.mainloop()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/C++_Programming_In_Easy_Steps/Chapter2.ipynb b/C++_Programming_In_Easy_Steps/Chapter2.ipynb
new file mode 100755
index 00000000..cd57ef03
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/Chapter2.ipynb
@@ -0,0 +1,419 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:1a5f4b4db0e022cc4962fee72ac059eb139d26a2030ea11b6f3c9bb4ceecd474"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 2 : Performing operations"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.1, Page No : 27"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a = 8\n",
+ "b = 4\n",
+ "print \"Addition result: \",(a+b)\n",
+ "print \"Substraction result: \",(a-b)\n",
+ "print \"Multiplication result: \",(a*b)\n",
+ "print \"Division result: \",(a/b)\n",
+ "print \"Modulus result: \",(a%b)\n",
+ "print \"Postfix increment: \",a+1\n",
+ "print \"Postfix result: \",a\n",
+ "print \"Prefix increment: \",b+1\n",
+ "print \"Prefix result: \",b"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Addition result: 12\n",
+ "Substraction result: 4\n",
+ "Multiplication result: 32\n",
+ "Division result: 2\n",
+ "Modulus result: 0\n",
+ "Postfix increment: 9\n",
+ "Postfix result: 8\n",
+ "Prefix increment: 5\n",
+ "Prefix result: 4\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.2, Page No : 29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a = 8\n",
+ "b = 4\n",
+ "print \"Assigned values: \"\n",
+ "print \"a = \",a\n",
+ "print \"b = \",b\n",
+ "print \"Add & assign: \"\n",
+ "a = a + b\n",
+ "print \"a += b (8 += 4 ) a = \",a\n",
+ "print \"Subtract & assign: \"\n",
+ "a = a - b\n",
+ "print \"a -= b (12 -= 4 ) a = \",a\n",
+ "print \"Multiply & assign: \"\n",
+ "a = a * b\n",
+ "print \"a *= b (8 *= 4 ) a = \",a\n",
+ "print \"Divide & assign: \"\n",
+ "a = a / b\n",
+ "print \"a /= b (32 /= 4 ) a = \",a\n",
+ "print \"Modulus & assign: \"\n",
+ "a = a % b\n",
+ "print \"a %= b (8 %= 4 ) a = \",a"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Assigned values: \n",
+ "a = 8\n",
+ "b = 4\n",
+ "Add & assign: \n",
+ "a += b (8 += 4 ) a = 12\n",
+ "Subtract & assign: \n",
+ "a -= b (12 -= 4 ) a = 8\n",
+ "Multiply & assign: \n",
+ "a *= b (8 *= 4 ) a = 32\n",
+ "Divide & assign: \n",
+ "a /= b (32 /= 4 ) a = 8\n",
+ "Modulus & assign: \n",
+ "a %= b (8 %= 4 ) a = 0\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.3, Page No 31"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "nil= 0\n",
+ "num= 0\n",
+ "max1 = 1\n",
+ "cap= 'A'\n",
+ "low= 'a'\n",
+ "print \"Equality comparisons: \"\n",
+ "print \"(0 == 0) \",(nil == num),\"(true)\"\n",
+ "print \"(A == a) \",(cap == low),\"(false)\"\n",
+ "print \"Inequality comparison: \"\n",
+ "print \"(0 != 1) \",(nil != max1),\"(true)\"\n",
+ "print \"Greater comparison: \"\n",
+ "print \"(0 > 1)\",(nil > max1),\"(false)\"\n",
+ "print \"Lesser comparison: \"\n",
+ "print \"(0 < 1) \",(nil < max1),\"(true)\"\n",
+ "print \"Greater or equal comparison: \"\n",
+ "print \"(0 >= 0) \",(nil >= num),\"(true)\"\n",
+ "print \"Lesser or equal comparison: \"\n",
+ "print \"(1 <= 0) \",(max1 <= num),\"(false)\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Equality comparisons: \n",
+ "(0 == 0) True (true)\n",
+ "(A == a) False (false)\n",
+ "Inequality comparison: \n",
+ "(0 != 1) True (true)\n",
+ "Greater comparison: \n",
+ "(0 > 1) False (false)\n",
+ "Lesser comparison: \n",
+ "(0 < 1) True (true)\n",
+ "Greater or equal comparison: \n",
+ "(0 >= 0) True (true)\n",
+ "Lesser or equal comparison: \n",
+ "(1 <= 0) False (false)\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.4, Page No : 33"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a = 1\n",
+ "b = 0\n",
+ "print \"AND logic: \"\n",
+ "print \"(a && a) \",(a & a),\"(true)\"\n",
+ "print \"(a && b) \",(a & b),\"(false)\"\n",
+ "print \"(b && b) \",(b & b),\"(false)\"\n",
+ "print \"OR logic: \"\n",
+ "print \"(a || a) \",( a | a ),\"(true)\"\n",
+ "print \"(a || b) \",( a | b ),\"(true)\"\n",
+ "print \"(b || b) \",( b | b ),\"(false)\"\n",
+ "print \"NOT logic: \"\n",
+ "print \"a = \",a,\"!a = \",not a\n",
+ "print \"b = \",b,\"!b = \",not b"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "AND logic: \n",
+ "(a && a) 1 (true)\n",
+ "(a && b) 0 (false)\n",
+ "(b && b) 0 (false)\n",
+ "OR logic: \n",
+ "(a || a) 1 (true)\n",
+ "(a || b) 1 (true)\n",
+ "(b || b) 0 (false)\n",
+ "NOT logic: \n",
+ "a = 1 !a = False\n",
+ "b = 0 !b = True\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Examle 2.5, Page No : 35"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a = 1\n",
+ "b = 2\n",
+ "print \"Variable a value is: \"\n",
+ "if a != 1:\n",
+ " print \"not one\"\n",
+ "else:\n",
+ " print \"one\"\n",
+ "if a % 2 != 0:\n",
+ " print \"odd\"\n",
+ "else:\n",
+ " print \"even\"\n",
+ "print \"Variable b value is: \"\n",
+ "if b != 1:\n",
+ " print \"not one\"\n",
+ "else:\n",
+ " print \"one\"\n",
+ "if b % 2 != 0:\n",
+ " print \"odd\"\n",
+ "else:\n",
+ " print \"even\"\n",
+ "if a > b:\n",
+ " max1 = a\n",
+ "else:\n",
+ " max1 = b\n",
+ "print \"Greater value is \",max1"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Variable a value is: \n",
+ "one\n",
+ "odd\n",
+ "Variable b value is: \n",
+ "not one\n",
+ "even\n",
+ "Greater value is 2\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.6, Page No 37"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# there are no few datatypes in ipython so i assigned manually to get idea about size\n",
+ "import sys\n",
+ "num = 1\n",
+ "nums = range(50)\n",
+ "number = 0\n",
+ "max1 = 100\n",
+ "pi = 3.14\n",
+ "decimal = 10.10\n",
+ "letter = 'a'\n",
+ "letters = \"hii\"\n",
+ "isTrue = \"true\"\n",
+ "print \"int size: \",sys.getsizeof(num)\n",
+ "print \"50 int size: \",sys.getsizeof(nums)\n",
+ "print \"short int size: \",sys.getsizeof(number)\n",
+ "print \"unsigned int size: \",sys.getsizeof(max1)\n",
+ "print \"double size: \",sys.getsizeof(pi)\n",
+ "print \"float size: \",sys.getsizeof(decimal)\n",
+ "print \"char size: \",sys.getsizeof(letter)\n",
+ "print \"50 char size: \",sys.getsizeof(letters)\n",
+ "print \"bool size: \",sys.getsizeof(isTrue)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " int size: 24\n",
+ "50 int size: 464\n",
+ "short int size: 24\n",
+ "unsigned int size: 24\n",
+ "double size: 24\n",
+ "float size: 24\n",
+ "char size: 34\n",
+ "50 char size: 36\n",
+ "bool size: 37\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.7, Page No 39"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "num = 1 + 4 * 3\n",
+ "print \"Default order: \",num\n",
+ "num = (1 + 4) * 3\n",
+ "print \"Forced order: \",num\n",
+ "num = 7 - 4 + 2\n",
+ "print \"Default direction: \",num\n",
+ "num = 7 - (4 + 2)\n",
+ "print \"Forced direction: \",num"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Default order: 13\n",
+ "Forced order: 15\n",
+ "Default direction: 5\n",
+ "Forced direction: 1\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2.8, Page No 41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "num= 7\n",
+ "factor= 2\n",
+ "letter= 'A'\n",
+ "result= 0.0;\n",
+ "print \"Integer division: \",(num/factor)\n",
+ "result = float(num) / factor\n",
+ "print \"Cast division float: \",result\n",
+ "num = ord(letter)\n",
+ "print \"Cast character int: \",num\n",
+ "letter = chr(70)\n",
+ "print \"Cast integer char: \",letter"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Integer division: 3\n",
+ "Cast division float: 3.5\n",
+ "Cast character int: 65\n",
+ "Cast integer char: F\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/C++_Programming_In_Easy_Steps/Chapter3.ipynb b/C++_Programming_In_Easy_Steps/Chapter3.ipynb
new file mode 100755
index 00000000..fa5bbe49
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/Chapter3.ipynb
@@ -0,0 +1,352 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:78ef4056dbbb5cf9345972f218d0d597af5ce86eb47594e9fba3eaa74e6511a9"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 3 : Making statements"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.1, Page No 45"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "num = 8\n",
+ "letter = 'A'\n",
+ "if num > 5:\n",
+ " print \"Number exceeds five\"\n",
+ "else: \n",
+ " \"Number is five or less\"\n",
+ "if letter == 'A':\n",
+ " print \"Letter is A\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number exceeds five\n",
+ "Letter is A\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.2, Page No 47"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "num = 3\n",
+ "if num == 1:\n",
+ " print num,\" : Monday\"\n",
+ "elif num == 2:\n",
+ " print num,\" : Tuesday\"\n",
+ "elif num == 3:\n",
+ " print num,\" : Wednesday\"\n",
+ "elif num == 4:\n",
+ " print num,\" : Thursday\"\n",
+ "elif num == 5:\n",
+ " print num,\" : Friday\"\n",
+ "else:\n",
+ " print \"Weekend day\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3 : Wednesday\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.3, Page No 48"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "for i in range(1,4):\n",
+ " print \"Loop iteration: \",i\n",
+ " for j in range(1,4):\n",
+ " print \" Inner loop iteration: \",j"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Loop iteration: 1\n",
+ " Inner loop iteration: 1\n",
+ " Inner loop iteration: 2\n",
+ " Inner loop iteration: 3\n",
+ "Loop iteration: 2\n",
+ " Inner loop iteration: 1\n",
+ " Inner loop iteration: 2\n",
+ " Inner loop iteration: 3\n",
+ "Loop iteration: 3\n",
+ " Inner loop iteration: 1\n",
+ " Inner loop iteration: 2\n",
+ " Inner loop iteration: 3\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.4, Page No 50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "vec = range(10)\n",
+ "i = 0\n",
+ "print \n",
+ "while i < len(vec):\n",
+ " i = i + 1\n",
+ " if i == 3:\n",
+ " print \"| Skipped\",\n",
+ " continue\n",
+ " if i == 8:\n",
+ " print \"Done\"\n",
+ " break\n",
+ " vec[i-1] = i\n",
+ " print \"|\",vec[i-1],"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "| 1 | 2 | Skipped | 4 | 5 | 6 | 7 Done\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.5, Page No 53"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def bodyTempC():\n",
+ " temperature = 37.0\n",
+ " return temperature\n",
+ "def bodyTempF():\n",
+ " temperature = 98.6\n",
+ " return temperature\n",
+ "print \"Centigrade: \",bodyTempC()\n",
+ "print \"Fahrenheit: \",bodyTempF()\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Centigrade: 37.0\n",
+ "Fahrenheit: 98.6\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.6, Page No 54"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def fToC(degreesF = 32.0):\n",
+ " degreesC = ((5.0/9.0) * (degreesF - 32.0))\n",
+ " return degreesC\n",
+ "fahrenheit = float(raw_input(\"Enter a Fahrenheit temperature:\\t\"))\n",
+ "centigrade = fToC(fahrenheit)\n",
+ "print fahrenheit,\"F is \",centigrade,\"C\"\n",
+ "print \"Freezing point: \",fToC(),\"C\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter a Fahrenheit temperature:\t98.6\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 98.6 F is 37.0 C\n",
+ "Freezing point: 0.0 C\n"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.7, Page No 56"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def computeArea(diameter):\n",
+ " radius = (diameter/2)\n",
+ " return (3.141593 * (radius * radius))\n",
+ "def computeArea(width,height):\n",
+ " return width * height\n",
+ "def computeArea(letter,width,height):\n",
+ " return ((width/2) * height)\n",
+ "num = float(raw_input(\"Enter dimension in feet: \"))\n",
+ "# python does not support overriding in this way\n",
+ "#area = computeArea(num)\n",
+ "#print \"Circle: Area = \",area,\" sq.ft.\"\n",
+ "#area= computeArea(num,num)\n",
+ "#print\"Square: Area = \",area,\" sq.ft.\"\n",
+ "area = computeArea('T',num,num)\n",
+ "print \"Triangle: Area = \",area,\" sq.ft.\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter dimension in feet: 4\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Triangle: Area = 8.0 sq.ft.\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3.8, Page No 58"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def computeFactorials(num,max1):\n",
+ " print \"Factorial of \",num,\":\",\n",
+ " print factorial(num)\n",
+ " num = num + 1\n",
+ " if num > max1:\n",
+ " return 0\n",
+ " else :\n",
+ " computeFactorials(num,max1)\n",
+ "def factorial(n):\n",
+ " if n == 1:\n",
+ " result = 1\n",
+ " else:\n",
+ " result = (factorial(n - 1) * n)\n",
+ " return result\n",
+ "computeFactorials( 1, 8) ;"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Factorial of 1 : 1\n",
+ "Factorial of 2 : 2\n",
+ "Factorial of 3 : 6\n",
+ "Factorial of 4 : 24\n",
+ "Factorial of 5 : 120\n",
+ "Factorial of 6 : 720\n",
+ "Factorial of 7 : 5040\n",
+ "Factorial of 8 : 40320\n"
+ ]
+ }
+ ],
+ "prompt_number": 28
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/C++_Programming_In_Easy_Steps/Chapter4.ipynb b/C++_Programming_In_Easy_Steps/Chapter4.ipynb
new file mode 100755
index 00000000..ae827529
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/Chapter4.ipynb
@@ -0,0 +1,335 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:b79ee2681573b5fe1113810718887e0801a441cdcbacd23dfe8fbd78765cba80"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 4 : Handling strings"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.1, Page No 63"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "text = \"9\"\n",
+ "term = \"9 \"\n",
+ "info = \"Toys\"\n",
+ "hue = ['R','e','d','\\0']\n",
+ "info = \" Balloons\"\n",
+ "color = \"\".join(hue)\n",
+ "text = text + term + color + info\n",
+ "print text"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "99 Red\u0000 Balloons\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.2, Page No 64"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "name = raw_input(\"Please enter your full name : \")\n",
+ "print \"Welcome \",name\n",
+ "name = raw_input(\"Please re-enter your full name : \")\n",
+ "print \"Thanks, \",name"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Please enter your full name : Mike McGrath\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Welcome Mike McGrath\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Please re-enter your full name : Mike McGrath\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Thanks, Mike McGrath\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.3, Page No 66"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "term = \"100\"\n",
+ "number = 100\n",
+ "stream = term\n",
+ "num = stream\n",
+ "num = number / 4\n",
+ "print \"Integer value: \",num\n",
+ "stream = \"\"\n",
+ "stream = number\n",
+ "text = stream\n",
+ "text = str(text) + \" Per Cent\"\n",
+ "print \"String value: \",text"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Integer value: 25\n",
+ "String value: 100 Per Cent\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.4, Page No 68"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#There is no such functions in python like size, capacity and empty "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.5, Page No 70"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "lang = \"C++\"\n",
+ "term = \"Programming\"\n",
+ "text = \"C++ Programming\"\n",
+ "print \"Concatinated: \",lang + term\n",
+ "print \"Original: \",lang\n",
+ "#print \"Appended: \",lang.append(term) there in no append method for string in python\n",
+ "print \"Original: \",lang\n",
+ "print \"Differ: \",(lang==term)\n",
+ "print \"Match: \",(lang==text)\n",
+ "# print \"Match: \",(lang.compare(text)) there in no compare method for string in python\n",
+ "# print \"Differ: \",(lang.compare(term)) there in no compare method for string in python\n",
+ "# print \"Lower ASCII: \",lang.compare(\"zzzzz\") there in no compare method for string in python"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Concatinated: C++Programming\n",
+ "Original: C++\n",
+ "Original: C++\n",
+ "Differ: False\n",
+ "Match: False\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.6, Page No 72"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "text = \"Always laugh when you can. It\\\u2019s cheap medicine.\"\n",
+ "front = text\n",
+ "print \"Front: \",front\n",
+ "front = text\n",
+ "print \"Front: \",front\n",
+ "back = text\n",
+ "print \"Back: \",back\n",
+ "back = front\n",
+ "print \"Front: \",front\n",
+ "print \"Back: \",back\n",
+ "#There is no option to assing specific length in python also no swap function"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Front: Always laugh when you can. It\\\u2019s cheap medicine.\n",
+ "Front: Always laugh when you can. It\\\u2019s cheap medicine.\n",
+ "Back: Always laugh when you can. It\\\u2019s cheap medicine.\n",
+ "Front: Always laugh when you can. It\\\u2019s cheap medicine.\n",
+ "Back: Always laugh when you can. It\\\u2019s cheap medicine.\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.7, Page No 74"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "text = \"I can resist anything but temptation.\"\n",
+ "num = text.find(\"resist\",0)\n",
+ "print \"Position: \",num\n",
+ "num= text.find(\"nonsuch\",0)\n",
+ "print \"Result: \",num\n",
+ "num= text.find(\"I\",0)\n",
+ "print \"First I\",num\n",
+ "num= text.find(\"i\",text.find(\"I\",0))\n",
+ "print \"First not I\",num\n",
+ "num= text.rfind(\"t\",0)\n",
+ "print \"Last t: \",num\n",
+ "num= text.rfind(\"t\",text.rfind(\"t\",0))\n",
+ "print \"Last not t: \",num"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Position: 6\n",
+ "Result: -1\n",
+ "First I 0\n",
+ "First not I 9\n",
+ "Last t: 32\n",
+ "Last not t: 32\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4.8, Page No 76"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "text = \"I do like the seaside\"\n",
+ "print \"Original: \",text\n",
+ "# text.insert(10,\"to be aside\") There is no insert method in python\n",
+ "print \"Inserted: \",text\n",
+ "# text.erase(2,3) There is no erase method in python\n",
+ "print \"Erased: \",text\n",
+ "text = text.replace(\"the seaside\",\"strolling by the sea\")\n",
+ "print \"Replaced: \",text\n",
+ "print \"Copied: \",text[10:19]\n",
+ "print \"Last character: \",text[len(text)-1]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Original: I do like the seaside\n",
+ "Inserted: I do like the seaside\n",
+ "Erased: I do like the seaside\n",
+ "Replaced: I do like strolling by the sea\n",
+ "Copied: strolling\n",
+ "Last character: a\n"
+ ]
+ }
+ ],
+ "prompt_number": 46
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/C++_Programming_In_Easy_Steps/Chapter5.ipynb b/C++_Programming_In_Easy_Steps/Chapter5.ipynb
new file mode 100755
index 00000000..5f544b56
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/Chapter5.ipynb
@@ -0,0 +1,381 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:be4a857e05d2149d20f6d26486c5784a7f1b2096e43de372a2b4b95639d8b93a"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 5 : Reading and writing files"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.1, Page No 81"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "poem = [\"\\n\\tI never saw a man who looked\"]\n",
+ "poem.append(\"\\n\\tWith such a wistful eye\")\n",
+ "poem.append(\"\\n\\tUpon that little tent of blue\")\n",
+ "poem.append(\"\\n\\tWhich prisoners call the sky\")\n",
+ "try:\n",
+ " writer = open(\"poem.txt\",\"w\")\n",
+ " if(not isinstance(writer,file)):\n",
+ " print \"Error opening file for output\"\n",
+ " writer.writelines(poem)\n",
+ " writer.close()\n",
+ "except IOError:\n",
+ " print \"Error opening file for output\"\n",
+ "\"\"\"\n",
+ "Out put Text File :- poem.txt\n",
+ "\n",
+ " I never saw a man who looked\n",
+ " With such a wistful eye\n",
+ " Upon that little tent of blue\n",
+ " Which prisoners call the sky\n",
+ " The Ballad of Reading Gaol\n",
+ " Oscar Wilde 1898\n",
+ " \n",
+ "\"\"\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.2, Page No 83"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "info = \"\\n\\tThe Ballad of Reading Gaol\"\n",
+ "info = info + \"\\n\\t\\t\\tOscar Wilde 1898\" #There is no append for string in python\n",
+ "try:\n",
+ " writer = open(\"poem.txt\",\"a\")\n",
+ " if(not isinstance(writer,file)):\n",
+ " print \"Error opening file for output\"\n",
+ " writer.writelines(info)\n",
+ " writer.close()\n",
+ "except IOError:\n",
+ " print \"Error opening file for output\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.3, Page No 84"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "try:\n",
+ " reader = open(\"poem.txt\",\"r\")\n",
+ " if(not isinstance(reader,file)):\n",
+ " print \"Error opening input file\"\n",
+ " i = 0\n",
+ " while(1):\n",
+ " c = reader.read(1)\n",
+ " if c == \"\":\n",
+ " break\n",
+ " else:\n",
+ " print c,\n",
+ " i= i + 1 \n",
+ " reader.close()\n",
+ " print \"\\nIterations: \",i\n",
+ "except IOError:\n",
+ " print \"Error opening input file\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\tI n e v e r s a w a m a n w h o l o o k e d \n",
+ "\tW i t h s u c h a w i s t f u l e y e \n",
+ "\tU p o n t h a t l i t t l e t e n t o f b l u e \n",
+ "\tW h i c h p r i s o n e r s c a l l t h e s k y \n",
+ "\tT h e B a l l a d o f R e a d i n g G a o l \n",
+ "\t\t\tO s c a r W i l d e 1 8 9 8 \n",
+ "Iterations: 164\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.4, Page No 86"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# this program gives output same as book program but logic is different because some of functions are not available in python\n",
+ "RANGE = 12\n",
+ "tab = range(RANGE)\n",
+ "i = 0\n",
+ "j = 1\n",
+ "t = \"\"\n",
+ "try:\n",
+ " reader = open(\"records.txt\",\"r\")\n",
+ " if(not isinstance(reader,file)):\n",
+ " print \"Error opening input file\"\n",
+ " while(1):\n",
+ " c = reader.read(1)\n",
+ " if c == \"\":\n",
+ " break\n",
+ " else:\n",
+ " t = t + c\n",
+ " if c == '\\t':\n",
+ " tab[i] = t\n",
+ " t = \"\"\n",
+ " i = i + 1\n",
+ " elif c == '\\n':\n",
+ " tab[i] = t\n",
+ " t = \"\"\n",
+ " i = i + 1\n",
+ " elif i == RANGE-1:\n",
+ " tab[i] = t\n",
+ " reader.close()\n",
+ " i= 0;\n",
+ " while i < RANGE:\n",
+ " print \"Record Number: \",j\n",
+ " j = j + 1\n",
+ " print \"Forename: \",tab[i]\n",
+ " i = i + 1\n",
+ " print \"Surname: \",tab[i]\n",
+ " i = i + 1\n",
+ " print \"Department: \",tab[i]\n",
+ " i = i + 1\n",
+ " print \"Telephone: \",tab[i]\n",
+ " i = i + 1\n",
+ "except IOError:\n",
+ " print \"Error opening input file\"\n",
+ "\n",
+ "\"\"\"\n",
+ " INPUT FILE :- records.txt\n",
+ " \n",
+ " John Smith Sales 555-1234\n",
+ " Mary Jones Wages 555-9876\n",
+ " Paul Harris Accts 555-4321\n",
+ " \n",
+ "\"\"\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Record Number: 1\n",
+ "Forename: John\t\n",
+ "Surname: Smith\t\n",
+ "Department: Sales\t\n",
+ "Telephone: 555-1234\n",
+ "\n",
+ "Record Number: 2\n",
+ "Forename: Mary\t\n",
+ "Surname: Jones\t\n",
+ "Department: Wages\t\n",
+ "Telephone: 555-9876\n",
+ "\n",
+ "Record Number: 3\n",
+ "Forename: Paul\t\n",
+ "Surname: Harris\t\n",
+ "Department: Accts\t\n",
+ "Telephone: 555-4321\n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.5, Page No 89"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "isTrue = 1\n",
+ "num = 255\n",
+ "for i in range(0,40):\n",
+ " print \".\",\n",
+ "print \"Output\"\n",
+ "print \"Pi: \",\"3.1415926536\"\n",
+ "print isTrue,\":\",bool(isTrue)\n",
+ "print num,\":\",\"{:01X}\".format(num)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Output\n",
+ "Pi: 3.1415926536\n",
+ "1 : True\n",
+ "255 : FF\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.6, Page No 91"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "try:\n",
+ " for number in range(1,21):\n",
+ " if number > 4:\n",
+ " raise Exception(number)\n",
+ " else:\n",
+ " print \"Number: \",number\n",
+ "except:\n",
+ " print \"Exception at: \",number"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number: 1\n",
+ "Number: 2\n",
+ "Number: 3\n",
+ "Number: 4\n",
+ "Exception at: 5\n"
+ ]
+ }
+ ],
+ "prompt_number": 20
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.7, Page No 92"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import sys\n",
+ "lang = \"C++\"\n",
+ "try:\n",
+ " lang.erase(4,6)\n",
+ "except:\n",
+ " print \"Exception\",sys.exc_info()[0]\n",
+ "# There is no support for erse method in python"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Exception <type 'exceptions.AttributeError'>\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5.8, Page No 94"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#there is no replace or resize method in python\n",
+ "import sys\n",
+ "lang = \"C++\"\n",
+ "num = 1000000000\n",
+ "try:\n",
+ " lang.replace(lang,\"C\",\"1\")\n",
+ " lang.resize(3*num)\n",
+ " reader = open(\"nonsuch.txt\",\"r\")\n",
+ " print \"Program continues...\"\n",
+ "except:\n",
+ " print sys.exc_info()[0]\n",
+ " print \"Program terminated.\"\n",
+ "#python dose not support much more exceptions"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "<type 'exceptions.TypeError'>\n",
+ "Program terminated.\n"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/C++_Programming_In_Easy_Steps/Chapter6.ipynb b/C++_Programming_In_Easy_Steps/Chapter6.ipynb
new file mode 100755
index 00000000..281e89b4
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/Chapter6.ipynb
@@ -0,0 +1,342 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:ebda2195f5f56b03f9c5aecb268e628cfb74a1a1fa1ea18ae277cc3f964d54bd"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 6: Pointing to data"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.1, Page No.98"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "num=100\n",
+ "sum=0.0123456789\n",
+ "text=\"C++ Fun\"\n",
+ "print \"Integer variable starts at\",hex(id(num))\n",
+ "print \"Double variable starts at\",hex(id(sum))\n",
+ "print \"String variable starts at\",hex(id(text))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Integer variable starts at 0x126eb04\n",
+ "Double variable starts at 0x279b490\n",
+ "String variable starts at 0x2b7a160\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.2, Page No.100"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "a=8\n",
+ "b=16\n",
+ "aPtr=id(a)\n",
+ "bPtr=id(b)\n",
+ "print \"Address of pointers...\"\n",
+ "print \"aPtr:\",hex(id(aPtr))\n",
+ "print \"bPtr:\",hex(id(bPtr))\n",
+ "print \"Values in pointers...\"\n",
+ "print \"aPtr:\",hex(aPtr)\n",
+ "print \"bPtr:\",hex(bPtr)\n",
+ "#As python does not support pointers values can't be displayed using * symbol"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Address of pointers...\n",
+ "aPtr: 0x2808ac8\n",
+ "bPtr: 0x2808b1c\n",
+ "Values in pointers...\n",
+ "aPtr: 0x126e794\n",
+ "bPtr: 0x126e734\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.3, Page No.102"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "nums={1,2,3,4,5,6,7,8,9,10}\n",
+ "ptr=id(nums)\n",
+ "#As python does not support concept of pointers we can not use pointer arithmetic to print numbers"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.4, Page No.104"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "num=5\n",
+ "def writeOutput(value):\n",
+ " print \"Current Value: \",value\n",
+ "def computeTriple(value):\n",
+ " global num\n",
+ " num=num*3\n",
+ "\n",
+ "\n",
+ "writeOutput(num)\n",
+ "num=num+15\n",
+ "writeOutput(num)\n",
+ "computeTriple(num)\n",
+ "writeOutput(num)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Current Value: 5\n",
+ "Current Value: 20\n",
+ "Current Value: 60\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.5, Page No.106"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "letters=['C','+','+',' ','F','u','n','\\0']\n",
+ "text=\"C++ Fun\"\n",
+ "term=\"Element\"\n",
+ "lang=\"C++\"\n",
+ "ap1=[\"Great \",\"Program \",\"Code \"]\n",
+ "ap2=[lang,\"is \",\"Fun\"]\n",
+ "ap3=[ap2[0],ap2[1],ap1[0]]\n",
+ "ap4=[ap1[2],ap2[1],ap2[2]]\n",
+ "print \"\".join(letters)\n",
+ "print text\n",
+ "for i in range(0,3):\n",
+ " print term,i,\" \",\n",
+ " print ap1[i],\" \",\n",
+ " print ap2[i],\" \",\n",
+ " print ap3[i],\" \",\n",
+ " print ap4[i],\" \""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "C++ Fun\u0000\n",
+ "C++ Fun\n",
+ "Element 0 Great C++ C++ Code \n",
+ "Element 1 Program is is is \n",
+ "Element 2 Code Fun Great Fun \n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.6, Page No.108"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "num=0\n",
+ "rNum=400\n",
+ "num=rNum\n",
+ "print \"Value direct\",num\n",
+ "print \"Value via reference \",rNum\n",
+ "\n",
+ "print \"Address direct\",hex(id(num))\n",
+ "print \"Address via reference\",hex(id(rNum))\n",
+ "\n",
+ "rNum=rNum*2\n",
+ "num=rNum\n",
+ "\n",
+ "print \"Value direct\",num\n",
+ "print \"Value via reference \",rNum\n",
+ "\n",
+ "#as python does not support pointers"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Value direct 400\n",
+ "Value via reference 400\n",
+ "Address direct 0x27cd294\n",
+ "Address via reference 0x27cd294\n",
+ "Value direct 800\n",
+ "Value via reference 800\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.7, Page No. 110"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def writeOutput(value):\n",
+ " print \"Current Value: \",value\n",
+ "\n",
+ "def computeTriple(value):\n",
+ " value=value*3\n",
+ " print \"Current Value: \",value\n",
+ " \n",
+ "num=5\n",
+ "ref=num\n",
+ "writeOutput(num)\n",
+ "num=num+15\n",
+ "writeOutput(num)\n",
+ "computeTriple(num)\n",
+ "\n",
+ "#as python does not support pointers I dont have used pointer in this program"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Current Value: 5\n",
+ "Current Value: 20\n",
+ "Current Value: 60\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6.8, Page No.113"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def add(a,b):\n",
+ " total=a+b\n",
+ " print \"total:\",total\n",
+ "\n",
+ "num=100\n",
+ "sum=500\n",
+ "rNum=num\n",
+ "ptr=num\n",
+ "print \"Reference:\",rNum\n",
+ "print \"Pointer:\",ptr\n",
+ "ptr=sum\n",
+ "print \"Pointer now:\",ptr\n",
+ "add(rNum,ptr)\n",
+ "\n",
+ "\n",
+ "#as python does not support pointers I dont have used pointer in this progaram"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Reference: 100\n",
+ "Pointer: 100\n",
+ "Pointer now: 500\n",
+ "total: 600\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/C++_Programming_In_Easy_Steps/Chapter7.ipynb b/C++_Programming_In_Easy_Steps/Chapter7.ipynb
new file mode 100755
index 00000000..21e4cb9a
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/Chapter7.ipynb
@@ -0,0 +1,429 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:1bf3a3c32b50a821205df977feb0399264ec0b05a84acfd47497b8eab54ae29b"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 7: Creating Classes and objects"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.1, Page No.118"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class dog:\n",
+ " def bark(self):\n",
+ " print \"WOOF!\"\n",
+ " \n",
+ " def setAge(self,age):\n",
+ " self.age=age\n",
+ " \n",
+ " def setWeight(self,weight):\n",
+ " self.weight=weight\n",
+ " \n",
+ " def setColor(self,color):\n",
+ " self.color=color\n",
+ " \n",
+ " def getAge(self):\n",
+ " return self.age\n",
+ " \n",
+ " def getWeight(self):\n",
+ " return self.weight\n",
+ " \n",
+ " def getColor(self):\n",
+ " return self.color\n",
+ " \n",
+ " \n",
+ "if __name__=='__main__':\n",
+ " fido=dog()\n",
+ " fido.setAge(3)\n",
+ " fido.setWeight(15)\n",
+ " fido.setColor(\"brown\")\n",
+ " \n",
+ " print \"Fido is a\",fido.getColor(),\" dog\"\n",
+ " print \"Fido is \",fido.getAge(),\" years old\"\n",
+ " print \"Fido Weighs \",fido.getWeight(),\" pounds\"\n",
+ " fido.bark()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Fido is a brown dog\n",
+ "Fido is 3 years old\n",
+ "Fido Weighs 15 pounds\n",
+ "WOOF!\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.2, Page No.120"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class dog:\n",
+ " def bark(self):\n",
+ " print \"WOOF!\"\n",
+ " \n",
+ " def setValues(self,age,weight,color):\n",
+ " self.age=age\n",
+ " self.weight=weight\n",
+ " self.color=color\n",
+ " \n",
+ " def getAge(self):\n",
+ " return self.age\n",
+ " \n",
+ " def getWeight(self):\n",
+ " return self.weight\n",
+ " \n",
+ " def getColor(self):\n",
+ " return self.color\n",
+ " \n",
+ " \n",
+ "if __name__=='__main__':\n",
+ " fido=dog()\n",
+ " fido.setValues(3,15,\"brown\")\n",
+ " poonch=dog()\n",
+ " poonch.setValues(4,18,\"gray\")\n",
+ " print \"Fido is a\",fido.getColor(),\" dog\"\n",
+ " print \"Fido is \",fido.getAge(),\" years old\"\n",
+ " print \"Fido Weighs \",fido.getWeight(),\" pounds\"\n",
+ " fido.bark()\n",
+ " \n",
+ " print \"Poonch is \",poonch.getAge(),\" years old \",poonch.getColor(),\" dog who weighs \",poonch.getWeight(),\" pounds\",poonch.bark()\n",
+ " \n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Fido is a brown dog\n",
+ "Fido is 3 years old\n",
+ "Fido Weighs 15 pounds\n",
+ "WOOF!\n",
+ "Poonch is 4 years old gray dog who weighs 18 pounds WOOF!\n",
+ "None\n"
+ ]
+ }
+ ],
+ "prompt_number": 36
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.3, Page No.122"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class dog:\n",
+ " def __init__(self,age,weight,color):\n",
+ " self.age=age\n",
+ " self.weight=weight\n",
+ " self.color=color\n",
+ " \n",
+ " def bark(self):\n",
+ " print \"WOOF!\"\n",
+ " \n",
+ " def getAge(self):\n",
+ " return self.age\n",
+ " \n",
+ " def getWeight(self):\n",
+ " return self.weight\n",
+ " \n",
+ " def getColor(self):\n",
+ " return self.color\n",
+ " \n",
+ " def __del__(self):\n",
+ " print \"Object destroyed\"\n",
+ " \n",
+ "if __name__=='__main__':\n",
+ " fido=dog(3,15,\"brown\")\n",
+ " poonch=dog(4,18,\"gray\")\n",
+ " \n",
+ " print \"Fido is a\",fido.getColor(),\" dog\"\n",
+ " print \"Fido is \",fido.getAge(),\" years old\"\n",
+ " print \"Fido Weighs \",fido.getWeight(),\" pounds\"\n",
+ " fido.bark()\n",
+ " \n",
+ " print \"Poonch is \",poonch.getAge(),\" years old \",poonch.getColor(),\" dog who weighs \",poonch.getWeight(),\" pounds\",poonch.bark()\n",
+ " \n",
+ " del fido\n",
+ " del poonch"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Fido is a brown dog\n",
+ "Fido is 3 years old\n",
+ "Fido Weighs 15 pounds\n",
+ "WOOF!\n",
+ "Poonch is 4 years old gray dog who weighs 18 pounds WOOF!\n",
+ "None\n",
+ "Object destroyed\n",
+ "Object destroyed\n"
+ ]
+ }
+ ],
+ "prompt_number": 37
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exmaple 7.4, Page No.124"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class dog:\n",
+ " def __init__(self,age=1,weight=2,color=\"black\"):\n",
+ " self.age=age\n",
+ " self.weight=weight\n",
+ " self.color=color \n",
+ " \n",
+ " def bark(self,noise):\n",
+ " print noise\n",
+ " \n",
+ " def getAge(self):\n",
+ " return self.age\n",
+ " \n",
+ " def getWeight(self):\n",
+ " return self.weight\n",
+ " \n",
+ " def getColor(self):\n",
+ " return self.color\n",
+ " \n",
+ " def __del__(self):\n",
+ " print \"Object destroyed\"\n",
+ " \n",
+ "if __name__=='__main__':\n",
+ " fido=dog(3,15,\"brown\")\n",
+ " poonch=dog(4,18,\"gray\")\n",
+ " rex=dog()\n",
+ " sammy=dog(2,6,\"white\")\n",
+ " \n",
+ " \n",
+ " print \"Fido is a\",fido.getColor(),\" dog\"\n",
+ " print \"Fido is \",fido.getAge(),\" years old\"\n",
+ " print \"Fido Weighs \",fido.getWeight(),\" pounds\"\n",
+ " fido.bark(\"WOOF!\")\n",
+ " \n",
+ " print \"Poonch is \",poonch.getAge(),\" years old \",poonch.getColor(),\" dog who weighs \",poonch.getWeight(),\" pounds\",poonch.bark(\"WOOF!\")\n",
+ " print \"Rex is \",rex.getAge(),\" years old \",rex.getColor(),\" dog who weighs \",rex.getWeight(),\" pounds\",rex.bark(\"GRRR!\")\n",
+ " print \"Sammy is \",sammy.getAge(),\" years old \",sammy.getColor(),\" dog who weighs \",sammy.getWeight(),\" pounds\",sammy.bark(\"BOWOW!\")\n",
+ " del fido\n",
+ " del poonch\n",
+ " del rex\n",
+ " del sammy"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Fido is a brown dog\n",
+ "Fido is 3 years old\n",
+ "Fido Weighs 15 pounds\n",
+ "WOOF!\n",
+ "Poonch is 4 years old gray dog who weighs 18 pounds WOOF!\n",
+ "None \n",
+ "Rex is 1 years old black dog who weighs 2 pounds GRRR!\n",
+ "None \n",
+ "Sammy is 2 years old white dog who weighs 6 pounds BOWOW!\n",
+ "None \n",
+ "Object destroyed\n",
+ "Object destroyed\n",
+ "Object destroyed\n",
+ "Object destroyed\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.5, Page No.126"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Polygon:\n",
+ " weight=0\n",
+ " height=0\n",
+ " def setValues(self,w,h):\n",
+ " self.weight=w\n",
+ " self.height=h\n",
+ "\n",
+ "class Rectangle(Polygon):\n",
+ " def area(self):\n",
+ " return self.weight*self.height\n",
+ "\n",
+ "class Triangle(Polygon):\n",
+ " def area(self):\n",
+ " return (self.weight*self.height)/2\n",
+ "\n",
+ "rect=Rectangle()\n",
+ "trgl=Triangle()\n",
+ "rect.setValues(4,5)\n",
+ "trgl.setValues(4,5)\n",
+ "print \"Rectangle Area:\",rect.area()\n",
+ "print \"Triangle Area:\",trgl.area()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Rectangle Area: 20\n",
+ "Triangle Area: 10\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7.6, Page No.128"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Parent:\n",
+ " def __init__(self):\n",
+ " print \"Default Parent Constructor Called\"\n",
+ " def __init__(self,a):\n",
+ " print \"Overloaded Parent Constructor Called\"\n",
+ "\n",
+ "class Daughter(Parent):\n",
+ " def __init__(self):\n",
+ " print \"Derived Daughter class default constructor called\"\n",
+ "\n",
+ "class Son(Parent):\n",
+ " def __init__(self,a):\n",
+ " Parent.__init__(self,a)\n",
+ " print \"Derived Son class overloaded constructor called\"\n",
+ "\n",
+ "emma=Daughter()\n",
+ "andrew=Son(0)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Derived Daughter class default constructor called\n",
+ "Overloaded Parent Constructor Called\n",
+ "Derived Son class overloaded constructor called\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example No.7.7, Page No. 130"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Man:\n",
+ " def Speak(self, msg=\"Hello\"):\n",
+ " print \" \",msg\n",
+ "\n",
+ "class Hombre(Man):\n",
+ " def Speak(self,msg):\n",
+ " print msg\n",
+ "henry=Man()\n",
+ "enrique=Hombre()\n",
+ "henry.Speak()\n",
+ "henry.Speak(\"It's a beautiful evening.\")\n",
+ "enrique.Speak(\"Hola!\")\n",
+ "enrique.Speak(\"Es una trade hermosa\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Hello\n",
+ " It's a beautiful evening.\n",
+ "Hola!\n",
+ "Es una trade hermosa\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/C++_Programming_In_Easy_Steps/Chapter8.ipynb b/C++_Programming_In_Easy_Steps/Chapter8.ipynb
new file mode 100755
index 00000000..2bb6672f
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/Chapter8.ipynb
@@ -0,0 +1,603 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:fa5fb390e0208b333276a0ed5185d5e56d34940c09a52bd389b2d0242ea600f2"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 8: Harnessing polymorphism"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.1, Page No.134"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Base:\n",
+ " def Identify(self,adr):\n",
+ " print \"Base Class called by \",hex(adr)\n",
+ "\n",
+ "class SubA(Base):\n",
+ " def __init__(self,adr):\n",
+ " Base.Identify(self,adr)\n",
+ "class SubB(Base):\n",
+ " def __init__(self,adr):\n",
+ " Base.Identify(self,adr)\n",
+ "ptrA=1\n",
+ "ptrB=SubA(id(ptrA))\n",
+ "ptrC=2\n",
+ "ptrc=SubB(id(ptrC))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Base Class called by 0x12fd8e0\n",
+ "Base Class called by 0x12fd8d4\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.2, Page No.136"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Parent:\n",
+ " def Common(self):\n",
+ " print \"I am part of this family\"\n",
+ " def identify(self):\n",
+ " print \"I am the parent\"\n",
+ "\n",
+ "class Child(Parent):\n",
+ " def identify(self):\n",
+ " print \"I am the child\"\n",
+ " \n",
+ "class Grandchild(Child):\n",
+ " def identify(self):\n",
+ " print \"I am the grandchild\"\n",
+ " def Relate(self):\n",
+ " print \"Grandchild has parent and grandparent\"\n",
+ "\n",
+ "son=Child()\n",
+ "grandson=Grandchild()\n",
+ "parent=Parent()\n",
+ "print parent.Common(),\" \",son.identify()\n",
+ "print parent.Common(),\" \",grandson.identify()\n",
+ "print parent.Common(),\" \",parent.identify()\n",
+ "print grandson.Relate()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "I am part of this family\n",
+ "None I am the child\n",
+ "None\n",
+ "I am part of this family\n",
+ "None I am the grandchild\n",
+ "None\n",
+ "I am part of this family\n",
+ "None I am the parent\n",
+ "None\n",
+ "Grandchild has parent and grandparent\n",
+ "None\n"
+ ]
+ }
+ ],
+ "prompt_number": 18
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.3, Page No.138"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Bird:\n",
+ " def Talk(self):\n",
+ " print \"A Bird talks...\"\n",
+ " def Fly(self):\n",
+ " print \"A Bird flies...\"\n",
+ "class Pigeon(Bird):\n",
+ " def Talk(self):\n",
+ " print \"Coo!Coo!\"\n",
+ " def Fly(self):\n",
+ " print \"A Pigeon flies away...\"\n",
+ "class Chicken(Bird):\n",
+ " def Talk(self):\n",
+ " print \"Cluk!Cluk!\"\n",
+ " def Fly(self):\n",
+ " print \"I'm just a chicken- I can't fly!\"\n",
+ "pPigeon=Pigeon()\n",
+ "pChicken=Chicken()\n",
+ "pBird=Bird()\n",
+ "print \"\",pPigeon.Talk()\n",
+ "print \"\",pPigeon.Fly()\n",
+ "print \"\",pChicken.Talk()\n",
+ "print \"\",pChicken.Fly()\n",
+ "print \"\",pBird.Talk()\n",
+ "print \"\",pBird.Fly()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Coo!Coo!\n",
+ "None\n",
+ " A Pigeon flies away...\n",
+ "None\n",
+ " Cluk!Cluk!\n",
+ "None\n",
+ " I'm just a chicken- I can't fly!\n",
+ "None\n",
+ " A Bird talks...\n",
+ "None\n",
+ " A Bird flies...\n",
+ "None\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.4, Page No. 140"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Bird:\n",
+ " def Talk(self):\n",
+ " return -1\n",
+ " def Fly(self):\n",
+ " return -1\n",
+ "class Pigeon(Bird):\n",
+ " def Talk(self):\n",
+ " print \"Coo!Coo!\"\n",
+ " def Fly(self):\n",
+ " print \"A Pigeon flies away...\"\n",
+ "class Chicken(Bird):\n",
+ " def Talk(self):\n",
+ " print \"Cluk!Cluk!\"\n",
+ " def Fly(self):\n",
+ " print \"I'm just a chicken- I can't fly!\"\n",
+ "pPegion=Pigeon()\n",
+ "pChicken=Chicken()\n",
+ "pPegion.Talk()\n",
+ "pChicken.Talk()\n",
+ "pBird=Bird()\n",
+ "data=pBird.Talk()\n",
+ "if data==-1:\n",
+ " print \"Error!-Program ended\"\n",
+ " exit()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Coo!Coo!\n",
+ "Cluk!Cluk!\n",
+ "Error!-Program ended\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.5, Page No.142"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Rect:\n",
+ " height=0\n",
+ " width=0\n",
+ " def __init__(self,initWidth,initHeight):\n",
+ " self.height=initHeight\n",
+ " self.width=initWidth\n",
+ " def getArea(self):\n",
+ " return self.height*self.width\n",
+ " def getEdge(self):\n",
+ " return ((2*self.height)+(2*self.width)) \n",
+ " def Draw(self):\n",
+ " for i in range(0,self.height):\n",
+ " for j in range(0,self.width):\n",
+ " print \"X\",\n",
+ " print \"\\n\"\n",
+ "\n",
+ "pQuad=Rect(7,3)\n",
+ "pSquare=Rect(5,5)\n",
+ "\n",
+ "pQuad.Draw()\n",
+ "print \"Area is:\",pQuad.getArea()\n",
+ "print \"Perimeter is:\",pQuad.getEdge()\n",
+ "\n",
+ "pSquare.Draw()\n",
+ "print \"Area is:\",pSquare.getArea()\n",
+ "print \"Perimeter is:\",pSquare.getEdge()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "X X X X X X X \n",
+ "\n",
+ "X X X X X X X \n",
+ "\n",
+ "X X X X X X X \n",
+ "\n",
+ "Area is: 21\n",
+ "Perimeter is: 20\n",
+ "X X X X X \n",
+ "\n",
+ "X X X X X \n",
+ "\n",
+ "X X X X X \n",
+ "\n",
+ "X X X X X \n",
+ "\n",
+ "X X X X X \n",
+ "\n",
+ "Area is: 25\n",
+ "Perimeter is: 20\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.6, Page No.144"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Boat:\n",
+ " length=0\n",
+ " def getLength(self):\n",
+ " return self.length\n",
+ "class Sailboat(Boat):\n",
+ " mast=0\n",
+ " def getMast(self):\n",
+ " return self.mast\n",
+ "class Laser(Sailboat):\n",
+ " def __init__(self):\n",
+ " self.mast=19\n",
+ " self.length=35\n",
+ " def Model(self):\n",
+ " print \"Laser Classic:\"\n",
+ " def Boom(self):\n",
+ " print \"Boom: 14ft\"\n",
+ "pLaser=Laser()\n",
+ "pLaser.Model()\n",
+ "print \"Length:\",pLaser.getLength(),\"ft\"\n",
+ "print \"Height:\",pLaser.getMast(),\"ft\"\n",
+ "pLaser.Boom()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Laser Classic:\n",
+ "Length: 35 ft\n",
+ "Height: 19 ft\n",
+ "Boom: 14ft\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8.7, Page No.147"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "class Calculator:\n",
+ " status=\"true\"\n",
+ " num1=0.0\n",
+ " num2=0.0\n",
+ " oper='+'\n",
+ " def __init__(self):\n",
+ " self.status=\"true\"\n",
+ " def launch(self):\n",
+ " print \"***SUM CALCULATOR***\"\n",
+ " print \"Enter a number, an operator (+,-,*,/), and another number\\nEnter Zero to exit\"\n",
+ " def readInput(self):\n",
+ " print \">\",\n",
+ " self.num1=float(raw_input())\n",
+ " if self.num1==0:\n",
+ " self.status=\"false\"\n",
+ " else:\n",
+ " self.oper=raw_input()\n",
+ " self.num2=float(raw_input())\n",
+ " def writeOutput(self):\n",
+ " if self.status==\"true\":\n",
+ " if self.oper=='+':\n",
+ " print self.num1+self.num2\n",
+ " elif self.oper=='-':\n",
+ " print self.num1-self.num2\n",
+ " elif self.oper=='*':\n",
+ " print self.num1*self.num2\n",
+ " elif self.oper=='/':\n",
+ " if self.num2!=0:\n",
+ " print self.num1/self.num2\n",
+ " else:\n",
+ " print \"Cannot divide by zero\"\n",
+ " def run(self):\n",
+ " return self.status\n",
+ " \n",
+ " \n",
+ " \n",
+ " \n",
+ "pCalc=Calculator()\n",
+ "pCalc.launch()\n",
+ "while (pCalc.run()==\"true\"):\n",
+ " pCalc.readInput()\n",
+ " pCalc.writeOutput()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " ***SUM CALCULATOR***\n",
+ "Enter a number, an operator (+,-,*,/), and another number\n",
+ "Enter Zero to exit\n",
+ ">"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "32\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "+\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "32\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 64.0\n",
+ ">"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5.25\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "-\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "8.75\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " -3.5\n",
+ ">"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "8\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "*\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 24.0\n",
+ ">"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "20\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "/\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " 4.0\n",
+ ">"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "20\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "/\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "0\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Cannot divide by zero\n",
+ ">"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "0\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/C++_Programming_In_Easy_Steps/Chapter9.ipynb b/C++_Programming_In_Easy_Steps/Chapter9.ipynb
new file mode 100755
index 00000000..18bdfd17
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/Chapter9.ipynb
@@ -0,0 +1,316 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:53d2aae81c824182838b074246429ee4c039bafa2ea2a0b5b38839beb8288df9"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 9: Processing macros"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.1, Page No.153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print \"This is a simple test program\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "This is a simple test program\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.2, Page No.154"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "BOOK=\"C++ Programming in easy steps\"\n",
+ "NUM=200\n",
+ "RULE=\"*****************************\"\n",
+ "print RULE\n",
+ "print BOOK\n",
+ "print RULE\n",
+ "print \"NUM is:\",NUM\n",
+ "print \"Double NUM:\",NUM*2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "*****************************\n",
+ "C++ Programming in easy steps\n",
+ "*****************************\n",
+ "NUM is: 200\n",
+ "Double NUM: 400\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.3, Page No.156"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "if not 'BOOK' in locals():\n",
+ " BOOK=\"C++ Programming in easy steps\"\n",
+ "\n",
+ "print BOOK,\n",
+ "if not 'AUTHOR' in locals():\n",
+ " AUTHOR=\"Mike McGrath\"\n",
+ "print \" by \",AUTHOR\n",
+ "if not 'BOOK' in locals():\n",
+ " BOOK=\"\"\n",
+ "if 'BOOK' in locals():\n",
+ " BOOK=\"Linux in easy steps\"\n",
+ "\n",
+ "print BOOK,\" by \",AUTHOR"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Linux in easy steps by Mike McGrath\n",
+ "Linux in easy steps by Mike McGrath\n"
+ ]
+ }
+ ],
+ "prompt_number": 26
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.4, Page No.159"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "import platform\n",
+ "plat=platform.system()\n",
+ "print plat,\" system\"\n",
+ "if plat==\"Windows\":\n",
+ " print \"Performing Windows-only tasks\"\n",
+ "else:\n",
+ " print \"Performing Linux-only tasks\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Windows system\n",
+ "Performing Windows-only tasks\n"
+ ]
+ }
+ ],
+ "prompt_number": 32
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.5, Page No.160"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def add(x,y):\n",
+ " return x+y\n",
+ "def triple(x):\n",
+ " return (add(x,add(x,x)))\n",
+ "print \"9 + 3 = \",add(9,3)\n",
+ "print \"9 x 3 = \",triple(9)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "9 + 3 = 12\n",
+ "9 x 3 = 27\n"
+ ]
+ }
+ ],
+ "prompt_number": 34
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.6, Page No.162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def SQUARE(n):\n",
+ " return n*n\n",
+ "def CUBE(n):\n",
+ " return n*n*n\n",
+ "num=5\n",
+ "print \"Macro SQUARE:\",SQUARE(num)\n",
+ "print \"inline square:\",SQUARE(num)\n",
+ "print \"Macro CUBE:\",CUBE(num)\n",
+ "print \"inline CUBE:\",CUBE(num)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Macro SQUARE: 25\n",
+ "inline square: 25\n",
+ "Macro CUBE: 125\n",
+ "inline CUBE: 125\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.7, Page No.164"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def LINEOUT(str):\n",
+ " print str\n",
+ "def GLUEOUT(a,b):\n",
+ " print a,\" \",b\n",
+ "longer=\"They carried a net \"\n",
+ "line=\"and their hearts \"\n",
+ "LINEOUT(\"In a bowl to sea went wise men three\")\n",
+ "LINEOUT(\"On a brilliant night in June\")\n",
+ "GLUEOUT(longer,line)\n",
+ "LINEOUT(\"On fishing up the moon.\")"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "In a bowl to sea went wise men three\n",
+ "On a brilliant night in June\n",
+ "They carried a net and their hearts \n",
+ "On fishing up the moon.\n"
+ ]
+ }
+ ],
+ "prompt_number": 36
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9.8, Page No.166"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "DEBUG=0\n",
+ "if DEBUG == 1:\n",
+ " def ASSERT(expr):\n",
+ " print expr, \"...\", num\n",
+ " if expr != True:\n",
+ " print \"Fails in file: \"# There is no concept of line in python\n",
+ " print \"at line\"# There is no concept of line in python\n",
+ " else:\n",
+ " print \"Succeeds\"\n",
+ "elif DEBUG == 0:\n",
+ " def ASSERT(expr):\n",
+ " print \"Number is \",num\n",
+ "num = 9\n",
+ "ASSERT(num < 10)\n",
+ "num = num + num\n",
+ "ASSERT(num < 10)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number is 9\n",
+ "Number is 18\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/C++_Programming_In_Easy_Steps/README.txt b/C++_Programming_In_Easy_Steps/README.txt
new file mode 100755
index 00000000..ae8d74aa
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/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: C++ Programming In Easy Steps
+Author: Mike McGrath
+Publisher: Easy Steps Limited Southfield Road .Southam Warwickshire CV47 0FB .United Kingdom
+Year of publication: 2011
+Isbn: 978-1-84078-432-9
+Edition: 4th edition \ No newline at end of file
diff --git a/C++_Programming_In_Easy_Steps/screenshots/1.png b/C++_Programming_In_Easy_Steps/screenshots/1.png
new file mode 100755
index 00000000..c1176161
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/screenshots/1.png
Binary files differ
diff --git a/C++_Programming_In_Easy_Steps/screenshots/2.png b/C++_Programming_In_Easy_Steps/screenshots/2.png
new file mode 100755
index 00000000..5ee82d29
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/screenshots/2.png
Binary files differ
diff --git a/C++_Programming_In_Easy_Steps/screenshots/3.png b/C++_Programming_In_Easy_Steps/screenshots/3.png
new file mode 100755
index 00000000..c1a54d3b
--- /dev/null
+++ b/C++_Programming_In_Easy_Steps/screenshots/3.png
Binary files differ