From 326867f1109539b087874c4d227ec7c408476b3a Mon Sep 17 00:00:00 2001 From: Prabhu Ramachandran Date: Mon, 30 Jan 2017 22:18:21 +0530 Subject: Minor fixes to slides. --- basic_python/control_flow.tex | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'basic_python/control_flow.tex') diff --git a/basic_python/control_flow.tex b/basic_python/control_flow.tex index a299563..373b1a6 100644 --- a/basic_python/control_flow.tex +++ b/basic_python/control_flow.tex @@ -82,14 +82,19 @@ else: \item \texttt{if-else} construct or the ternary operator \end{itemize} \begin{lstlisting} - In []: if score_str != 'AA': - .....: score = int(score_str) - .....: else: - .....: score = 0 +In []: if score_str != 'AA': +.....: score = int(score_str) +.....: else: +.....: score = 0 \end{lstlisting} +\end{frame} +\begin{frame}[fragile] + \frametitle{Ternary operator} + With the ternary operator you can do this: + \small \begin{lstlisting} - In []: ss = score_str - In []: score = int(ss) if ss != 'AA' else 0 +In []: ss = score_str +In []: score = int(ss) if ss != 'AA' else 0 \end{lstlisting} \end{frame} @@ -136,8 +141,8 @@ else: \pause \item Shift \typ{a, b} to next values \begin{itemize} - \item \typ{b = next} \item \typ{a = b} + \item \typ{b = next} \end{itemize} \pause \item Repeat steps 2, 3 when \typ{b < 30} -- cgit