From ff2505f6e0e274272827f39f2501bb1ff0e7df8a Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Wed, 10 Nov 2010 13:30:25 +0530 Subject: Changes to conditionals quickref. --- conditionals/quickref.tex | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/conditionals/quickref.tex b/conditionals/quickref.tex index b26d168..2f169a4 100644 --- a/conditionals/quickref.tex +++ b/conditionals/quickref.tex @@ -1,8 +1,12 @@ -Creating a linear array:\\ -{\ex \lstinline| x = linspace(0, 2*pi, 50)|} +Writing an if/elif/else block: +\begin{lstlisting} +if condition1: + # do A, B, C +elif condition2: + # do D, E +else: + # do Y, Z +\end{lstlisting} -Plotting two variables:\\ -{\ex \lstinline| plot(x, sin(x))|} - -Plotting two lists of equal length x, y:\\ -{\ex \lstinline| plot(x, y)|} +The ternary operator: +{\ex \lstinline| C if X else Y|} -- Do C if X is True else do Y. -- cgit