From 02b46b0657a86a50e13d74f0929df8132cf3d274 Mon Sep 17 00:00:00 2001 From: issa-garcia <68673381+issa-garcia@users.noreply.github.com> Date: Tue, 12 Jul 2022 12:10:01 +0200 Subject: [PATCH 1/5] Printing all results in a cell | Removed possible unintended texts | Corrected typos | Report broken hyperlinks in binder (see description) --- brisk_python.Rmd | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/brisk_python.Rmd b/brisk_python.Rmd index 6851e55c..921c2b83 100644 --- a/brisk_python.Rmd +++ b/brisk_python.Rmd @@ -72,6 +72,13 @@ a + b a * b ``` +By default, jupyter notebook cells will only print the results of the last line of code when it is not assigned to a variable. To print the results of previous lines of codes in the cell as well, the function print() can be used: + +```{python} +print(a + b) +a * b +``` + Dividing an int by an int also gives a float: ```{python} @@ -107,7 +114,6 @@ The `%` operator on numbers gives you the remainder of integer division 5.0 % 2.0 ``` -(true-and-false)= ## True and False @@ -186,7 +192,6 @@ different from MATLAB, which uses `~=`: a != 1 ``` -(comparison-operators)= ## Comparison operators @@ -269,7 +274,7 @@ print('not True:', not True) print('not False:', not False) ``` -In fact, the logical operators will first force their arguments to be True or False before they give their answer. So, in the case of `and` or `or`, they force force their left and right arguents to be `bool` values, before they calculate the answer. So, in fact, you can use things other than exact True and False on either side of the `and` or `or`, as long as applying `bool(value)` to the thing to the left and right will produce a True or False value. See {doc}`truthiness` for more detail. +In fact, the logical operators will first force their arguments to be True or False before they give their answer. So, in the case of `and` or `or`, they force their left and right arguents to be `bool` values, before they calculate the answer. So, in fact, you can use things other than exact True and False on either side of the `and` or `or`, as long as applying `bool(value)` to the thing to the left and right will produce a True or False value. See {doc}`truthiness` for more detail. ## “If” statements, blocks and indention @@ -689,7 +694,6 @@ you a reversed copy of the list: my_list[::-1] ``` -(tuples)= ## Tuples @@ -869,7 +873,7 @@ characters removed from the beginning and end of the string: ```{python} # A string with a newline character at the end my_string = ' a string\n' -my_string +print(my_string) my_string.strip() ``` From 0bfff105973c5cfd3eb4d9cea990fe224bc701bc Mon Sep 17 00:00:00 2001 From: issa-garcia <68673381+issa-garcia@users.noreply.github.com> Date: Tue, 12 Jul 2022 13:27:42 +0200 Subject: [PATCH 2/5] Update brisk_python.Rmd Fixed a typo on line 1071. Actual number in the text should have been 100. --- brisk_python.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brisk_python.Rmd b/brisk_python.Rmd index 921c2b83..0b88e091 100644 --- a/brisk_python.Rmd +++ b/brisk_python.Rmd @@ -1068,7 +1068,7 @@ software = {} ``` Here we insert a new key / value mapping into the dictionary. The key is a -string — `'Python'` — and the corresponding value is an integer 50: +string — `'Python'` — and the corresponding value is an integer 100: ```{python} software['Python'] = 100 From 5679370f33fd36b796107d722302f8193b5c8e75 Mon Sep 17 00:00:00 2001 From: issa-garcia <68673381+issa-garcia@users.noreply.github.com> Date: Tue, 12 Jul 2022 14:49:04 +0200 Subject: [PATCH 3/5] Update the_software.md Fixed typo in line 43: "here" into "hear" P.S. Atom is apparently going to be archived in December 15, 2022 (see Atom website for more info: https://github.blog/2022-06-08-sunsetting-atom/). You might want to change the example mentioned into other code editors or redirect to your "choosing an editor" website (https://textbook.nipraxis.org/choosing_editor.html). --- the_software.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/the_software.md b/the_software.md index 2ad88e30..f4f616bb 100644 --- a/the_software.md +++ b/the_software.md @@ -40,7 +40,7 @@ post](http://asterisk.dynevor.org/python-matlab.html). ## The Jupyter Notebook -We will soon here more about the Jupyter Notebook. It is a particularly +We will soon hear more about the Jupyter Notebook. It is a particularly easy interface to run Python code, and display the results. The Notebook has two parts. The first is the web application, that you From 90de4424eb4bc1797e1e0356a432c02ba11a3781 Mon Sep 17 00:00:00 2001 From: issa-garcia <68673381+issa-garcia@users.noreply.github.com> Date: Tue, 12 Jul 2022 15:00:49 +0200 Subject: [PATCH 4/5] Add GitHub Codespaces as an editor Atom mentions on their near-future archiving notice (https://github.blog/2022-06-08-sunsetting-atom/) this option which seems like a VS code online version from Github (https://github.com/features/codespaces). It might be good to have information about it on this website. Let me know if you would like me to write a small section about it. --- choosing_editor.md | 1 + 1 file changed, 1 insertion(+) diff --git a/choosing_editor.md b/choosing_editor.md index 6ab8a06e..baf5e1fc 100644 --- a/choosing_editor.md +++ b/choosing_editor.md @@ -76,6 +76,7 @@ to PyCharm users). * [Sublime text](https://www.sublimetext.com) * [Emacs](https://emacs.org) * [Spyder](https://www.spyder-ide.org) +* [GitHub Codespaces](https://github.com/features/codespaces) ## Some version of Visual Studio Code From 7de1712307a224238ee2bdcbcc1f56053e45d4ea Mon Sep 17 00:00:00 2001 From: issa-garcia <68673381+issa-garcia@users.noreply.github.com> Date: Thu, 14 Jul 2022 12:01:19 +0200 Subject: [PATCH 5/5] Update what_is_an_image.Rmd added some minor additional missing information that I think would be useful for the reader stopped at line 176; will continue later --- what_is_an_image.Rmd | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/what_is_an_image.Rmd b/what_is_an_image.Rmd index 14eefa33..13b332c6 100644 --- a/what_is_an_image.Rmd +++ b/what_is_an_image.Rmd @@ -79,11 +79,16 @@ import os # module for interacting with the operating system If you want to explore modules or objects, type their name followed by a period, and press tab to see what functions or classes are available. -Try this now. Type ( followed by a period) then press tab, to see +Try this now. Type os (followed by a period) then press tab, to see what functions are in the `os` module. Continue typing so you have -`os.getcwd`, and then type `?` followed by Return. This shows you +`os.getcwd`, and then type `?` followed by SHIFT + Return. This shows you the help for the `os.getcwd` function. +```{python} +# Cell to follow instructions in the previous parragraph +os. +``` + For example, here we print out the Python's *working directory*. It is the directory that contains this notebook file. @@ -145,7 +150,7 @@ How do I find out what `type` of object is attached to this variable called How big is this file in terms of bytes? Can you find out from the `contents` variable? (Hint: you want to know the length of -`contents`). +`contents`; Hint 2: use function len() ). ```{python} # n_bytes = ?