|
96 | 96 | \centering% |
97 | 97 | % |
98 | 98 | \subfloat[][% |
99 | | -The file \textil{assignment.py} opened in \pycharm.% |
| 99 | +The file \programUrl{variables:assignment} opened in \pycharm.% |
100 | 100 | \label{fig:assignmentPyCharm1}% |
101 | 101 | ]{% |
102 | 102 | \tightbox{\includegraphics[width=0.49\linewidth]{\currentDir/assignmentPyCharm1}}% |
103 | 103 | }% |
104 | 104 | \hfill% |
105 | 105 | % |
106 | 106 | \subfloat[][% |
107 | | -Left-clicking on \menu{Run `assignment'} in the pop-up menu after right-clicking on \textil{assignment.py}, or directly pressing \keys{\ctrl+\shift+F10}, to run the program.% |
| 107 | +Left-clicking on \menu{Run `assignment'} in the pop-up menu after right-clicking on \programUrl{variables:assignment}, or directly pressing \keys{\ctrl+\shift+F10}, to run the program.% |
108 | 108 | \label{fig:assignmentPyCharm2}% |
109 | 109 | ]{% |
110 | 110 | \tightbox{\includegraphics[width=0.49\linewidth]{\currentDir/assignmentPyCharm2}}% |
111 | 111 | }% |
112 | 112 | \\% |
113 | 113 | % |
114 | 114 | \subfloat[][% |
115 | | -The output of the program \textil{assignment.py} in \pycharm.% |
| 115 | +The output of the program \programUrl{variables:assignment} in \pycharm.% |
116 | 116 | \label{fig:assignmentPyCharm3}% |
117 | 117 | ]{% |
118 | 118 | \tightbox{\includegraphics[width=0.7\linewidth]{\currentDir/assignmentPyCharm3}}% |
119 | 119 | }% |
120 | 120 | \\% |
121 | 121 | % |
122 | 122 | \subfloat[][% |
123 | | -The output of the program \textil{assignment.py} in the \ubuntu\ \pgls{terminal} (which you can open via~\ubuntuTerminal).% |
| 123 | +The output of the program \programUrl{variables:assignment} in the \ubuntu\ \pgls{terminal} (which you can open via~\ubuntuTerminal).% |
124 | 124 | \label{fig:assignmentTerminal}% |
125 | 125 | ]{% |
126 | 126 | \includegraphics[width=0.7\linewidth]{\currentDir/assignmentTerminal}% |
127 | 127 | }% |
128 | 128 | % |
129 | | -\caption{Running the program \textil{assignment.py} from \cref{lst:variables:assignment} in \pycharm~(\cref{fig:assignmentPyCharm1,fig:assignmentPyCharm2,fig:assignmentPyCharm3}) or the \ubuntu\ \pgls{terminal}~(\cref{fig:assignmentTerminal}).}% |
| 129 | +\caption{Running the program \programUrl{variables:assignment} from \cref{lst:variables:assignment} in \pycharm~(\cref{fig:assignmentPyCharm1,fig:assignmentPyCharm2,fig:assignmentPyCharm3}) or the \ubuntu\ \pgls{terminal}~(\cref{fig:assignmentTerminal}).}% |
130 | 130 | \label{fig:variables:assignment}% |
131 | 131 | \end{figure}% |
132 | 132 | % |
|
172 | 172 | (Do you remember a method, to get this output even more easily?)% |
173 | 173 | \end{sloppypar}% |
174 | 174 | % |
175 | | -This first program is stored in a file named~\textil{assignment.py}. |
| 175 | +This first program is stored in a file named~\programUrl{variables:assignment}. |
176 | 176 | To execute it, you have two choices: |
177 | 177 | You can do this in the \pgls{terminal} or using \pycharm.% |
178 | 178 | % |
179 | 179 | \begin{sloppypar}% |
180 | 180 | Under \ubuntu\ \linux, you open the \pgls{terminal} by pressing \ubuntuTerminal, under \microsoftWindows\ you instead \windowsTerminal. |
181 | | -Then you enter the folder where the program \textil{assignment.py} is stored using the command~\bashil{cd}. |
| 181 | +Then you enter the folder where the program \programUrl{variables:assignment} is stored using the command~\bashil{cd}. |
182 | 182 | Then you would execute the command~\bashil{python3 assignment.py} to run the \python\ interpreter, as illustrated in \cref{fig:assignmentTerminal}.% |
183 | 183 | \end{sloppypar}% |
184 | 184 | % |
185 | 185 | Alternatively, you can open the program file in \pycharm\ \pgls{ide}, as sketched in \cref{fig:assignmentPyCharm1}. |
186 | | -You would then right-click on the file \textil{assignment.py} in the project tree view. |
| 186 | +You would then right-click on the file \programUrl{variables:assignment} in the project tree view. |
187 | 187 | In the popup-menu that opens, you would left-click on \menu{Run `assignment'} as shown in \cref{fig:assignmentPyCharm2}. |
188 | 188 | As a shortcut, you can also simply press~\keys{\ctrl+\shift+F10}. |
189 | 189 | Either way, \pycharm\ will run the program and the output appears in \cref{fig:assignmentPyCharm3}. |
|
361 | 361 | Now that we have learned some programming, we do no longer need to type the numbers and computation steps into a calculator. |
362 | 362 | We also do not need to use \python\ as calculator. |
363 | 363 | Instead, we can enter all the commands needed for the computation into a program file. |
364 | | -We will call it~\textil{pi_liu_hui.py}, as illustrated in \cref{lst:variables:pi_liu_hui}. |
| 364 | +We will call it~\programUrl{variables:pi_liu_hui}, as illustrated in \cref{lst:variables:pi_liu_hui}. |
365 | 365 |
|
366 | 366 | We begin by setting the initial number of edges \pythonil{e = 6} and the initial side length of the $e$\nobreakdashes-gon to \pythonil{s = 1}, because we still keep with the choice of~$\liuhuir=1$. |
367 | 367 | In each iteration of the approximation, we simply set \pythonil{e *= 2}\pythonIdx{*=}, which is equivalent to \pythonil{e = e * 2}, to double the number of edges. |
|
377 | 377 |
|
378 | 378 | For your convenience, we also showed the results when executing the program in \pycharm\ or the \ubuntu\ \pgls{terminal} in \cref{fig:variables:liuHuiPi}. |
379 | 379 | To open a \pgls{terminal} under \ubuntu\ \linux, you would press~\ubuntuTerminal, whereas under \microsoftWindows, you~\windowsTerminal. |
380 | | -With the command \bashil{cd}, you would enter the directory where our program \textil{pi_liu_hui.py} is located. |
| 380 | +With the command \bashil{cd}, you would enter the directory where our program \programUrl{variables:pi_liu_hui} is located. |
381 | 381 | You would then type in \bashil{python3 pi_liu_hui.py} and hit~\keys{\enter}. |
382 | 382 | As you can see in \cref{fig:liuHuiPiTerminal}, you will get the same output as given in \cref{exec:variables:pi_liu_hui}. |
383 | 383 |
|
|
0 commit comments