From 8cad0dc4066da23a9e2adb8de5f618dae1343afe Mon Sep 17 00:00:00 2001 From: Joynul Islam Date: Fri, 22 Sep 2017 13:09:04 +0000 Subject: [PATCH 1/3] maths function updated --- Function-Math-libary-task.ipynb | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Function-Math-libary-task.ipynb diff --git a/Function-Math-libary-task.ipynb b/Function-Math-libary-task.ipynb new file mode 100644 index 0000000..e123c73 --- /dev/null +++ b/Function-Math-libary-task.ipynb @@ -0,0 +1,88 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "#YOU NEED TO CALL THE DESIRED FUNCTION\n", + "#add()\n", + "#sub()\n", + "#floorDiv()\n", + "#div()\n", + "#mult()\n", + "#rem()\n", + "#power()\n", + "\n", + "#Libary of Maths Function\n", + "\n", + "#Additon\n", + "#Takes 2 paramenters to input\n", + "def add(x,y):\n", + " #returns the sum of the 2 numbers inputed \n", + " return(x+y)\n", + " \n", + "\n", + "#Subtraction\n", + "#Takes 2 paramenters to input\n", + "def sub(x,y):\n", + " #returns the difference of the 2 numbers inputed \n", + " return(x-y)\n", + "\n", + "#Floor divide\n", + "#Takes 2 paramenters to input\n", + "def floorDiv(x,y):\n", + " #returns the division of the 2 numbers inputed, rounded down as an integer \n", + " return(int(x/y))\n", + "\n", + "#Divide\n", + "#Takes 2 paramenters to input\n", + "def div(x,y):\n", + " #returns the division of the 2 numbers inputed\n", + " return(x/y)\n", + "\n", + "#Multiplication\n", + "#Takes 2 paramenters to input\n", + "def mult(x,y):\n", + " #returns the product of the 2 numbers\n", + " return(x*y)\n", + "\n", + "#Remainder\n", + "#Takes 2 paramenters to input\n", + "def rem(x,y):\n", + " #returns the remainder of the divion of the 2 numbers\n", + " return(x%y)\n", + "\n", + "#Exponents of power\n", + "#Takes 2 paramenters to input\n", + "def power(x,y):\n", + " #returns the first number raised by the second.\n", + " return(x**y)\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 5b67cdf14f85dc08629e49915bbea15b8f0e9590 Mon Sep 17 00:00:00 2001 From: Joynul Islam Date: Tue, 26 Sep 2017 13:00:56 +0000 Subject: [PATCH 2/3] Math library assertion added --- Function-Math-libary-task.ipynb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Function-Math-libary-task.ipynb b/Function-Math-libary-task.ipynb index e123c73..d9c1e90 100644 --- a/Function-Math-libary-task.ipynb +++ b/Function-Math-libary-task.ipynb @@ -60,7 +60,16 @@ "#Takes 2 paramenters to input\n", "def power(x,y):\n", " #returns the first number raised by the second.\n", - " return(x**y)\n" + " return(x**y)\n", + "\n", + "#Using assert to test if function is fit for purpose.\n", + "assert add(2,3)==5, \"add function not working\"\n", + "assert subtract(2,3)==-1, \"subtract function not working\"\n", + "assert multiply(2,3)==6, \"multiply function not working\"\n", + "assert divide(6,3)==2.0, \"divide function not working\"\n", + "assert floorDivide(1,2)==0, \"floor divide function not working\"\n", + "assert getRemainder(3,2)==1, \"getRemainder function not working\n", + "assert power(2,4)==16, \"power function not working\"" ] } ], From a479a242ec6d2fe35336523a42330b9c0a6fad75 Mon Sep 17 00:00:00 2001 From: Joynul Islam Date: Tue, 26 Sep 2017 13:04:40 +0000 Subject: [PATCH 3/3] Errors fixed --- Function-Math-libary-task.ipynb | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/Function-Math-libary-task.ipynb b/Function-Math-libary-task.ipynb index d9c1e90..cb75571 100644 --- a/Function-Math-libary-task.ipynb +++ b/Function-Math-libary-task.ipynb @@ -2,10 +2,8 @@ "cells": [ { "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, + "execution_count": 7, + "metadata": {}, "outputs": [], "source": [ "#YOU NEED TO CALL THE DESIRED FUNCTION\n", @@ -64,11 +62,11 @@ "\n", "#Using assert to test if function is fit for purpose.\n", "assert add(2,3)==5, \"add function not working\"\n", - "assert subtract(2,3)==-1, \"subtract function not working\"\n", - "assert multiply(2,3)==6, \"multiply function not working\"\n", - "assert divide(6,3)==2.0, \"divide function not working\"\n", - "assert floorDivide(1,2)==0, \"floor divide function not working\"\n", - "assert getRemainder(3,2)==1, \"getRemainder function not working\n", + "assert sub(2,3)==-1, \"subtract function not working\"\n", + "assert mult(2,3)==6, \"multiply function not working\"\n", + "assert div(6,3)==2.0, \"divide function not working\"\n", + "assert floorDiv(1,2)==0, \"floor divide function not working\"\n", + "assert rem(3,2)==1, \"getRemainder function not working\"\n", "assert power(2,4)==16, \"power function not working\"" ] } @@ -78,18 +76,6 @@ "display_name": "Python 3", "language": "python", "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.5.2" } }, "nbformat": 4,