# HG changeset patch # User Puneeth Chaganti # Date 1289376025 -19800 # Node ID b437ff7def954a24208c28ce60857f0da44b9275 # Parent 4523b20486630ed55c6ba62e0629bdd7f1c667c4 Changes to conditionals quickref. diff -r 4523b2048663 -r b437ff7def95 conditionals/quickref.tex --- a/conditionals/quickref.tex Wed Nov 10 13:25:46 2010 +0530 +++ b/conditionals/quickref.tex Wed Nov 10 13:30:25 2010 +0530 @@ -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.