Skip to content

Commit 9d4ddb5

Browse files
committed
Add the slides about the quadratic equation to the cs102-week-three.tex.
1 parent 0c77c86 commit 9d4ddb5

File tree

1 file changed

+71
-4
lines changed

1 file changed

+71
-4
lines changed

cs102-week-three.tex

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
\definecolor{blue}{RGB}{0, 118, 186}
3030
\definecolor{gray}{RGB}{146, 146, 146}
3131

32-
\title{Discrete Structures: \\ Basics of Mathematics and Programming}
32+
\title{Discrete Structures: \\ Computational and Mathematical Tasks in Python}
3333

3434
\author{{\bf Gregory M. Kapfhammer}}
3535

@@ -109,7 +109,7 @@
109109
% Slide
110110
%
111111
\begin{frame}[fragile]
112-
\frametitle{Using Python to Find a Name in a File}
112+
\frametitle{Python Programs are Sequences of Statements}
113113
\normalsize
114114
\hspace*{-.65in}
115115
\begin{minipage}{6in}
@@ -136,7 +136,7 @@
136136
% Slide
137137
%
138138
\begin{frame}[fragile]
139-
\frametitle{Using Python to Average Numerical Values}
139+
\frametitle{Simple and Compound Statements in Python}
140140
\hspace*{-.6in}
141141
\begin{minipage}{6in}
142142
\begin{minted}[mathescape, numbersep=5pt, fontsize=\large]{python}
@@ -154,7 +154,7 @@
154154

155155
% Slide
156156
%
157-
\begin{frame}{Enhancing Python Programs}
157+
\begin{frame}{Industry-Standard Python Programming}
158158
%
159159
\begin{itemize}
160160
%
@@ -190,4 +190,71 @@
190190
%
191191
\end{frame}
192192

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+
193260
\end{document}

0 commit comments

Comments
 (0)