You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
author = a_editors_of_encyclopaedia_britannica # and # a_setia_veenu # and # a_rodriguez_emily # and # a_gaur_aakanksha # and # a_matthias_meg # and # a_lotha_gloria,
Copy file name to clipboardExpand all lines: notation/terms.sty
+2-2
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ See \cref{sec:howFloatingPointNumbersWork}.%
18
18
name={docstring},%
19
19
description={%
20
20
Docstrings are special string constants in \python\ that contain documentation for modules or functions~\cite{PEP257}. %
21
-
They must be delimited by~\pythonil{"""..."""}\pythonIdx{\textquotedbl\textquotedbl\textquotedbl}~\cite{PEP257,PEP8}.%
21
+
They must be delimited by~\pythonil{"""..."""}\pythonIdx{\textquotedbl\textquotedbl\textquotedbl\idxdots\textquotedbl\textquotedbl\textquotedbl}~\cite{PEP257,PEP8}.%
22
22
}%
23
23
}%
24
24
%
@@ -49,7 +49,7 @@ name={f-string},%
49
49
plural={f-strings},%
50
50
sort={f-string},
51
51
description={%
52
-
is a special string in \python, which delimited by \pythonil{f"..."} which can contain expressions in curly braces like \pythonil{f"a\{6-1\}b"} that are then turned to text via \pgls{strinterpolation}, which turns the string to~\pythonil{"a5b"}. %
52
+
is a special string in \python, which delimited by \pythonil{f"..."}\pythonIdx{f\textquotedbl\idxdots\textquotedbl} which can contain expressions in curly braces like \pythonil{f"a\{6-1\}b"} that are then turned to text via \pgls{strinterpolation}, which turns the string to~\pythonil{"a5b"}. %
53
53
f\nobreakdash-strings are discussed in \cref{sec:fstrings}.%
\lstinputlisting[label={exec:#5},style=text_style,caption={The standard output and error as well as the exit code of the program~\href{\csname @pwp@gitUrl:lst:#5\endcsname}{\textil{#3}} given in~\cref{lst:#5}.}]{\csname @pwp@gitFile:exec:#5\endcsname}%
Copy file name to clipboardExpand all lines: text/main/basics/collections/collections.tex
+2-2
Original file line number
Diff line number
Diff line change
@@ -23,14 +23,14 @@
23
23
The mathematical notion of sets is implemented in the \python\ datatype \pythonil{set}.
24
24
A set can contain each element at most once.
25
25
The methods for modifying sets and for checking whether elements are contained in them are particularly fast.
26
-
Sets are created using curly braces, i.e., \pythonil{my_set = \{1.2, 2.3, 4.5, 2.3\}} would create the set \pythonil{my_set} with the three numbers \pythonil{1.2}, \pythonil{2.3}, and~\pythonil{4.5}.
26
+
Sets are created using curly braces, i.e., \pythonil{my_set = \{1.2, 2.3, 4.5, 2.3\}}\pythonIdx{\textbraceleft\idxdots\textbraceright!set} would create the set \pythonil{my_set} with the three numbers \pythonil{1.2}, \pythonil{2.3}, and~\pythonil{4.5}.
27
27
Notice that \pythonil{2.3} would appear only once in the set.
28
28
Sets cannot be indexed, but like lists and tuples they support the \pythonil{in} operator and \pythonil{1.2 in my_set} returns \pythonil{True} while \pythonil{1.3 in my_set} is \pythonil{False}.
29
29
We will discuss sets in \cref{sec:sets}.
30
30
31
31
Finally, dictionaries are mappings between keys and values, similar to hash tables in other programming languages.
32
32
They, too, are created using curly braces which, however, contain key-value pairs.
33
-
In other words, \pythonil{my_dict = \{"pi": 3.1416, "e": 2.7183, "phi": 1.618\}} creates a dictionary which maps the strings \pythonil{"pi"}, \pythonil{"e"}, and \pythonil{"phi"} to the values \pythonil{3.1416}, \pythonil{2.7183}, and~\pythonil{1.618}, respectively.
33
+
In other words, \pythonil{my_dict = \{"pi": 3.1416, "e": 2.7183, "phi": 1.618\}}\pythonIdx{\textbraceleft\idxdots\textbraceright!dict} creates a dictionary which maps the strings \pythonil{"pi"}, \pythonil{"e"}, and \pythonil{"phi"} to the values \pythonil{3.1416}, \pythonil{2.7183}, and~\pythonil{1.618}, respectively.
34
34
The value of a key can be retrieved using the square-bracket indexing, i.e., \pythonil{my_dict["e"]} would return \pythonil{2.7183}.
Copy file name to clipboardExpand all lines: text/main/basics/collections/dictionaries/dictionaries.tex
+4-4
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,14 @@
5
5
An example for using dictionaries in \python.}%
6
6
%
7
7
Dictionaries in \python\ are containers that store key-value pairs.
8
-
The value associated with a given key is accessed via the \pythonilIdx{[...]}-based indexing.
8
+
The value associated with a given key is accessed via the \pythonil{[...]}\pythonIdx{[\idxdots]}-based indexing.
9
9
The keys are unique and can be of an arbitrary type, as long as they are immutable.
10
10
The concept of dictionary is also known as hash table or hash map in other languages or domains.
11
11
Sets and dictionaries in \python\ are implemented using similar datastructures~\cite{B2023T}, namely hash tables~\cite{K1998SAS,CLRS2009ITA,SKS2019DSC}, and thus exhibit similar performance.%
12
12
%
13
13
\begin{sloppypar}%
14
14
\cref{lst:dicts:dicts_1} shows some examples of how we can use dictionaries.
15
-
A dictionary can be created again using the \pythonilIdx{\{...\}} syntax, however, this time, we place comma-separated \pythonil{key-value} pairs within the curly braces.
15
+
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.
16
16
The type hints 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.
17
17
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}.
18
18
The type-hint of the variable states that it can point only to dictionaries that have integers as keys and strings as values.
@@ -60,8 +60,8 @@
60
60
%
61
61
\begin{sloppypar}%
62
62
As stated before, the types for keys and values in a dictionary can be chosen arbitrary, with the limitation that keys must be immutable.
63
-
We now create the empty dictionary \pythonil{str_num: dict[str, int] = \{\}}\pythonIdx{\{\}}\pythonIdx{dict!empty}.\footnote{%
64
-
Using the \pythonil{dict()}\pythonIdx{dict!empty} without arguments has the same effect, but several \pglspl{linter} discourage this and encourage using \pythonilIdx{\{\}} instead.%
63
+
We now create the empty dictionary \pythonil{str_num: dict[str, int] = \{\}}\pythonIdx{\textbraceleft\textbraceright}\pythonIdx{dict!empty}.\footnote{%
64
+
Using the \pythonil{dict()}\pythonIdx{dict!empty} without arguments has the same effect, but several \pglspl{linter} discourage this and encourage using \pythonil{\{\}}\pythonIdx{\textbraceleft\textbraceright} instead.%
65
65
}
66
66
Notice that only due to the type hint \pythonil{dict[str, int]}, other programmers and static type-checking tools can know at this point that we intend to use strings as keys and integers as values in this new dictionary.
67
67
The \pythonilIdx{update}\pythonIdx{dict!update} method allows us to append the values of an existing dictionary to a given dictionary.
A third example for using lists in \python: slicing, adding, and multiplying lists.}%
17
17
%
18
18
In \cref{lst:lists:lists_1}, we provide some first examples for using lists.
19
-
A list can be defined by simply writing its contents, separated by~\pythonilIdx{,} inside square brackets~\pythonilIdx{[...]}.
19
+
A list can be defined by simply writing its contents, separated by~\pythonilIdx{,} inside square brackets~\pythonil{[...]}\pythonIdx{[\idxdots]}.
20
20
\pythonil{["apple", "pear", "orange"]} creates a list with three elements, namely the strings \pythonil{"apple"}, \pythonil{"pear"}, and~\pythonil{"orange"}.
21
21
If we want to store a list in a variable, then we can use the type hint~\pythonil{list[elementType]}\pythonIdx{list!type hint} where \pythonil{elementType} is to be replaced with the type of the list elements.
22
22
\pythonil{fruits: list[str] = ["apple", "pear", "orange"]} therefore creates the list \pythonil{fruits} with the contents listed above.
@@ -104,7 +104,7 @@
104
104
105
105
In \cref{sec:strBasicOperations}, we discussed string slicing.
106
106
Lists can be sliced in pretty much the same way\pythonIdx{list!slicing}\pythonIdx{slicing}~\cite{PSF2024S}.
107
-
When slicing a list~\pythonil{l} or a string, you can provide either two or three values in the square brackets\pythonIdx{[...]}, i.e., either do~\pythonil{l[i:j]} or \pythonil{l[i:j:k]}.
107
+
When slicing a list~\pythonil{l} or a string, you can provide either two or three values in the square brackets\pythonIdx{[\idxdots]}\pythonIdx{[i:j:k]}, i.e., either do~\pythonil{l[i:j]}\pythonIdx{[i:j]}\pythonIdx{slicing} or \pythonil{l[i:j:k]}.
108
108
If \pythonil{j < 0}, then it is replaced with~\pythonil{len(l) - j}.
109
109
In both the two and three indices case, \pythonil{i} is the inclusive start index and \pythonil{j} is the exclusive end index, i.e., all elements with index~\pythonil{m} such that \pythonil{i <= m < j}.
110
110
In other words, the slice will contain elements from~\pythonil{l} whose index is between~\pythonil{i} and~\pythonil{j}, including the element at index~\pythonil{i} but \emph{not} including the element at index~\pythonil{j}.
A program processing lists which exhibits some subtle errors and inefficiencies.}
@@ -190,7 +191,7 @@
190
191
Each \python\ file should start with a string describing its purpose~\cite{PEP257}. %
191
192
This can either be a single line, like a headline, or a longer text. %
192
193
In the second case, the first line must be a headline, followed by an empty line, followed by the rest of the text. %
193
-
Either way, it must be a string delimited by~\pythonil{"""..."""}\pythonIdx{\textquotedbl\textquotedbl\textquotedbl}~\cite{PEP257,PEP8}.%
194
+
Either way, it must be a string delimited by~\pythonil{"""..."""}\pythonIdx{\textquotedbl\textquotedbl\textquotedbl\idxdots\textquotedbl\textquotedbl\textquotedbl}~\cite{PEP257,PEP8}.%
Copy file name to clipboardExpand all lines: text/main/basics/collections/sets/sets.tex
+1-1
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@
49
49
%
50
50
\begin{sloppypar}%
51
51
In \cref{lst:sets:sets_1}, we provide a first example for creating and working with sets.
52
-
Sets can be created by using curly braces, i.e, \pythonilIdx{\{...\}}.
52
+
Sets can be created by using curly braces, i.e, \pythonil{\{...\}}\pythonIdx{\textbraceleft\idxdots\textbraceright!set}.
53
53
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.
54
54
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"}.
55
55
The type hint~\pythonil{set[str]} states that this is a set that shall contain only strings.%
Copy file name to clipboardExpand all lines: text/main/basics/simpleDataTypesAndOperations/none/none.tex
+1-1
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@
15
15
16
16
\pythonilIdx{None} is used in scenarios where we want to specify that something does not have any value.
17
17
It is not an integer, float, string, or bool.
18
-
\pythonilIdx{None} is not equivalent to \pythonil{0}, it is not equivalent to~\pythonilIdx{nan}, and also different from the empty string~\pythonil{""}\pythonIdx{{\textquotedbl\textquotedbl}}.
18
+
\pythonilIdx{None} is not equivalent to \pythonil{0}, it is not equivalent to~\pythonilIdx{nan}, and also different from the empty string~\pythonil{""}\pythonIdx{\textquotedbl\textquotedbl}.
19
19
It is just nothing.
20
20
21
21
\cref{fig:none} illustrates some of the things we can do with \pythonilIdx{None}.
0 commit comments