diff options
Diffstat (limited to 'Practical_C_Programming/Chapter_14_1.ipynb')
-rwxr-xr-x | Practical_C_Programming/Chapter_14_1.ipynb | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/Practical_C_Programming/Chapter_14_1.ipynb b/Practical_C_Programming/Chapter_14_1.ipynb index 6d3c736e..c25523b7 100755 --- a/Practical_C_Programming/Chapter_14_1.ipynb +++ b/Practical_C_Programming/Chapter_14_1.ipynb @@ -52,17 +52,15 @@ "metadata": {}, "outputs": [ { - "ename": "IOError", - "evalue": "[Errno 2] No such file or directory: 'input.txt'", - "output_type": "pyerr", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIOError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-1-038814efe2a7>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mcount\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m0\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[0min_file\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'input.txt'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'r'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[1;31m# Calculation and result\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mIOError\u001b[0m: [Errno 2] No such file or directory: 'input.txt'" + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number of characters in input.txt is 0\n", + "\n" ] } ], - "prompt_number": 1 + "prompt_number": 2 }, { "cell_type": "heading", @@ -84,7 +82,7 @@ "in_file = open ('input.txt', 'r')\n", " \n", "# Calculation and result\n", - "if not os.path.exists (name) :\n", + "if not os.path.exists ('input.txt') :\n", " print ('Could not open file\\n')\n", " sys.exit(1)\n", "print ('File found\\n')\n", @@ -95,17 +93,15 @@ "metadata": {}, "outputs": [ { - "ename": "IOError", - "evalue": "[Errno 2] No such file or directory: 'input.txt'", - "output_type": "pyerr", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIOError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m<ipython-input-2-370dc09ecbc3>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0msys\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[0min_file\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;34m'input.txt'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'r'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[1;31m# Calculation and result\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mIOError\u001b[0m: [Errno 2] No such file or directory: 'input.txt'" + "output_type": "stream", + "stream": "stdout", + "text": [ + "File found\n", + "\n" ] } ], - "prompt_number": 2 + "prompt_number": 5 }, { "cell_type": "heading", |