diff options
author | kinitrupti | 2017-05-12 18:53:46 +0530 |
---|---|---|
committer | kinitrupti | 2017-05-12 18:53:46 +0530 |
commit | f270f72badd9c61d48f290c3396004802841b9df (patch) | |
tree | bc8ba99d85644c62716ce397fe60177095b303db /Programming_With_Java_A_Primer_by_E._Balagurusamy/chapter17.ipynb | |
parent | 64d949698432e05f2a372d9edc859c5b9df1f438 (diff) | |
download | Python-Textbook-Companions-f270f72badd9c61d48f290c3396004802841b9df.tar.gz Python-Textbook-Companions-f270f72badd9c61d48f290c3396004802841b9df.tar.bz2 Python-Textbook-Companions-f270f72badd9c61d48f290c3396004802841b9df.zip |
Removed duplicates
Diffstat (limited to 'Programming_With_Java_A_Primer_by_E._Balagurusamy/chapter17.ipynb')
-rwxr-xr-x | Programming_With_Java_A_Primer_by_E._Balagurusamy/chapter17.ipynb | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Programming_With_Java_A_Primer_by_E._Balagurusamy/chapter17.ipynb b/Programming_With_Java_A_Primer_by_E._Balagurusamy/chapter17.ipynb new file mode 100755 index 00000000..75e227d6 --- /dev/null +++ b/Programming_With_Java_A_Primer_by_E._Balagurusamy/chapter17.ipynb @@ -0,0 +1,61 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:6e44d5a558f592081f494afbf193b979399d3f382d6ddf2dd199186d661ef909" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 17: Assertion & Design by Contract" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 17.1, page no. 336" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "class Division():\n", + " def assertcheck(self, a, b):\n", + " assert(b!=0), \"The value b cannot be zero\"\n", + " c = a/b\n", + " print \"The result is: \", c\n", + "div = Division()\n", + "div.assertcheck(5, 0)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "AssertionError", + "evalue": "The value b cannot be zero", + "output_type": "pyerr", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m<ipython-input-1-426e5021b6ba>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0;34m\"The result is: \"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mdiv\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mDivision\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0mdiv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0massertcheck\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m<ipython-input-1-426e5021b6ba>\u001b[0m in \u001b[0;36massertcheck\u001b[0;34m(self, a, b)\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;32mclass\u001b[0m \u001b[0mDivision\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0massertcheck\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0;32massert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m!=\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"The value b cannot be zero\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0mc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0;34m\"The result is: \"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mAssertionError\u001b[0m: The value b cannot be zero" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file |