diff -r 55342d3c9d25 -r 7c4855fb8e5f loops/quickref.tex --- a/loops/quickref.tex Mon Oct 11 01:25:45 2010 +0530 +++ b/loops/quickref.tex Mon Oct 11 11:40:04 2010 +0530 @@ -1,8 +1,16 @@ -Creating a linear array:\\ -{\ex \lstinline| x = linspace(0, 2*pi, 50)|} +\textbf{loops} + +To iterate over a sequence: \lstinline|for i in sequence:|\\ +\texttt{i} is the looping variable. + +To iterate while a condition is true: \lstinline|while condition:| -Plotting two variables:\\ -{\ex \lstinline| plot(x, sin(x))|} +Blocks in python are indented. To end block return to the previous +indentation. + +To break out of the innermost loop: \lstinline|break| -Plotting two lists of equal length x, y:\\ -{\ex \lstinline| plot(x, y)|} +To skip to end of current iteration: \lstinline|continue| + +\lstinline|pass| is just a syntactic filler. +