conditionals/quickref.tex
changeset 439 b437ff7def95
parent 315 7944a4504769
equal deleted inserted replaced
438:4523b2048663 439:b437ff7def95
     1 Creating a linear array:\\
     1 Writing an if/elif/else block:
     2 {\ex \lstinline|    x = linspace(0, 2*pi, 50)|}
     2 \begin{lstlisting}
       
     3 if condition1:
       
     4    # do A, B, C
       
     5 elif condition2:
       
     6    # do D, E
       
     7 else:
       
     8    # do Y, Z
       
     9 \end{lstlisting}
     3 
    10 
     4 Plotting two variables:\\
    11 The ternary operator:
     5 {\ex \lstinline|    plot(x, sin(x))|}
    12 {\ex \lstinline|    C if X else Y|} -- Do C if X is True else do Y. 
     6 
       
     7 Plotting two lists of equal length x, y:\\
       
     8 {\ex \lstinline|    plot(x, y)|}