|
29 | 29 | \definecolor{blue}{RGB}{0, 118, 186} |
30 | 30 | \definecolor{gray}{RGB}{146, 146, 146} |
31 | 31 |
|
32 | | -\title{Discrete Structures: \\ Basics of Mathematics and Programming} |
| 32 | +\title{Discrete Structures: \\ Computational and Mathematical Tasks in Python} |
33 | 33 |
|
34 | 34 | \author{{\bf Gregory M. Kapfhammer}} |
35 | 35 |
|
|
109 | 109 | % Slide |
110 | 110 | % |
111 | 111 | \begin{frame}[fragile] |
112 | | - \frametitle{Using Python to Find a Name in a File} |
| 112 | + \frametitle{Python Programs are Sequences of Statements} |
113 | 113 | \normalsize |
114 | 114 | \hspace*{-.65in} |
115 | 115 | \begin{minipage}{6in} |
|
136 | 136 | % Slide |
137 | 137 | % |
138 | 138 | \begin{frame}[fragile] |
139 | | - \frametitle{Using Python to Average Numerical Values} |
| 139 | + \frametitle{Simple and Compound Statements in Python} |
140 | 140 | \hspace*{-.6in} |
141 | 141 | \begin{minipage}{6in} |
142 | 142 | \begin{minted}[mathescape, numbersep=5pt, fontsize=\large]{python} |
|
154 | 154 |
|
155 | 155 | % Slide |
156 | 156 | % |
157 | | -\begin{frame}{Enhancing Python Programs} |
| 157 | +\begin{frame}{Industry-Standard Python Programming} |
158 | 158 | % |
159 | 159 | \begin{itemize} |
160 | 160 | % |
|
190 | 190 | % |
191 | 191 | \end{frame} |
192 | 192 |
|
| 193 | +% Slide |
| 194 | +% |
| 195 | +\begin{frame}[fragile] |
| 196 | + \frametitle{Command-Line Interfaces for Python Programs} |
| 197 | + \normalsize |
| 198 | + \hspace*{-.15in} |
| 199 | + \begin{minipage}{6in} |
| 200 | + \vspace*{.15in} |
| 201 | + \begin{minted}[mathescape, numbersep=5pt, fontsize=\footnotesize]{python} |
| 202 | +def main( |
| 203 | + a: float = typer.Option(1), |
| 204 | + b: float = typer.Option(2), |
| 205 | + c: float = typer.Option(2) |
| 206 | +): |
| 207 | + """Calculate roots of a quadratic eqn with quadratic formula.""" |
| 208 | + typer.echo(f"Calculating the roots of a quadratic equation with:") |
| 209 | + typer.echo(f" a = {a}") |
| 210 | + typer.echo(f" b = {b}") |
| 211 | + typer.echo(f" c = {c}") |
| 212 | + x_one, x_two = rootfind.calculate_quadratic_equation_roots(a, b, c) |
| 213 | + typer.echo(f" x_one = {x_one}") |
| 214 | + typer.echo(f" x_two = {x_two}") |
| 215 | + |
| 216 | +if __name__ == "__main__": |
| 217 | + typer.run(main) |
| 218 | + \end{minted} |
| 219 | + \end{minipage} |
| 220 | + % |
| 221 | + \vspace*{.05in} |
| 222 | + % |
| 223 | + \begin{center} |
| 224 | + % |
| 225 | + \normalsize \noindent This program can accept user input through the command line \\ |
| 226 | + % |
| 227 | + \end{center} |
| 228 | + % |
| 229 | +\end{frame} |
| 230 | + |
| 231 | +% Slide |
| 232 | +% |
| 233 | +\begin{frame}[fragile] |
| 234 | + \frametitle{Calculating the Roots of a Quadratic Function} |
| 235 | + \hspace*{-.2in} |
| 236 | + \begin{minipage}{6in} |
| 237 | + \begin{minted}[mathescape, numbersep=5pt, fontsize=\small]{python} |
| 238 | +def calc_quad_eqn_roots(a: float, b: float, c: float): |
| 239 | + """Calculate the roots of a quadratic equation.""" |
| 240 | + D = (b * b - 4 * a * c) ** 0.5 |
| 241 | + x_one = (-b + D) / (2 * a) |
| 242 | + x_two = (-b - D) / (2 * a) |
| 243 | + return x_one, x_two |
| 244 | + \end{minted} |
| 245 | + \end{minipage} |
| 246 | + % |
| 247 | + \vspace*{.05in} |
| 248 | + % |
| 249 | + \begin{center} |
| 250 | + % |
| 251 | + \normalsize \noindent {\bf Input}: three floating-point inputs called {\tt a}, {\tt b}, and {\tt c}\\ |
| 252 | + \normalsize \noindent {\bf Output}: two floating-point outputs called {\tt x\_one} and {\tt x\_two}\\ |
| 253 | + \normalsize \noindent {\bf Behavior}: calculate the roots of a quadratic equation\\ |
| 254 | + \normalsize \noindent {\bf Question}: how does this function work? how would you test it? |
| 255 | + % |
| 256 | + \end{center} |
| 257 | + % |
| 258 | +\end{frame} |
| 259 | + |
193 | 260 | \end{document} |
0 commit comments