Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 208 additions & 8 deletions Functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"add(4,5)"
Expand All @@ -111,7 +113,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"add(-6,-5)"
Expand All @@ -120,7 +124,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"add(5.6, 9)"
Expand All @@ -129,7 +135,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"add (\"hello\", \"world\") # ooops this is weird!!"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 (<tokenize>, line 59)",
"output_type": "error",
"traceback": [
"\u001b[0;36m File \u001b[0;32m\"<tokenize>\"\u001b[0;36m, line \u001b[0;32m59\u001b[0m\n\u001b[0;31m File \"<ipython-input-19-3681a1b595f2>\", 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",
"<ipython-input-51-9f8f9b6db40b> in <module>()\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\""
Expand Down