|
7 | 7 | % |
8 | 8 | \subfloat[][% |
9 | 9 | Open a \pgls{terminal} (by pressing \ubuntuTerminal\ under \ubuntu\ \linux; under \microsoftWindows\ \windowsTerminal). % |
10 | | -Change into the directory \inQuotes{directory} where your \python\ file is located, by typing \bashil{cd directory} and hit \keys{\enter}. % |
| 10 | +Change into the directory \inQuotes{directory} where your \python\ file is located, by typing \bashil{cd directory} and hit \keys{\return}. % |
11 | 11 | (I here had it in the temporary directory \bashil{/tmp}, you will have it elsewhere\dots)% |
12 | 12 | \label{fig:terminalPython1cd}% |
13 | 13 | ]{\includegraphics[width=0.9\linewidth]{\currentDir/terminalPython1cd}}% |
|
22 | 22 | \floatRowSep% |
23 | 23 | % |
24 | 24 | \subfloat[][% |
25 | | -Execute a \python\ program \inQuotes{program.py} by typing \bashil{python3 program.py} and hit \keys{\enter}. % |
| 25 | +Execute a \python\ program \inQuotes{program.py} by typing \bashil{python3 program.py} and hit \keys{\return}. % |
26 | 26 | In our case, the program is \inQuotes{very\_first\_program.py}.% |
27 | 27 | \label{fig:terminalPython3python}% |
28 | 28 | ]{\includegraphics[width=0.9\linewidth]{\currentDir/terminalPython3python}}% |
|
61 | 61 | \centering% |
62 | 62 | % |
63 | 63 | \subfloat[][% |
64 | | -We enter the \inQuotes{Hello World!} program from \cref{lst:very_first_program} and press \keys{\enter}.% |
| 64 | +We enter the \inQuotes{Hello World!} program from \cref{lst:very_first_program} and press \keys{\return}.% |
65 | 65 | \label{fig:pycharmConsole3writingCode}% |
66 | 66 | ]{\tightbox{\includegraphics[width=0.76\linewidth]{\currentDir/pycharmConsole3writingCode}}}% |
67 | 67 | % |
|
80 | 80 | \centering% |
81 | 81 | % |
82 | 82 | \subfloat[][% |
83 | | -Open a \pgls{terminal} (by pressing \ubuntuTerminal\ under \ubuntu\ \linux; under \microsoftWindows\ \windowsTerminal), enter \bashil{python3}, then hit \keys{\enter}.% |
| 83 | +Open a \pgls{terminal} (by pressing \ubuntuTerminal\ under \ubuntu\ \linux; under \microsoftWindows\ \windowsTerminal), enter \bashil{python3}, then hit \keys{\return}.% |
84 | 84 | \label{fig:terminalConsole1python}% |
85 | 85 | ]{\includegraphics[width=0.852\linewidth]{\currentDir/terminalConsole1python}}% |
86 | 86 | % |
|
94 | 94 | \floatRowSep% |
95 | 95 | % |
96 | 96 | \subfloat[][% |
97 | | -We enter the \inQuotes{Hello World!} program from \cref{lst:very_first_program} and press \keys{\enter}.% |
| 97 | +We enter the \inQuotes{Hello World!} program from \cref{lst:very_first_program} and press \keys{\return}.% |
98 | 98 | \label{fig:terminalConsole3writingCode}% |
99 | 99 | ]{\includegraphics[width=0.852\linewidth]{\currentDir/terminalConsole3writingCode}}% |
100 | 100 | % |
|
113 | 113 | \centering% |
114 | 114 | % |
115 | 115 | \subfloat[][% |
116 | | -We exit the console by typing \pythonil{exit()}\pythonIdx{exit} and pressing \keys{\enter}.% |
| 116 | +We exit the console by typing \pythonil{exit()}\pythonIdx{exit} and pressing \keys{\return}.% |
117 | 117 | \label{fig:terminalConsole5exit}% |
118 | 118 | ]{\includegraphics[width=0.852\linewidth]{\currentDir/terminalConsole5exit}}% |
119 | 119 | % |
|
137 | 137 | % |
138 | 138 | \item Actually, we can also write a \python\ program with a normal text editor. % |
139 | 139 | A \python\ program is just a normal text file, after all. % |
140 | | -We can execute such a text file by entering its directory and typing \bashil{python3 programName} (where \bashil{programName} is \bashil{very_first_program.py}, in our case) and hitting \keys{\enter}. % |
| 140 | +We can execute such a text file by entering its directory and typing \bashil{python3 programName} (where \bashil{programName} is \bashil{very_first_program.py}, in our case) and hitting \keys{\return}. % |
141 | 141 | Then the program is executed directly in the \pgls{terminal}. % |
142 | 142 | This process is shown in \cref{sec:terminalPython,fig:terminalPython}.% |
143 | 143 | % |
|
156 | 156 | Under \ubuntu\ \linux, we simply press \ubuntuTerminal. |
157 | 157 | Under \microsoftWindows, we have to \windowsTerminal. |
158 | 158 | Once the terminal is open, we need to change into the directory where the program is located. |
159 | | -Under both \linux\ and \microsoftWindows, this can be done by typing the command \bashil{cd}, followed by the path to the directory, and hitting \keys{\enter}.\footnote{% |
| 159 | +Under both \linux\ and \microsoftWindows, this can be done by typing the command \bashil{cd}, followed by the path to the directory, and hitting \keys{\return}.\footnote{% |
160 | 160 | Under \microsoftWindows, you may also need to change into the correct drive first.} |
161 | 161 | We provide a screenshot for that, taken under \ubuntu\ \linux, in \cref{fig:terminalPython1cd}. |
162 | 162 | Now we simply call the \python\ interpreter by writing \bashil{python3} followed by the file name of our program, which is \bashil{very_first_program.py} in our case. |
163 | | -In \cref{fig:terminalPython3python} we do this and hit \keys{\enter}, which causes the \python\ interpreter to execute our program. |
| 163 | +In \cref{fig:terminalPython3python} we do this and hit \keys{\return}, which causes the \python\ interpreter to execute our program. |
164 | 164 | The output \inQuotes{Hello World!} is then printed into the \pgls{terminal} in \cref{fig:terminalPython4result}.% |
165 | 165 | \endhsection% |
166 | 166 | % |
|
176 | 176 | This directly brings us to the \python\ console~(\cref{fig:pycharmConsole2consoleOpen}). |
177 | 177 | We can enter the one-line-program from \cref{lst:very_first_program}, as illustrated in \cref{fig:pycharmConsole3writingCode}. |
178 | 178 | Notice that the input prompt of the console is marked by the three greater characters \bashil{>>>} after which we enter our text. |
179 | | -Pressing \keys{\enter} after writing the code leads to the expected output shown in \cref{fig:pycharmConsole4codeOutput}. |
| 179 | +Pressing \keys{\return} after writing the code leads to the expected output shown in \cref{fig:pycharmConsole4codeOutput}. |
180 | 180 | This output directly appears in the console and is not preceded by any other text, in particular not by \bashil{>>>}, which makes it easy to visually distinguish what the input and output in a \python\ console are.% |
181 | 181 | \endhsection% |
182 | 182 | % |
|
186 | 186 | We therefore first need to open a normal terminal. |
187 | 187 | Under \ubuntu\ \linux, we simply press \ubuntuTerminal. |
188 | 188 | Under \microsoftWindows, we have to \windowsTerminal. |
189 | | -Either way, the terminal opens and we can enter \bashil{python3} and press \keys{\enter}, as shown in \cref{fig:terminalConsole1python}. |
| 189 | +Either way, the terminal opens and we can enter \bashil{python3} and press \keys{\return}, as shown in \cref{fig:terminalConsole1python}. |
190 | 190 | Now the \python\ interpreter starts right inside the \pgls{terminal}~(\cref{fig:terminalConsole2pythonRunning}). |
191 | 191 | The prompt, i.e., the place where we can write our code, again is preceded by the \bashil{>>>} characters. |
192 | | -As illustrated in \cref{fig:terminalConsole3writingCode}, we copy the single line of code, \pythonil{print("Hello World!")}\pythonIdx{print} from \cref{lst:very_first_program} and press \keys{\enter}. |
| 192 | +As illustrated in \cref{fig:terminalConsole3writingCode}, we copy the single line of code, \pythonil{print("Hello World!")}\pythonIdx{print} from \cref{lst:very_first_program} and press \keys{\return}. |
193 | 193 | The output \inQuotes{Hello World!} is printed as expected in \cref{fig:terminalConsole4codeOutput}. |
194 | 194 | However, we now are still in the \python\ interpreter. |
195 | 195 | In order to leave it and to, maybe, enter other commands in the \pgls{terminal}, we have to use another new \python\ instruction: |
196 | | -We type in \pythonil{exit()} and press \keys{\enter}, as shown in \cref{fig:terminalConsole5exit}, which causes the \python\ interpreter to exit. |
| 196 | +We type in \pythonil{exit()} and press \keys{\return}, as shown in \cref{fig:terminalConsole5exit}, which causes the \python\ interpreter to exit. |
197 | 197 | We are now back in the basic terminal, as shown in \cref{fig:terminalConsole6left}. |
198 | 198 | In these figures, I was using \ubuntu\ \linux. |
199 | 199 | On \microsoftWindows\ or other \linux\ variants, the process would have looked quite similar.% |
|
0 commit comments