diff --git a/Function-Math-libary-task.ipynb b/Function-Math-libary-task.ipynb new file mode 100644 index 0000000..cb75571 --- /dev/null +++ b/Function-Math-libary-task.ipynb @@ -0,0 +1,83 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "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", + "\n", + "#Using assert to test if function is fit for purpose.\n", + "assert add(2,3)==5, \"add 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\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}