conditionals/quickref.tex
author bhanu
Thu, 11 Nov 2010 02:16:07 +0530
changeset 477 0406115dccd1
parent 439 b437ff7def95
permissions -rw-r--r--
language check done for `matrices`
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
439
b437ff7def95 Changes to conditionals quickref.
Puneeth Chaganti <punchagan@fossee.in>
parents: 315
diff changeset
     1
Writing an if/elif/else block:
b437ff7def95 Changes to conditionals quickref.
Puneeth Chaganti <punchagan@fossee.in>
parents: 315
diff changeset
     2
\begin{lstlisting}
b437ff7def95 Changes to conditionals quickref.
Puneeth Chaganti <punchagan@fossee.in>
parents: 315
diff changeset
     3
if condition1:
b437ff7def95 Changes to conditionals quickref.
Puneeth Chaganti <punchagan@fossee.in>
parents: 315
diff changeset
     4
   # do A, B, C
b437ff7def95 Changes to conditionals quickref.
Puneeth Chaganti <punchagan@fossee.in>
parents: 315
diff changeset
     5
elif condition2:
b437ff7def95 Changes to conditionals quickref.
Puneeth Chaganti <punchagan@fossee.in>
parents: 315
diff changeset
     6
   # do D, E
b437ff7def95 Changes to conditionals quickref.
Puneeth Chaganti <punchagan@fossee.in>
parents: 315
diff changeset
     7
else:
b437ff7def95 Changes to conditionals quickref.
Puneeth Chaganti <punchagan@fossee.in>
parents: 315
diff changeset
     8
   # do Y, Z
b437ff7def95 Changes to conditionals quickref.
Puneeth Chaganti <punchagan@fossee.in>
parents: 315
diff changeset
     9
\end{lstlisting}
315
7944a4504769 Conditionals LO - script and questions.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    10
439
b437ff7def95 Changes to conditionals quickref.
Puneeth Chaganti <punchagan@fossee.in>
parents: 315
diff changeset
    11
The ternary operator:
b437ff7def95 Changes to conditionals quickref.
Puneeth Chaganti <punchagan@fossee.in>
parents: 315
diff changeset
    12
{\ex \lstinline|    C if X else Y|} -- Do C if X is True else do Y.