|
116 | 116 | \begin{sloppypar}%
|
117 | 117 | We can use \pythonil{int_var} just like any other value.
|
118 | 118 | For example, we can compute \pythonil{2 + int_var} and pass the result to the \pythonilIdx{print} function.
|
119 |
| -This will then print \pythonil{3} to the standard output of our program. |
| 119 | +This will then print \pythonil{3} to the \pgls{stdout} of our program. |
120 | 120 | We can also use \pythonil{int_var} in \pglspl{fstring}\pythonIdx{f-string}\pythonIdx{str!f} about which we leared back in \cref{sec:fstrings}.
|
121 | 121 | \pythonil{f"int_var has value \{int_var\}."} will render to \pythonil{"int_var has value 1."}.%
|
122 | 122 | \end{sloppypar}%
|
|
128 | 128 | In this computation, the current (old) value of \pythonil{int_var} is used.
|
129 | 129 | It therefore corresponds to computing \pythonil{(3 * 1) + 1}, which equals~\pythonil{4}.
|
130 | 130 | This value is stored somewhere in memory and \pythonil{int_var} points to it.
|
131 |
| -Doing \pythonil{print(f"int_var is now \{int_var\}.")} will print \textil{int_var is now 4.} to the standard output. |
| 131 | +Doing \pythonil{print(f"int_var is now \{int_var\}.")} will print \textil{int_var is now 4.} to the \pgls{stdout}. |
132 | 132 | The value \pythonil{1} is now no longer referenced.
|
133 | 133 | Eventually, the \python\ interpreter could free the corresponding memory to use it for something else.
|
134 | 134 |
|
|
145 | 145 | Finally, \pythonil{print(f"new_var = \{new_var\}." )} then prints \textil{new_var = 14.0.}.%
|
146 | 146 | \end{sloppypar}%
|
147 | 147 | %
|
148 |
| -The standard output of the complete program is given in \cref{exec:variables:assignment}. |
| 148 | +The \acrfull{stdout} of the complete program is given in \cref{exec:variables:assignment}. |
149 | 149 | For your convenience, we also showed the results when executing the program in \pycharm\ or the \ubuntu\ \pgls{terminal} in \cref{fig:variables:assignment}.
|
150 | 150 | They are obviously identical.
|
151 | 151 |
|
|
279 | 279 | 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.
|
280 | 280 | We compute \pythonil{s = sqrt(2 - sqrt(4 - (s ** 2)))}\pythonIdx{sqrt} having imported\pythonIdx{import} the \pythonilIdx{sqrt} function from the \pythonilIdx{math} module.
|
281 | 281 | We print the approximated value of~\numberPi\ as \pythonil{e * s / 2}.
|
282 |
| -Notice how elegantly we use the unicode characters~$\pi$ and~$\approx$ via the escapes~\pythonil{\\u03c0} and \pythonil{\\u2248}\pythonIdx{\textbackslash{u}}, respectively, from back in~\cref{sec:unicodeChars} (and how nicely it indeed prints the greek character~$\pi$ in the standard output in \cref{exec:variables:pi_liu_hui}). |
| 282 | +Notice how elegantly we use the unicode characters~$\pi$ and~$\approx$ via the escapes~\pythonil{\\u03c0} and \pythonil{\\u2248}\pythonIdx{\textbackslash{u}}, respectively, from back in~\cref{sec:unicodeChars} (and how nicely it indeed prints the greek character~$\pi$ in the \pgls{stdout} in \cref{exec:variables:pi_liu_hui}). |
283 | 283 | Either way, since \cref{eq:liuhui:sidelength,eq:liuhui:approx} are always the same, we can simply copy-paste the lines of code for updating~\pythonil{s}, \pythonil{e}, and printing the approximated value of~\numberPi\ several times.
|
284 | 284 |
|
285 |
| -\Cref{exec:variables:pi_liu_hui} shows the standard output produced by this program. |
| 285 | +\Cref{exec:variables:pi_liu_hui} shows the \acrfull{stdout} produced by this program. |
286 | 286 | Indeed, each new approximation comes closer to~\numberPi.
|
287 | 287 | For 192~edges, we get the approximation~\pythonil{3.1414524722853443}.
|
288 | 288 | Given that the constant~\pythonilIdx{pi} from the \pythonilIdx{math} module is \pythonil{3.141592653589793}, we find that the first four digits are correct and that the number is only off by only 0.0045\%!
|
|
0 commit comments