From 98aafc8888970c0dc6da22cfb057c103334065ed Mon Sep 17 00:00:00 2001 From: Puneeth Chaganti Date: Mon, 11 Oct 2010 11:40:04 +0530 Subject: Quickrefs --- loops/quickref.tex | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'loops/quickref.tex') diff --git a/loops/quickref.tex b/loops/quickref.tex index b26d168..e0b8d61 100644 --- a/loops/quickref.tex +++ b/loops/quickref.tex @@ -1,8 +1,16 @@ -Creating a linear array:\\ -{\ex \lstinline| x = linspace(0, 2*pi, 50)|} +\textbf{loops} -Plotting two variables:\\ -{\ex \lstinline| plot(x, sin(x))|} +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:| + +Blocks in python are indented. To end block return to the previous +indentation. + +To break out of the innermost loop: \lstinline|break| + +To skip to end of current iteration: \lstinline|continue| + +\lstinline|pass| is just a syntactic filler. -Plotting two lists of equal length x, y:\\ -{\ex \lstinline| plot(x, y)|} -- cgit