Skip to content

Printing all results in a cell | Removed possible unintended texts | Corrected typos | Report broken hyperlinks in binder (see below) #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
16 changes: 10 additions & 6 deletions brisk_python.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -107,7 +114,6 @@ The `%` operator on numbers gives you the remainder of integer division
5.0 % 2.0
```

(true-and-false)=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed? (please re-add)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In binder they look like this. I was not sure if they were a mistake.

image

But now I see on the website version they look OK.

image

Should I re-add still? Should I look for a way the they do not look like that in Binder? I now assume they are there for a reason, do you know what is the function of those lines?


## True and False

Expand Down Expand Up @@ -186,7 +192,6 @@ different from MATLAB, which uses `~=`:
a != 1
```

(comparison-operators)=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


## Comparison operators

Expand Down Expand Up @@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
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

Expand Down Expand Up @@ -689,7 +694,6 @@ you a reversed copy of the list:
my_list[::-1]
```

(tuples)=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


## Tuples

Expand Down Expand Up @@ -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()
```

Expand Down Expand Up @@ -1064,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
Expand Down
1 change: 1 addition & 0 deletions choosing_editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* [GitHub Codespaces](https://github.com/features/codespaces)


## Some version of Visual Studio Code

Expand Down
2 changes: 1 addition & 1 deletion the_software.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions what_is_an_image.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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 = ?
Expand Down