Skip to content

Commit ad0bdd5

Browse files
committed
slight improvement
1 parent fef2f72 commit ad0bdd5

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

text/main/basics/collections/summary/summary.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
%
2222
collection is mutable&\greenYes&\redNo&\greenYes&\greenYes\\%
2323
%
24-
mutable values OK&\greenYes&\redNo&\redNo&\pythonil{E}:~\redNo; \pythonil{F}:~\greenYes\\%
24+
mutable elements OK&\greenYes&\redNo&\redNo&\pythonil{E}:~\redNo; \pythonil{F}:~\greenYes\\%
2525
%
2626
all elements of same datatype&\greenYes&\redNo&\greenYes&\greenYes\\%
2727
%

text/main/basics/variables/typesAndTypeHints/typesAndTypeHints.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
We can now apply the tool to the program \programUrl{variables:types_wrong} from \cref{lst:variables:types_wrong}.
166166
All we have to do is invoke it in the terminal, giving the program to be checked as argument as well as some additional parameters.
167167
In \cref{exec:variables:variable_types_wrong:mypy}, we invoke \bashil{mypy variable_types_wrong.py --no-strict-optional --check-untyped-defs}, where \programUrl{variables:types_wrong} is the (very fitting) name of the program to check.
168+
(In some setups, this does not work, and we have to write \bashil{python3 -m mypy variable_types_wrong.py} instead of \bashil{mypy variable_types_wrong.py}.)
168169
Indeed, \mypy\ tells us that something dodgy is going on in the fourth line of that program, i.e., \pythonil{int_var = int_var / 3}.
169170
It will fail with an \pgls{exitCode} of~\bashil{1}.
170171
Programs usually return~\bashil{0} as \pgls{exitCode} if everything went well and some non-zero value if something went wrong.

text/main/controlFlow/loops/loops.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
We use four \pythonilIdx{for}~loops to fill this dictionary with data.
6363
In each of these first four \pythonilIdx{for}~loops, we use \pythonil{i} as the loop variable.
6464

65-
When iterating over the \pythonil{range(5)} in the first loop, \pythonil{i} will hold the value \pythonil{0} in the first iteration (=~execution of the loop body).
65+
When iterating over the \pythonil{range(5)} in the first loop, \pythonil{i} will hold the value \pythonil{0} in the first iteration~(=~execution of the loop body).
6666
The loop body \pythonil{squares[i] = i * i} will thus effectively be \pythonil{squares[0] = 0} and thus store the value~\pythonil{0} under key~\pythonil{0} into the dictionary \pythonil{squares}.
6767
In the second iteration, \pythonil{i} will hold the value~\pythonil{1}.
6868
Then, the body \pythonil{squares[i] = i * i} will effectively be \pythonil{squares[1] = 1}.
@@ -204,9 +204,9 @@
204204
%
205205
\begin{sloppypar}%
206206
We can therefore iterate a second, inner loop variable \pythonil{check} over \pythonil{range(3, isqrt(candidate) + 1, 2)}\pythonIdx{range}\pythonIdx{isqrt}.
207-
If \pythonil{candidate <= 3}, then this loop will never be executed because no number \pythonil{check} with $3\leq\pythonil{check}<\pythonil{candidate}$ exists.
207+
If \pythonil{candidate <= 8}, then this loop will never be executed because no number \pythonil{check} with $3\leq\pythonil{check}<\pythonil{isqrt(candidate)}$ exists.
208208
Then, \pythonil{is_prime} will remain \pythonil{True} and we will append \pythonil{candidate} to \pythonil{primes} further down the outer loop body.
209-
If \pythonil{candidate > 3}, then \pythonil{check} will go from~\pythonil{3} bis~$\left\lfloor\sqrt{\pythonil{candidate}}\right\rfloor$.%
209+
If \pythonil{candidate > 8}, then the loop is actually entered and \pythonil{check} will go from~\pythonil{3} to~$\left\lfloor\sqrt{\pythonil{candidate}}\right\rfloor$.%
210210
\end{sloppypar}%
211211
%
212212
In the body of our inner loop, we try to find out whether \pythonil{check} is an integer divisor of \pythonil{candidate}.

0 commit comments

Comments
 (0)