diff options
author | Hardik Ghaghada | 2014-06-20 15:52:25 +0530 |
---|---|---|
committer | Hardik Ghaghada | 2014-06-20 15:52:25 +0530 |
commit | e1e59ca3a50d9f93e8b7bc0693b8081d5db77771 (patch) | |
tree | f54eab21dd3d725d64a495fcd47c00d37abed004 /C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb | |
parent | a78126bbe4443e9526a64df9d8245c4af8843044 (diff) | |
parent | 83c1bfceb1b681b4bb7253b47491be2d8b2014a1 (diff) | |
download | Python-Textbook-Companions-e1e59ca3a50d9f93e8b7bc0693b8081d5db77771.tar.gz Python-Textbook-Companions-e1e59ca3a50d9f93e8b7bc0693b8081d5db77771.tar.bz2 Python-Textbook-Companions-e1e59ca3a50d9f93e8b7bc0693b8081d5db77771.zip |
Merge pull request #1 from debashisdeb/master
removing problem statements from all the chapters to avoid copyright violations
Diffstat (limited to 'C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb')
-rw-r--r-- | C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb | 78 |
1 files changed, 15 insertions, 63 deletions
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", |