summaryrefslogtreecommitdiff
path: root/C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb
diff options
context:
space:
mode:
authorkinitrupti2015-10-15 17:40:30 +0530
committerkinitrupti2015-10-15 17:40:30 +0530
commit4a735f833653551e3321fbe9a8e47faa879d282f (patch)
treedb91b182e06d1695ad8db15d757f669ad929c0b6 /C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb
parent78784b374b2d1a9be66eb4ad41470409e2bd4dfa (diff)
downloadPython-Textbook-Companions-4a735f833653551e3321fbe9a8e47faa879d282f.tar.gz
Python-Textbook-Companions-4a735f833653551e3321fbe9a8e47faa879d282f.tar.bz2
Python-Textbook-Companions-4a735f833653551e3321fbe9a8e47faa879d282f.zip
solved errors
Diffstat (limited to 'C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb')
-rwxr-xr-xC++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb65
1 files changed, 55 insertions, 10 deletions
diff --git a/C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb b/C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb
index 78228f18..5b5e1ccb 100755
--- a/C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb
+++ b/C++_Demystified:_A_Self-Teaching_Guide/chapter9.ipynb
@@ -157,11 +157,12 @@
"input": [
"\n",
"def printMessage():\n",
+ " times = 0\n",
" times += 1\n",
" print \"This function called \", times, \" times\"\n",
"\n",
"\n",
- "times = 0\n",
+ "\n",
"choice = '1'\n",
"while(choice != 'Q'):\n",
" print \"Enter Q to quit, any other character to continue: \",\n",
@@ -178,6 +179,22 @@
"output_type": "stream",
"stream": "stdout",
"text": [
+ " Enter Q to quit, any other character to continue: "
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "e\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " This function called 1 times\n",
"Enter Q to quit, any other character to continue: "
]
},
@@ -190,18 +207,46 @@
]
},
{
- "ename": "UnboundLocalError",
- "evalue": "local variable 'times' referenced before assignment",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mUnboundLocalError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m<ipython-input-8-42e131eb489c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 17\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"Input stopped\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 18\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 19\u001b[1;33m \u001b[0mprintMessage\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[1;32m<ipython-input-8-42e131eb489c>\u001b[0m in \u001b[0;36mprintMessage\u001b[1;34m()\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mprintMessage\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 7\u001b[1;33m \u001b[0mtimes\u001b[0m \u001b[1;33m+=\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 8\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"This function called \"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtimes\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\" times\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;31mUnboundLocalError\u001b[0m: local variable 'times' referenced before assignment"
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " This function called 1 times\n",
+ "Enter Q to quit, any other character to continue: "
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "q\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " This function called 1 times\n",
+ "Enter Q to quit, any other character to continue: "
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Q\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " Input stopped\n"
]
}
],
- "prompt_number": 8
+ "prompt_number": 4
},
{
"cell_type": "heading",