equal
deleted
inserted
replaced
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)|} |
|