Skip to content

Commit

Permalink
📝 Improve explanation for exercise 2d
Browse files Browse the repository at this point in the history
  • Loading branch information
jemrobinson committed Jan 27, 2023
1 parent f913b8c commit aba520e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions solutions/module_02.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -162,30 +162,30 @@
"source": [
"**Answer 2d**\n",
"\n",
"Will have to import libraries.\n",
"After `import`ing the libraries you can use ```dir(X)``` to list the attributes of each module\n",
"\n",
"Can use ```dir(X)``` to list the attributes of the modules\n",
"There will be some depreciation warnings from `scipy` instructing users to use `numpy` or `numpy.lib` (which can also be investigated via ```dir(numpy.lib)```\n",
"\n",
"There will be some depreciation warnings from scipy instructing users to go use numpy or numpy.lib (which can also be investigated via ```dir(np.lib)```\n",
"`pi`: Use `numpy.pi`, `scipy.pi`, `math.pi`. `statistics` has `tau` but not `pi`.\n",
"\n",
"Statistics will return the mean as an integer whereas numpy and scipy will return a float.\n",
"`log`: Use `numpy.log10`, `scipy.log10`, `math.log10`. `statistics` has `log` but not `log10`: `log(n)/log(10)` can be used instead.\n",
"\n",
"All return the same value of pi.\n",
"For log(+ive) we use +12.01 as an example while for log(-ive) we use -11.99 as an example.\n",
"\n",
"scipy returns a complex number for the negative log example with an imaginary part of pi.\n",
"| Module | pi | log(+ive) | log(-ive) | mean |\n",
"|:-----------|:----------:|:----------:|:------------------------:|:----:|\n",
"| numpy | 3.14159... | 1.07954... | nan | 5.0 |\n",
"| scipy | 3.14159... | 1.07954... | (1.07881...+1.36437...j) | 5.0 |\n",
"| math | 3.14159... | 1.07954... | math domain error | n/a |\n",
"| statistics | n/a | 1.07954... | math domain error | 5 |\n",
"\n",
"log(+ive) using +12.01 as an example\n",
"All libraries return the same value of pi.",
"\n",
"log(-ive) using -11.99 as an example\n",
"All libraries return the same value of log(+ive).",
"\n",
"| Module | pi| log(+ive) | log(-ive)| mean|\n",
"| :-------|:-------------:|:-----:|:-----:|:-----:|\n",
"|numpy|3.14159...|2.48573...|nan|5.0|\n",
"|scipy|3.14159...|2.48573...|(2.48407... + 3.14159...j)|5.0|\n",
"|math|3.14159...|2.48573...|math domain error|§|\n",
"|statistics|§|2.48573...|math domain error|5|\n",
"scipy returns a complex number for the negative log example while all others produce an error.\n",
"\n",
"§ module doesn't have method"
"`statistics` returns the mean as an integer whereas `numpy` and `scipy` return a float.\n"
]
},
{
Expand Down

0 comments on commit aba520e

Please sign in to comment.