diff options
author | debashisdeb | 2014-06-20 15:42:42 +0530 |
---|---|---|
committer | debashisdeb | 2014-06-20 15:42:42 +0530 |
commit | 83c1bfceb1b681b4bb7253b47491be2d8b2014a1 (patch) | |
tree | f54eab21dd3d725d64a495fcd47c00d37abed004 /C++_Demystified:_A_Self-Teaching_Guide | |
parent | a78126bbe4443e9526a64df9d8245c4af8843044 (diff) | |
download | Python-Textbook-Companions-83c1bfceb1b681b4bb7253b47491be2d8b2014a1.tar.gz Python-Textbook-Companions-83c1bfceb1b681b4bb7253b47491be2d8b2014a1.tar.bz2 Python-Textbook-Companions-83c1bfceb1b681b4bb7253b47491be2d8b2014a1.zip |
removing problem statements
Diffstat (limited to 'C++_Demystified:_A_Self-Teaching_Guide')
14 files changed, 159 insertions, 564 deletions
diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter1.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter1.ipynb index b19bede4..48ad3225 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter1.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter1.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:e4a8e7d7f68c55157338101fb923c578a4287a391df7f630ea67b43d6c59bd53" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,9 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Simple Hello World !\n", - "\"\"\"\n", + "\n", "\n", "print \"Hello World!\"" ], diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter10.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter10.ipynb index dd6f3a0f..7fcd3612 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter10.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter10.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:ffbb5815913062b1375d894b2fe1e26db393d3f99c982f5934f82d0355e05d2e" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,10 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "defining an array\n", - "note: no need to specify size of an array in python, it exapands automatically.\n", - "\"\"\"\n", + "\n", "\n", "testScore = [] #array defined" ], @@ -51,12 +49,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "variable as size of array\n", - "note: this won't give an error as mentioned in book as it will take numTests as\n", - "an element of array instead of size of array, as there is no need of size of \n", - "array in python.\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter the number of test scores:\",\n", "numTests = int(raw_input())\n", @@ -102,11 +95,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "variable as size of array\n", - "note: numTests will be taken as an element of array instead of size.\n", - "Also, there in no constant in Python, this program will be same as previous one\n", - "\"\"\"\n", + "\n", "\n", "numTests = 3\n", "print \"Enter the number of test scores:\",\n", @@ -153,11 +142,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "variable as size of array\n", - "note: numTests will be taken as an element of array instead of size.\n", - "Also, there in no constant in Python, this program will be same as previous one\n", - "\"\"\"\n", + "\n", "\n", "numTests = 3\n", "print \"Enter the number of test scores:\",\n", @@ -205,10 +190,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "intializing character array\n", - "note: '\\0' will have different result in python than in c++ \n", - "\"\"\"\n", + "\n", "\n", "name = ['J', 'e', 'f', 'f', '\\0']\n", "print name" @@ -238,10 +220,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "intializing character array\n", - "note: output will be different than that in book.\n", - "\"\"\"\n", + "\n", "\n", "name = ['J', 'e', 'f', 'f']\n", "print name" @@ -271,9 +250,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "assigning & displaying array values\n", - "\"\"\"\n", + "\n", "\n", "testScore = []\n", "print \"Enter test score #1: \",\n", @@ -358,9 +335,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "using 3 separate variables instead of array in previous example\n", - "\"\"\"\n", + "\n", "\n", "\n", "print \"Enter test score #1: \",\n", @@ -445,9 +420,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "looping for array\n", - "\"\"\"\n", + "\n", "\n", "testScore = []\n", "for i in range(3):\n", @@ -529,9 +502,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "using constant for range of array\n", - "\"\"\"\n", + "\n", "\n", "MAX = 3\n", "\n", @@ -615,11 +586,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Common programming mistake for array\n", - "note: the problem mentioned in the textbook won't occur in python as we are not\n", - "specifying size of an array.\n", - "\"\"\"\n", + "\n", "\n", "MAX = 3\n", "\n", @@ -719,11 +686,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "input element by index in array\n", - "note: if the array is not initialized then this method won't work. append() may\n", - "be used instead.\n", - "\"\"\"\n", + "\n", "\n", "MAX = 3\n", "grades = [0,0,0]\n", @@ -802,9 +765,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "character array\n", - "\"\"\"\n", + "\n", "\n", "name = ['J','e','f','f']\n", "print \"Enter your name: \",\n", @@ -851,11 +812,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "cout Object with Numeric Arrays\n", - "note: here the list itself will be printed instead of base address(as mentioned\n", - "in textbook).\n", - "\"\"\"\n", "\n", "MAX = 3\n", "testScore = []\n", @@ -935,11 +891,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "cin with numeric array\n", - "note: there won't be any error in python as it is with the case of c++. It will\n", - "just take testScore as a normal variable.\n", - "\"\"\"\n", + "\n", "\n", "testScore = []\n", "testScore = raw_input()" @@ -970,11 +922,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "cin with character array\n", - "note: it will simply override the array and assign whatever value you enter to\n", - "the name variable unlike c++(as mentioned in c++)\n", - "\"\"\"\n", + "\n", "\n", "name = ['J','e','f','f']\n", "print \"Enter your name: \",\n", @@ -1021,9 +969,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "name as string\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter your name: \",\n", "name = raw_input()\n", @@ -1069,10 +1015,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "getline()\n", - "note: there is no getline() in python.\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter your name: \",\n", "name = raw_input()\n", @@ -1118,9 +1061,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "passing array as function argument\n", - "\"\"\"\n", + "\n", "\n", "MAX = 3\n", "\n", diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb index f1d28b76..28bea5a9 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter11.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:3856d250c0b05978b896337a2d03bfbc47b52567398ed488a9db68479c713e89" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,10 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "size of pointers\n", - "note: there is no concept of pointers in python\n", - "\"\"\"\n", + "\n", "\n", "import sys\n", "\n", @@ -69,10 +67,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "attempt to print the value of pointer.\n", - "note: there is no pointer in python, we will simply print out an integer value instead\n", - "\"\"\"\n", + "\n", "\n", "iPtr = 0\n", "print \"The value of iPtr is\", iPtr" @@ -102,9 +97,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Null pointers\n", - "\"\"\"\n", + "\n", "\n", "iPtr = None\n", "print \"The value of iPtr is \", iPtr" @@ -134,9 +127,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "address of pointers\n", - "\"\"\"\n", + "\n", "\n", "num = 5\n", "iPtr = id(num)\n", @@ -169,10 +160,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "dereferencing\n", - "output will deffer from that given in textbook\n", - "\"\"\"\n", + "\n", "\n", "num = 5\n", "iPtr = id(num)\n", @@ -209,10 +197,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Pointer as a Variable\n", - "note: output may differ from that given in textbook\n", - "\"\"\"\n", + "\n", "\n", "num1 = 5\n", "num2 = 14\n", @@ -253,11 +238,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "array name as a constant pointer\n", - "note: we cannot use * operator to point in python as there are no pointers\n", - "python\n", - "\"\"\"\n", + "\n", "\n", "testScore = [4, 7, 1]\n", "print \"The address of the array using testScore is \", testScore\n", @@ -293,10 +274,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Pointer Arithmetic\n", - "the adress values will be different\n", - "\"\"\"\n", + "\n", "\n", "MAX = 3\n", "\n", @@ -335,10 +313,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "previous program modified with a pointer to point to array\n", - "the adress values will be different\n", - "\"\"\"\n", + "\n", "\n", "MAX = 3\n", "\n", @@ -378,11 +353,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Incrementing a Pointer\n", - "the method given in textbook is not possible in python.\n", - "We will do it in different way\n", - "\"\"\"\n", + "\n", "\n", "MAX = 3\n", "\n", @@ -422,9 +393,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "comparing address\n", - "\"\"\"\n", + "\n", "import sys\n", "MAX = 3\n", "\n", @@ -489,10 +458,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "decrementing pointers\n", - "Note: not possible in python. Impletement in a different way\n", - "\"\"\"\n", + "\n", "import sys\n", "MAX = 3\n", "\n", @@ -536,9 +502,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "pointer as function\n", - "\"\"\"\n", + "\n", "\n", "MAX = 3\n", "\n", @@ -627,10 +591,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "pointer as function\n", - "the program remains same in python\n", - "\"\"\"\n", + "\n", "\n", "MAX = 3\n", "\n", @@ -719,9 +680,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Passing a Single Variable Using Pointer Notation\n", - "\"\"\"\n", + "\n", "\n", "def doubleIt(x):\n", " print \"The number to be doubled is \", x\n", @@ -776,12 +735,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "modify previous program so it passes the variable to be doubled by address instead of by\n", - "reference\n", "\n", - "note: in python it will remain same\n", - "\"\"\"\n", "\n", "def doubleIt(x):\n", " print \"The number to be doubled is \", x\n", @@ -836,9 +790,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Dynamic Memory Allocation\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter the number of test scores: \",\n", "numTests = int(raw_input())\n", @@ -937,9 +889,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Returning Pointers from Functions\n", - "\"\"\"\n", + "\n", "\n", "str = \"Jeff Kent\"\n", "print str" @@ -969,9 +919,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Returning a Pointer to a Local Variable\n", - "\"\"\"\n", "\n", "def setName():\n", " print \"Enter your name: \",\n", @@ -1021,9 +968,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Returning a Pointer to a Static Local Variable\n", - "\"\"\"\n", + "\n", "\n", "def setName():\n", " print \"Enter your name: \",\n", @@ -1073,9 +1018,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Returning a Pointer to a Dynamically Created Variable\n", - "\"\"\"\n", + "\n", "\n", "def setName():\n", " print \"Enter your name: \",\n", diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter12.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter12.ipynb index 20f1ab81..aad6446b 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter12.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter12.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "chapter12" + "name": "", + "signature": "sha256:7cb05a28e7ffaf35858d238ed32ee5850136dba10511258d20543dca08f1609c" }, "nbformat": 3, "nbformat_minor": 0, @@ -28,9 +29,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "The \"Press Any Key to Continue\" Problem\n", - "\"\"\"\n", + "\n", "\n", "ch = 'a'\n", "\n", @@ -98,10 +97,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "cin.get function example.\n", - "we will use raw_input\n", - "\"\"\"\n", "\n", "ch = 'a'\n", "\n", @@ -169,10 +164,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "cin.ignore function.\n", - "note: no such function in Python, using normal raw_input\n", - "\"\"\"\n", + "\n", "\n", "ch = 'a'\n", "\n", @@ -224,10 +216,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "ignoring \\n character\n", - "we will do it normally in Python as \\n is alread ignored.\n", - "\"\"\"\n", "\n", "ch = 'a'\n", "\n", @@ -295,10 +283,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Combining Use of cin, cin.get, and cin.getline\n", - "note: result differ from textbook\n", - "\"\"\"\n", + "\n", "\n", "name = []\n", "print \"Enter course number: \",\n", @@ -364,9 +349,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "cin.get, cin.getline contd.\n", - "\"\"\"\n", + "\n", "\n", "name = []\n", "print \"Enter course number: \",\n", @@ -432,10 +415,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Useful Character Functions\n", - "toupper\n", - "\"\"\"\n", + "\n", "\n", "ch = 'a'\n", "while(ch != 'Q'):\n", @@ -487,9 +467,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "string comparison\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter first string: \",\n", "str1 = raw_input()\n", @@ -557,9 +535,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "string to int\n", - "\"\"\"\n", + "\n", "\n", "import sys\n", "\n", diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter13.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter13.ipynb index 46b00b70..a7e400b9 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter13.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter13.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:60c23a8f50ffb51e0da71a6e8b36475b7941871a6f534003180327a651bb1c1c" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,10 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "open a file\n", - "note: it will give an error\n", - "\"\"\"\n", + "\n", "\n", "try:\n", " if(fp):\n", @@ -67,9 +65,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "open file write mode\n", - "\"\"\"\n", + "\n", "\n", "try:\n", " fp = open(\"students.dat\", \"w\")\n", @@ -105,9 +101,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "writing to file\n", - "\"\"\"\n", "\n", "fp = open(\"students.dat\", \"w\")\n", "print \"Writing to the file\"\n", @@ -178,9 +171,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "reading from file\n", - "\"\"\"\n", + "\n", "\n", "fp = open(\"students.dat\", \"w\")\n", "print \"Writing to the file\"\n", @@ -262,9 +253,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "reading from file using getline\n", - "\"\"\"\n", "\n", "fp = open(\"students.dat\", \"w\")\n", "print \"Writing to the file\"\n", @@ -346,9 +334,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "looping through file\n", - "\"\"\"\n", + "\n", "\n", "fp = open(\"students.dat\", \"w\")\n", "print \"Writing to the file\"\n", diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter14.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter14.ipynb index 57cde338..ff10cf77 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter14.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter14.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:016508922d0131c0ac159bf106009ef877ee5a7ded89017b639b2c0f28cf52bc" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,10 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "declaring structure\n", - "note: there is no concept of structure in python. We will use class instead\n", - "\"\"\"\n", + "\n", "\n", "class Person:\n", " name = \"\"\n", @@ -53,10 +51,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "declares a three-element Person array, assigns values to the member\n", - "variables of each element, and then outputs their values\n", - "\"\"\"\n", + "\n", "\n", "class Person:\n", " name = \"\"\n", @@ -199,10 +194,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "constructors & destructors\n", - "note: there are no destructors in Python\n", - "\"\"\"\n", + "\n", "\n", "class Person:\n", " name = \"\"\n", @@ -237,9 +229,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "constructors\n", - "\"\"\"\n", + "\n", "\n", "class Person:\n", " def __init__(self):\n", @@ -275,9 +265,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "constructors with arguments\n", - "\"\"\"\n", + "\n", "\n", "class Person:\n", " def __init__(self, s=\"no name assigned\", h=-1):\n", @@ -347,11 +335,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Separating the Constructor Prototype and Implementation\n", - "note: separation is not possible in Python we will do it the same way as previous\n", - "program\n", - "\"\"\"\n", + "\n", "\n", "class Person:\n", " def __init__(self, s=\"no name assigned\", h=-1):\n", @@ -421,9 +405,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Passing Structures as Function Arguments\n", - "\"\"\"\n", + "\n", "\n", "class Person:\n", " name = \"\"\n", @@ -499,9 +481,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "nesting structures\n", - "\"\"\"\n", + "\n", "\n", "class Date:\n", " month = 0\n", @@ -622,10 +602,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "classes\n", - "note: there won't be any error unlike the situation mentioned in textbook\n", - "\"\"\"\n", + "\n", "\n", "class Person:\n", " name = \"\"\n", @@ -701,10 +678,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "private & public specifiers\n", - "note: there are no such specifiers in Python\n", - "\"\"\"\n", "\n", "class Person:\n", " name = \"\"\n", diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter2.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter2.ipynb index d25f5c31..a10e4f68 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter2.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter2.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "chapter2" + "name": "", + "signature": "sha256:609a5d3522e4231d9e4a78cca1d62620ebc8f02a9a5a670cc7f12a71d13447b3" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,11 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Data Types\n", - "Note: there is no long double, or float double or double range or short.\n", - "Also, the size of data types my differ compared to c++\n", - "\"\"\"\n", + "\n", "\n", "import sys \n", "\n", diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter3.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter3.ipynb index d1b20dbb..ea8d38c3 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter3.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter3.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "chapter3" + "name": "", + "signature": "sha256:7d3fff6ffc0709910490ced1c16839cdcfbdac70ad380dbfa135865aaf26e67d" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,9 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Variable Declaration\n", - "\"\"\"\n", + "\n", "\n", "testScore = 0 #will declare testScore as an integer" ], @@ -50,9 +49,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Variable Declaration with error\n", - "\"\"\"\n", "\n", "testScore" ], @@ -82,10 +78,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Memory Address of variable\n", - "Note: address will be different from that given in the book\n", - "\"\"\"\n", + "\n", "\n", "testScore = 0\n", "print id(testScore)" @@ -115,10 +108,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Address and size of two variables\n", - "Note: the address and size will be diffent than the ones given in book\n", - "\"\"\"\n", + "\n", "import sys\n", "\n", "testScore = 0\n", @@ -157,9 +147,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "change in the value of a variable\n", - "\"\"\"\n", + "\n", "\n", "testScore = 95;\n", "print \"Your test score is: \", testScore\n", @@ -192,11 +180,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "A floating-point value, 77.83, is being assigned to an integer variable\n", - "Note: it will be printed as 77.83 unlike in the book, as Python implicitly\n", - "takes the data type according to the value assigned\n", - "\"\"\"\n", + "\n", "\n", "testScore = 77.83;\n", "print \"The test score is: \", testScore\n", @@ -228,10 +212,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Printing variable of short type but out of range.\n", - "Note: it will print 32768 as it is as there is no short data type in python\n", - "\"\"\"\n", + "\n", "\n", "testScore = 32768;\n", "print \"Your test score is: \", testScore" @@ -261,10 +242,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Printing variable of short type but out of range.\n", - "Note: it will print -32769 as it is as there is no short data type in python\n", - "\"\"\"\n", + "\n", "\n", "testScore = -32769\n", "print \"Your test score is: \", testScore" @@ -294,9 +272,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Inputting a value (without prompt msg)\n", - "\"\"\"\n", + "\n", "\n", "testScore = int(raw_input())\n", "print \"Your test score is: \", testScore" @@ -317,9 +293,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Inputting a value (with prompt msg)\n", - "\"\"\"\n", + "\n", "\n", "testScore = int(raw_input(\"Enter your test score: \"))\n", "print \"Your test score is: \", testScore" @@ -357,9 +331,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Inputting Values for Multiple Variables\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter your name: \",\n", "myName = raw_input()\n", @@ -443,10 +415,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Inputting Values for Multiple Variables in one prompt (no possible in python, it\n", - "will be same like the previous program\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter your name: \",\n", "myName = raw_input()\n", @@ -530,9 +499,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "inputting a string (python will take the whole string and will not omit anything)\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter your name: \",\n", "name = raw_input()\n", @@ -578,10 +545,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Printing variable of short type but out of range.\n", - "Note: it will print -32769 as it is as there is no short data type in python\n", - "\"\"\"\n", + "\n", "\n", "testScore = 32769\n", "print \"Your test score is: \", testScore" diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter4.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter4.ipynb index 3293ca3b..2fed811a 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter4.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter4.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:985e0e6b7e8ae27035cca1419b7775a3f9a570b5ac018168350c0febbe31d7b4" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,9 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "following program has two integer variables, total and added\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter number of preregistered students: \",\n", "total = int(raw_input())\n", @@ -93,9 +92,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "addition operator also can be used with string operands\n", - "\"\"\"\n", + "\n", "\n", "firstName = \"Jeff\"\n", "lastName = \"Kent\"\n", @@ -126,9 +123,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "program then uses the subtraction operator to update total.\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter number of preregistered students: \",\n", "total = int(raw_input())\n", @@ -210,9 +205,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "The Multiplication Operator\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter number of preregistered students: \",\n", "total = int(raw_input())\n", @@ -296,9 +289,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "The Division Operator\n", - "\"\"\"\n", + "\n", "\n", "firstOp = 10\n", "secondOp = 4\n", @@ -330,9 +321,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "The Division Operator with the variables intialized with float values\n", - "\"\"\"\n", + "\n", "\n", "firstOp = 10.0\n", "secondOp = 4.0\n", @@ -364,10 +353,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "the first division example changed to make the result of integer division\n", - "result into float\n", - "\"\"\"\n", + "\n", "\n", "firstOp = 10\n", "secondOp = 4\n", @@ -399,9 +385,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "using all the operators together\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter number of preregistered students: \",\n", "total = int(raw_input())\n", @@ -488,9 +472,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "program calculates the area of a circle based on a radius inputted by the user\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter radius of circle: \",\n", "radius = float(raw_input())\n", @@ -537,10 +519,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "converting pennies to dollars, Dollars: 3, \n", - "Quarters, Dimes: 1, Nickels: 0, Pennies: 2\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter number of pennies to make change for: \",\n", "total = int(raw_input())\n", diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter5.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter5.ipynb index cd6b98e9..7973421f 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter5.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter5.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "chapter5" + "name": "", + "signature": "sha256:527aef20f7b40df168e6ff4a5ccb96d249aaf7c6743cc854ce1a221227ecfb75" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,10 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "outputs the results of several variable comparisons.\n", - "0 -> False 1 -> True\n", - "\"\"\"\n", + "\n", "\n", "a = 4\n", "b = 5\n", @@ -69,9 +67,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Addition operation\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter number of preregistered students: \",\n", "total = int(raw_input())\n", @@ -135,9 +131,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "tests if a whole number entered is even\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter a whole number: \",\n", "num = int(raw_input())\n", @@ -184,9 +178,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "previous program modified to add else part for odd number\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter a whole number: \",\n", "num = int(raw_input())\n", @@ -235,9 +227,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "odd or even using inline condition (similar to conditional operator)\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter a whole number: \",\n", "num = int(raw_input())\n", @@ -283,9 +273,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "determines grades based on test score\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter your test score: \",\n", "testScore = int(raw_input())\n", @@ -340,10 +328,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "determines your average based on your grade\n", - "note: there is no switch statement in python\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter your grade: \",\n", "grade = raw_input()\n", @@ -399,10 +384,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "determines your average based on your grade with lower case alphabets also\n", - "note: there is no switch statement in python\n", - "\"\"\"\n", + "\n", "\n", "\n", "print \"Enter your grade: \",\n", @@ -459,9 +441,8 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "more example for switch (if else in python)\n", - "\"\"\"\n", + "\n", + "\n", "\n", "print \"Choose your car\"\n", "print \"S for Standard\"\n", diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter6.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter6.ipynb index a00118a8..bb24153c 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter6.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter6.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:9c21d1f44f5f11828308d4a5b6ab2316e8a5d933b04912def7dc67cfcb9dbaea" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,9 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "use of nested if statements\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter your age: \",\n", "age = int(raw_input())\n", @@ -102,9 +101,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "use of nested if statements\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter your age: \",\n", "age = int(raw_input())\n", @@ -156,9 +153,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "use of the logical And operator\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter your age: \",\n", "age = int(raw_input())\n", @@ -228,9 +223,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "use of the logical Or operator\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter your age: \",\n", "age = int(raw_input())\n", @@ -279,9 +272,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "use of the logical Not operator\n", - "\"\"\"\n", "\n", "print \"Enter your age: \",\n", "age = int(raw_input())\n", diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter7.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter7.ipynb index 6076d617..0272be09 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter7.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter7.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "chapter7" + "name": "", + "signature": "sha256:84d44e5e34aa0042556dda8bb39ee06beeff8eaea8bb2913d8710f888ef51867" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,9 +28,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "unary operators\n", - "\"\"\"\n", "\n", "num = 2\n", "num += 1\n", @@ -60,10 +58,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "increment operator\n", - "note: there is no increment/decrement operator in python we will use += instead\n", - "\"\"\"\n", + "\n", "\n", "num = 2\n", "num += 1\n", @@ -94,10 +89,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "increment operator\n", - "note: there is no increment/decrement operator in python we will use += instead\n", - "\"\"\"\n", + "\n", "\n", "num = 2\n", "print num\n", @@ -128,9 +120,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "unary operator (decrement)\n", - "\"\"\"\n", + "\n", "\n", "num = 2\n", "num -= 1\n", @@ -161,11 +151,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "prefix & postfix\n", - "note: there is no increment/decrement operator in python we will use -= instead\n", - "this program illustrates n--\n", - "\"\"\"\n", + "\n", "\n", "\n", "num = 2\n", @@ -197,11 +183,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "prefix & postfix\n", - "note: there is no increment/decrement operator in python we will use -= instead\n", - "this program illustrates --n\n", - "\"\"\"\n", "\n", "\n", "num = 2\n", @@ -233,9 +214,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "output the numbers between 1 and 10\n", - "\"\"\"\n", + "\n", "\n", "num = 1\n", "print num\n", @@ -292,9 +271,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "using a for loop (1 to 10)\n", - "\"\"\"\n", + "\n", "\n", "for num in range(1, 11):\n", " print num\n" @@ -333,9 +310,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "using a for loop (1 to 100)\n", - "\"\"\"\n", + "\n", "\n", "for num in range(1, 101):\n", " print num," @@ -365,11 +340,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "using a for loop\n", - "note: the method given in textbook is not possible in python, we will use a while\n", - "loop instead\n", - "\"\"\"\n", + "\n", "\n", "num = 1\n", "while num <= 10:\n", @@ -401,9 +372,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "infinite loop\n", - "\"\"\"\n", + "\n", "\n", "num = 1\n", "while num <= 10:\n", @@ -425,9 +394,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "factorial\n", - "\"\"\"\n", "\n", "total = 1;\n", "print \"Enter a number: \",\n", @@ -477,9 +443,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Breaking Out of a Loop\n", - "\"\"\"\n", + "\n", "\n", "secret = 3\n", "print \"Guess a number between 1 and 10\"\n", @@ -564,12 +528,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "logical && (And) operator is an alternative to using the break\n", - "keyword\n", "\n", - "note: and cannot be used in python with for loop, we will use if condition\n", - "\"\"\"\n", "\n", "secret = 3\n", "print \"Guess a number between 1 and 10\\n\"\n", @@ -631,12 +590,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "missing condition\n", - "Instead, the break keyword inside the if/else structure substitutes for that condition\n", - "note: we cannot write an infinte loop in python as given in book, we will use\n", - "while loop\n", - "\"\"\"\n", + "\n", "\n", "num = 1\n", "while True:\n", @@ -671,9 +625,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "continue keyword\n", - "\"\"\"\n", + "\n", "\n", "total = 0\n", "print \"How many items do you want to buy: \",\n", @@ -724,9 +676,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "using logical Not instead of continue keyword\n", - "\"\"\"\n", + "\n", "\n", "total = 0\n", "print \"How many items do you want to buy: \",\n", @@ -777,9 +727,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "Nesting for loop\n", - "\"\"\"\n", + "\n", "\n", "for x in range(1, 6):\n", " for y in range(1, 11):\n", @@ -820,9 +768,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "more nested for loop\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter number of salespersons: \",\n", "persons = int(raw_input())\n", diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter8.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter8.ipynb index c3bc8e16..24601877 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter8.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter8.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "chapter8" + "name": "", + "signature": "sha256:0900a5bcaf7054f0b4351a7d97782dfa44a0ae756b508bf87060112c13f5f981" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,9 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "for loop that was used earlier to show the difference between while loop & for\n", - "\"\"\"\n", + "\n", "\n", "for num in range(1, 11):\n", " print num," @@ -59,9 +58,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "using while loop for the same\n", - "\"\"\"\n", + "\n", "\n", "num = 1\n", "while num <=10:\n", @@ -93,10 +90,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "updation in the condition itself.\n", - "it is not possible in python, we will use normal while loop\n", - "\"\"\"\n", + "\n", "\n", "num = 0\n", "while (num <= 10):\n", @@ -128,10 +122,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "asks the user to enter a positive number,\n", - "and in a loop continues that request until the user does so\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter a positive number: \",\n", "num = int(raw_input())\n", @@ -180,10 +171,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "modification of the program uses the break keyword to provide the user with the\n", - "option of quitting the data entry\n", - "\"\"\"\n", + "\n", "\n", "print \"Enter a positive number: \",\n", "num = int(raw_input())\n", @@ -267,11 +255,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "flags\n", - "note: there is a mistake in the textbook, it should be choice == 'Y' instead of\n", - "choice != 'Y'\n", - "\"\"\"\n", + "\n", "\n", "quit = False\n", "print \"Enter a positive number: \",\n", @@ -329,9 +313,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "while(true)\n", - "\"\"\"\n", "\n", "quit = False\n", "while(True):\n", @@ -405,9 +386,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "continue keyword\n", - "\"\"\"\n", "\n", "counter = 0\n", "total = 0\n", @@ -436,10 +414,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "logical ! (Not)\n", - "operator as an alternative to using the continue keyword\n", - "\"\"\"\n", "\n", "counter = 0\n", "total = 0\n", @@ -492,9 +466,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "program using nested while loops\n", - "\"\"\"\n", "\n", "x = 0\n", "while(x < 5):\n", @@ -539,10 +510,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "do while loop\n", - "note: there is no do while loop in python, we will use while loop instead\n", - "\"\"\"\n", + "\n", "\n", "quit = False\n", "print \"Enter a positive number: \",\n", diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb index 4918a533..78228f18 100644 --- a/C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb +++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "" + "name": "", + "signature": "sha256:f0e84b29896f17b0ff44f8bccf20cf041a408375d83b3bc2290848ec54364369" }, "nbformat": 3, "nbformat_minor": 0, @@ -27,10 +28,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "terminology of a function\n", - "note: there is no need of main in python, defining here just for sake of understanding\n", - "\"\"\"\n", + "\n", "\n", "def main(): #defining a function \n", " print \"Hello World!\"\n", @@ -62,9 +60,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "defining a function\n", - "\"\"\"\n", "\n", "def printMessage(): # defining function\n", " print \"Hello world!\"\n", @@ -96,10 +91,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "prototyping\n", - "note: there is no need of prototyping in Python. In fact, you have to define a function before you call it in Python.\n", - "\"\"\"\n", + "\n", "\n", "printMessage();\n", "\n", @@ -131,11 +123,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "prototyping\n", - "note: the way it is given in textbook is not possible in python. We have to \n", - "define a funciton first in order to call it\n", - "\"\"\"\n", + "\n", "\n", "def printMessage():\n", " print \"Hello world!\"\n", @@ -167,10 +155,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "local variables\n", - "note: program will give an error saying local variable time is not defined\n", - "\"\"\"\n", "\n", "def printMessage():\n", " times += 1\n", @@ -231,9 +215,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "local variables\n", - "\"\"\"\n", + "\n", "\n", "def printMessage():\n", " times = 0\n", @@ -322,9 +304,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "global variables\n", - "\"\"\"\n", + "\n", "\n", "times = 0\n", "def printMessage():\n", @@ -430,11 +410,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "static local variables\n", - "note: there is no static keyword in python so we will use it as global variable\n", - "only.\n", - "\"\"\"\n", + "\n", "\n", "times = 0\n", "def printMessage():\n", @@ -540,9 +516,6 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "sending info. to a function\n", - "\"\"\"\n", "\n", "def printMessage():\n", " print \"You inputted \", str\n", @@ -591,9 +564,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "passing argument by value\n", - "\"\"\"\n", + "\n", "\n", "def printMessage(s):\n", " print \"You inputted \", s\n", @@ -642,9 +613,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "multiple function arguments\n", - "\"\"\"\n", + "\n", "\n", "def printMessage(firstName, lastName):\n", " print \"Your name is \", firstName, \" \", lastName\n", @@ -710,12 +679,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "multiple function arguments\n", - "note: in Python even if the arguments are reversed, it won't give an error as \n", - "we do not have to specipy the data type explicitly. The meaning or the context\n", - "of the output may change.\n", - "\"\"\"\n", + "\n", "\n", "def printMessage(thename, theage):\n", " print \"Your name is \", thename, \" and your age is\", theage\n", @@ -783,9 +747,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "passing argument by reference\n", - "\"\"\"\n", + "\n", "\n", "def doubleIt(x):\n", " print \"The number to be doubled is \", x\n", @@ -839,12 +801,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "pass by reference (address)\n", - "note: & sign is used in c++ to access a varibale by its address. There is no\n", - "such way or it is not a good practice to implement it. We will do the same in \n", - "some other way(there are multiple ways to achieve the same result)\n", - "\"\"\"\n", + "\n", "\n", "li = [0]\n", "def doubleIt():\n", @@ -900,10 +857,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "function to add two numbers\n", - "note: we are doing it in a differnt way then the one given in book\n", - "\"\"\"\n", + "\n", "\n", "z = []\n", "def addNumbers (a, b):\n", @@ -972,9 +926,7 @@ "cell_type": "code", "collapsed": false, "input": [ - "\"\"\"\n", - "returning value from function\n", - "\"\"\"\n", + "\n", "\n", "def addNumbers(x, y):\n", " return x + y\n", |