Skip to content

Commit 263ab9b

Browse files
committed
some improvements
1 parent 219e96d commit 263ab9b

File tree

20 files changed

+96
-65
lines changed

20 files changed

+96
-65
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Die Slides zum Kurs in deutscher Sprache können unter <https://thomasweise.gith
5050
25. [Schleifen mit `while`](https://thomasweise.github.io/programmingWithPythonSlidesDE/25_schleifen_mit_while.pdf)
5151
26. [Funktionen definieren und aufrufen](https://thomasweise.github.io/programmingWithPythonSlidesDE/26_funktionen_definieren_und_aufrufen.pdf)
5252
27. [Funktionen in Modulen](https://thomasweise.github.io/programmingWithPythonSlidesDE/27_funktionen_in_modulen.pdf)
53-
28. [Zwischenspiel: Unit Tests](https://thomasweise.github.io/programmingWithPythonSlidesDE/28_uni_tests.pdf)
53+
28. [Zwischenspiel: Unit Tests](https://thomasweise.github.io/programmingWithPythonSlidesDE/28_unit_tests.pdf)
5454

5555

5656
### 2.3. The Slides in English

text/main/basics/collections/dictionaries/dictionaries.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Sets and dictionaries in \python\ are implemented using similar datastructures~\cite{PSF:TPW:TC}, namely hash tables~\cite{K1998SAS,CLRS2009ITA,SKS2019DSC}, and thus exhibit similar performance.%
1313
%
1414
\begin{sloppypar}%
15-
\cref{lst:dicts:dicts_1} shows some examples of how we can use dictionaries.
15+
\Cref{lst:dicts:dicts_1} shows program \programUrl{dicts:dicts_1} with some examples of how we can use dictionaries.
1616
A dictionary can be created again using the \pythonil{\{...\}}\pythonIdx{\textbraceleft\idxdots\textbraceright!dict} syntax, however, this time, we place comma-separated \pythonil{key-value} pairs within the curly braces.
1717
The \pglspl{typeHint} for dictionaries\pythonIdx{dict!type hint} is \pythonil{dict[keyType][valueType]}, where \pythonil{keyType} is the type for the keys and \pythonil{valueType} is the type for the values~\cite{PEP585}.
1818
The line \pythonil{num_str: dict[int, str] = \{2: "two", 1: "one", 3: "three", 4: "four"\}} therefore creates a new dictionary and stores it in the variable \pythonil{num_str}.

text/main/basics/collections/lists/lists.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
A \pythonilIdx{list} is a mutable sequence of objects which can be accessed via their index~\cite{PSF:P3D:TPLR:S}.
1717
They work very similar to the strings we already discussed in \cref{sec:str}, but instead of (only) characters, they can contain any kind of objects and they can be modified.
1818

19-
In \cref{lst:lists:lists_1}, we provide some first examples for using lists.
19+
With program \programUrl{lists:lists_1} in \cref{lst:lists:lists_1}, we provide some first examples for using lists.
2020
A list can be defined by simply writing its contents, separated by~\pythonilIdx{,} inside square brackets~\pythonil{[...]}\pythonIdx{[\idxdots]}.
2121
\pythonil{["apple", "pear", "orange"]} creates a list with three elements, namely the strings \pythonil{"apple"}, \pythonil{"pear"}, and~\pythonil{"orange"}.
2222
If we want to store a list in a variable, then we can use the \pgls{typeHint}~\pythonil{list[elementType]}\pythonIdx{list!type hint} where \pythonil{elementType} is to be replaced with the type of the list elements~\cite{PEP585}.
@@ -58,7 +58,7 @@
5858
\pythonIdx{del}\pythonIdx{list!del}\pythonil{del food[1]} deletes the second element from the list~\pythonil{food}.
5959
The second element is \pythonil{pear} and if we print \pythonil{food} again, it has indeed disappeared.
6060

61-
In \cref{lst:lists:lists_2}, we illustrate some more operations on lists.
61+
In program \programUrl{lists:lists_2} in \cref{lst:lists:lists_2}, we illustrate some more operations on lists.
6262
We begin again by creating a list, this time of numbers: \pythonil{numbers: list[int] = [1, 7, 56, 2, 4]} creates (and type-hints) a list of five integers.
6363
If we want to know whether an element is included in a list, we can use the \pythonilIdx{in}~operator\pythonIdx{list!in}.
6464
\pythonil{7 in numbers} returns \pythonil{True} if \pythonil{7} is located somewhere inside the list~\pythonil{numbers} and \pythonil{False} otherwise.
@@ -96,7 +96,7 @@
9696
By the way, in the same manner as \pythonilIdx{not in} is the opposite of the \pythonil{in}~operator, \pythonilIdx{not is} is the opposite of~\pythonilIdx{is}:
9797
\pythonil{cpy is not numbers} yields \pythonil{True} because \pythonil{cpy} is not the same object as \pythonil{numbers}.
9898

99-
In \cref{lst:lists:lists_3}, we continue our journey through the magical land of \python\ \pythonils{list}.
99+
Program \programUrl{lists:lists_3} given in \cref{lst:lists:lists_3} continues our journey through the magical land of \python\ \pythonils{list}.
100100
You can add two lists~\pythonil{a} and~\pythonil{b} using \pythonilIdx{+}\pythonIdx{list!+}, i.e., do \pythonil{c = a + b}.
101101
The result is a new list which contains all elements of the first list~\pythonil{a} followed by all the elements from the second list~\pythonil{b}.
102102
Therefore, the expression \pythonil{[1, 2, 3, 4] + [5, 6, 7]} results in \pythonil{[1, 2, 3, 4, 5, 6, 7]}.

text/main/basics/collections/ruff/ruff.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
%
4747
\gitExec{exec:lists:lists_error:ruff}{\programmingWithPythonCodeRepo}{.}{_scripts_/ruff.sh collections lists_error.py}%
4848
\listingToolOutput{lists:lists_error:ruff}{%
49-
The results of linting with \ruff\ of the program given in \cref{lst:lists:lists_error}. (We used the script given in \cref{lst:bash:ruff} on \cpageref{lst:bash:ruff} to apply \ruff.)}%
49+
The results of linting with \ruff\ of the program \programUrl{lists:lists_error} given in \cref{lst:lists:lists_error}. (We used the script given in \cref{lst:bash:ruff} on \cpageref{lst:bash:ruff} to apply \ruff.)}%
5050
%
5151
Let us apply \ruff\ to the program \programUrl{lists:lists_error} given in \cref{lst:lists:lists_error}.
5252
This can be done by executing the command \bashil{ruff check myfile.py}, where \textil{myfile.py} is the file to be checked~(you can also specify a directory).
@@ -83,7 +83,7 @@
8383
The corrected version of~\cref{lst:lists:lists_error}, taking into account the information given by \mypy\ in \cref{exec:lists:lists_error:mypy} and \ruff\ in \cref{exec:lists:lists_error:ruff}.}{}%
8484
%
8585
%
86-
In \cref{lst:lists:lists_fixed} we implement the three recommendations from the two tools.
86+
In \cref{lst:lists:lists_fixed} we implement the three recommendations from the two tools as program \programUrl{lists:lists_fixed}.
8787
We change the \pgls{typeHint} of the list to \pythonil{list[int]}, which solves the type confusion that \mypy\ discovered.
8888
We remove the useless copying of the list as \ruff\ recommended.
8989
Finally, we add a proper \pgls{docstring} at the top of the file, in which we even document the changes we applied.

text/main/basics/collections/sets/sets.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
If we have more than just very few elements and either need to perform efficient lookups or set operations such as those discussed in the following text, sets are the way to go.%
5454
%
5555
\begin{sloppypar}%
56-
In \cref{lst:sets:sets_1}, we provide a first example of creating and working with sets.
56+
In program \programUrl{sets:sets_1} given as \cref{lst:sets:sets_1}, we provide a first example of creating and working with sets.
5757
Set \pglspl{literal} can be created by using curly braces, i.e, \pythonil{\{...\}}\pythonIdx{\textbraceleft\idxdots\textbraceright!set}.
5858
They can be type-hinted using the notation \pythonil{set[elementType]}\pythonIdx{set!type hint} where \pythonil{elementType} is the type of elements to be stored in the set~\cite{PEP585}.
5959
The line \pythonil{upper: set[str] = \{"A", "G", "B", "T", "V"\}} creates the variable \pythonil{upper}, which points to a set of the five uppercase latin characters~\pythonil{"A"}, \pythonil{"G"}, \pythonil{"B"}, \pythonil{"T"}, and~\pythonil{"V"}.
@@ -99,7 +99,7 @@
9999
\pythonil{sorted(my_text, key=str.casefold)}\pythonIdx{str!casefold}\pythonIdx{casefold}\pythonIdx{sorted}.%
100100
}%
101101
%
102-
In \cref{lst:sets:sets_2} we illustrate several basic operations with sets, some of which are visualized in \cref{fig:setOperations}.
102+
In program \programUrl{sets:sets_2} provided as \cref{lst:sets:sets_2}, we illustrate several basic operations with sets, some of which are visualized in \cref{fig:setOperations}.
103103
This time, we begin by defining a set \pythonil{odd} containing the first eight odd integers.
104104
Sets, like lists and tuples, support both the \pythonilIdx{in}\pythonIdx{set!in} and \pythonilIdx{not in}\pythonIdx{set!not in} operators.
105105
In the context of sets, they are equivalent to the $\in$ and $\notin$ operations from, well, set theory.

text/main/basics/collections/tuples/tuples.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
%
1616
\gitExec{exec:tuples:tuples_3:mypy}{\programmingWithPythonCodeRepo}{.}{_scripts_/mypy.sh collections tuples_3.py}%
1717
\listingToolOutput{tuples:tuples_3:mypy}{%
18-
The results of static type checking with \mypy\ of the program given in \cref{lst:tuples:tuples_3}.}%
18+
The results of static type checking with \mypy\ of the program \programUrl{tuples:tuples_3} given in \cref{lst:tuples:tuples_3}.}%
1919
%
2020
\gitExec{exec:tuples:tuples_3:ruff}{\programmingWithPythonCodeRepo}{.}{_scripts_/ruff.sh collections tuples_3.py}%
2121
\listingToolOutput{tuples:tuples_3:ruff}{%
22-
The results of the \ruff\ \pgls{linter} applied to the program given in \cref{lst:tuples:tuples_3}.}%
22+
The results of the \ruff\ \pgls{linter} applied to the program \programUrl{tuples:tuples_3} given in \cref{lst:tuples:tuples_3}.}%
2323
%
2424
\pythonIdx{tuple}%
2525
Tuples are very similar to lists, with three differences:
@@ -64,7 +64,7 @@
6464
The \pythonilIdx{index}\pythonIdx{tuple!index}, too, is available and \pythonil{fruits.index('apple')} returns~\pythonil{0} because \pythonil{"apple"} is the very first element of~\pythonil{fruits}.
6565
%
6666
\begin{sloppypar}%
67-
In \cref{lst:tuples:tuples_2} we explore tuples containing elements of multiple different types.
67+
With program \programUrl{tuples:tuples_2} in \cref{lst:tuples:tuples_2}, we explore tuples containing elements of multiple different types.
6868
The \pgls{typeHint} \pythonil{tuple[str, int, float]} states that we want to define a tuple where the first element is a string, the second element is an integer number, and the third element is a floating point number.
6969
The line \pythonil{mixed: tuple[str, int, float] = ("apple", 12, 1e25)} stores such a tuple in the variable~\pythonil{mixed}.
7070
The first element of the tuple is the string~\pythonil{"apple"}.

text/main/basics/gettingStarted/firstProgram/firstProgram.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
%
55
We now want to write and execute our very first \python\ program.
66
This program should just print \inQuotes{Hello World!} to the \pgls{stdout} and then exit.
7-
It therefore will consist of the single statement \pythonil{print("Hello World!")}, as illustrated in \cref{lst:very_first_program}.
7+
It therefore will consist of the single statement \pythonil{print("Hello World!")} in file \programUrl{very_first_program}, as illustrated in \cref{lst:very_first_program}.
88

99
\gitLoadAndExecPython{very_first_program}{}{veryFirstProject}{very_first_program.py}{}%
1010
\listingPythonAndOutput{very_first_program}{%

text/main/basics/simpleDataTypesAndOperations/str/str.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@
469469
Depending on how their computer encodes text, the Basic Latin characters are usually interpreted correctly.
470470
But some computers may misinterpret \pgls{unicode} text as something else because the mix up the file encoding.
471471
If we use the \pythonil{\\u}-based\pythonIdx{\textbackslash{u}} escape, then we can represent \emph{any} character as Basic Latin text sequence.
472-
It is also useful if we want to, e.g., enter Chinese text on a machine that does not have an \pgls{IME} or other corresponding tools, or text in any other kind of language where we do not have corresponding keys on the keyboard (see, e.g., \cref{lst:variables:pi_liu_hui} later on).
472+
It is also useful if we want to, e.g., enter Chinese text on a machine that does not have an \pgls{IME} or other corresponding tools, or text in any other kind of language where we do not have corresponding keys on the keyboard~(see, e.g., \cref{lst:variables:pi_liu_hui} later on).
473473

474474
Anyway, in \cref{exec:str_unicode}, we use the information obtained in \cref{fig:unicodeCharacterTableSubset} to print the Chinese text \inQuotes{你好。} standing for \inQuotes{Hello.} and pronounced as \inQuotes{N{\v{\i}} h{\v{a}}o.} as a unicode-escaped string.
475475
We found that the character for \inQuotes{你} has unicode number~4f60, \inQuotes{好} has~597d, and the big period~\inQuotes{。} has~3002.

text/main/basics/variables/errorsInIde/errorsInIde.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
%
44
\gitLoadAndExecPythonAndErrors{variables:assignment_wrong}{}{variables}{assignment_wrong.py}{}%
55
\listingPythonAndError{variables:assignment_wrong}{%
6-
A variant of \cref{lst:variables:assignment} with an error:~\pythonil{int_var} is accidentally spelled as \pythonil{intvar} in one location.}%
6+
A variant of program \programUrl{variables:assignment} from \cref{lst:variables:assignment} with an error:~\pythonil{int_var} is accidentally spelled as \pythonil{intvar} in one location.}%
77
%
88
\begin{figure}%
99
\centering%

0 commit comments

Comments
 (0)