Skip to content

Commit

Permalink
added numerical error convergence defn
Browse files Browse the repository at this point in the history
  • Loading branch information
rcc02007 committed Jan 9, 2020
1 parent a775031 commit ecc40dc
Show file tree
Hide file tree
Showing 4 changed files with 532 additions and 224 deletions.
39 changes: 33 additions & 6 deletions notebooks/.ipynb_checkpoints/02_Getting-started-checkpoint.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,30 @@
"\n",
"- 10! = 3,628,800\n",
"\n",
"In the next block, we have rewritten `code` so the output is unchanged, but another user can read the code *and* help debug if there is an issue. "
"In the next block, we have rewritten `code` so the output is unchanged, but another user can read the code *and* help debug if there is an issue. \n",
"\n",
"A function is a compact collection of code that executes some action on its arguments. \n",
"\n",
"Once *defined*, you can *call* a function as many times as you want. When we *call* a function, we execute all the code inside the function. The result of the execution depends on the *definition* of the function and on the values that are *passed* into it as *arguments*. Functions might or might not *return* values in their last operation. \n",
"\n",
"The syntax for defining custom Python functions is:\n",
"\n",
"```python\n",
"def function_name(arg_1, arg_2, ...):\n",
" '''\n",
" docstring: description of the function\n",
" '''\n",
" <body of the function>\n",
"```\n",
"\n",
"The **docstring** of a function is a message from the programmer documenting what he or she built. Docstrings should be descriptive and concise. They are important because they explain (or remind) the intended use of the function to the users. You can later access the docstring of a function using the function `help()` and passing the name of the function. If you are in a notebook, you can also prepend a question mark `'?'` before the name of the function and run the cell to display the information of a function. \n",
"\n",
"Try it!"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 96,
"metadata": {
"slideshow": {
"slide_type": "subslide"
Expand All @@ -136,17 +154,26 @@
" '''Good variable names and better help documentation\n",
" \n",
" factorial_function(input_number): calculates the factorial of the input_number\n",
" where the factorial is defined as N*(N-1)*(N-2)*...*3*2*1'''\n",
" where the factorial is defined as N*(N-1)*(N-2)*...*3*2*1\n",
" \n",
" Arguments\n",
" ---------\n",
" input_value: an integer >= 0\n",
" \n",
" Returns\n",
" -------\n",
" factorial_output: the factorial of input_value'''\n",
" \n",
" factorial_output=1 # define 0! = 1\n",
" for factor in range(1,input_value+1):\n",
" factorial_output*=factor; # mutliply m by 1*2*3*...*N (factor)\n",
" factorial_output*=factor; # mutliply factorial_output by 1*2*3*...*N (factor)\n",
" return factorial_output\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 97,
"metadata": {
"slideshow": {
"slide_type": "subslide"
Expand All @@ -159,7 +186,7 @@
"24"
]
},
"execution_count": 13,
"execution_count": 97,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
Loading

0 comments on commit ecc40dc

Please sign in to comment.