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
95 changes: 51 additions & 44 deletions Functions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"#this function adds two numbers passed as parameters\n",
Expand Down Expand Up @@ -128,9 +126,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'helloworld'"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"add (\"hello\", \"world\") # ooops this is weird!!"
]
Expand Down Expand Up @@ -208,23 +217,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 47,
"metadata": {},
"outputs": [],
"source": [
"# subtract function \n",
"\n",
"def subtract(a,b):\n",
" return(a-b)\n",
"# floorDivide function\n",
"\n",
"def floorDivide(a,b):\n",
" return(a/b)\n",
"# divide function\n",
"\n",
"def divide(a,b):\n",
" return(a//b)\n",
"# multiply function\n",
"\n",
"def multiply(a,b):\n",
" return(a*b)\n",
"# getRemainder function\n",
"\n",
"# power function"
"def getRemainder(a,b):\n",
" return(a%b)\n",
"# power function\n",
"def power(a,b):\n",
" return(a**2)"
]
},
{
Expand All @@ -238,80 +252,73 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"assert add(4,5)==9, \"add function not working\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"assert subtract(4,5)==-1, \"subtract function not working\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"assert multiply(4,5)==20, \"multiply function not working\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 49,
"metadata": {},
"outputs": [],
"source": [
"assert divide(5,5)==1.0, \"divide function not working\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 48,
"metadata": {},
"outputs": [],
"source": [
"assert floorDivide(1,2)==0.5, \"floor divide function not working\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 45,
"metadata": {},
"outputs": [],
"source": [
"assert getRemainder(5,4)==1, \"getRemainder function not working\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 46,
"metadata": {},
"outputs": [],
"source": [
"assert power(3,2)==9, \"power function not working\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down