diff --git a/Functions.ipynb b/Functions.ipynb index df58b4c..082fdb4 100644 --- a/Functions.ipynb +++ b/Functions.ipynb @@ -102,7 +102,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "add(4,5)" @@ -111,7 +113,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "add(-6,-5)" @@ -120,7 +124,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "add(5.6, 9)" @@ -129,7 +135,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "add (\"hello\", \"world\") # ooops this is weird!!" @@ -170,7 +178,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "assert 2 + 2 == 5, \"Houston we've got a problem\" #This will give an AssertionError\n" @@ -302,12 +312,202 @@ "assert getRemainder(5,4)==1, \"getRemainder function not working\"" ] }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "ename": "IndentationError", + "evalue": "unindent does not match any outer indentation level (, line 59)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m59\u001b[0m\n\u001b[0;31m File \"\", line 6\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m unindent does not match any outer indentation level\n" + ] + } + ], + "source": [ + "assert power(3,2)==9, \"power function not working\"\n", + "Jupyter Notebook Logout Control Panelprogramming1_function Last Checkpoint: 21 minutes ago (autosaved) Python 3\n", + "Python 3 Trusted\n", + "File\n", + "Edit\n", + "View\n", + "Insert\n", + "Cell\n", + "Kernel\n", + "Widgets\n", + "Help\n", + "\n", + "\n", + " \n", + " \n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "180" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def add (number1, number2):\n", + " answer = number1+number2 \n", + " return answer \n", + "add(50,130)" + ] + }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, + "outputs": [], + "source": [ + "def subtract (number1, number2):\n", + " answer = number1-number2\n", + " return answer \n", + "subtract(40,2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def floordivide (number1, number2):\n", + " answer = number1//number2\n", + " return answer\n", + "floordivide(9,2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def divide (number1, number2):\n", + " answer = number1/number2\n", + " return answer\n", + "divide(9,3)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def multiply (number1, number2):\n", + " answer = number1*number2\n", + " return answer\n", + "multiply(8,9)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def getRemainder (number1, number2):\n", + " answer = number1/number2\n", + " return answer\n", + "getRemainder(12,9)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def power (number1, number2):\n", + " answer = number1**number2\n", + " return answer \n", + "power(9,6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "answer = function(4,5)\n", + "print(answer)\n", + "\n", + "assert function(3,2)==5, \"error in addition\"\n", + "\n", + " in ()\n", + " 7 print(answer)\n", + " 8 \n", + "----> 9 assert function(3,2)==5, \"error in addition\"\n", + "\n", + "AssertionError: error in addition" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "assert subtract(4,5)==-1, \"subtract function not working\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "assert multiply(4,5)==20, \"multiply function not working\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "assert divide(5,5)==1.0, \"divide function not working\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "assert floorDivide(1,2)==0, \"floor divide function not working\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "assert getRemainder(5,4)==1, \"getRemainder function not working \"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, "outputs": [], "source": [ "assert power(3,2)==9, \"power function not working\""