Added lists and for slides to session 2, day 1.
authorSantosh G. Vattam <vattam.santosh@gmail.com>
Fri, 23 Oct 2009 16:59:50 +0530
changeset 158 978108b0c02c
parent 155 069a9aed1027
child 159 01f57cda252f
Added lists and for slides to session 2, day 1.
day1/session2.tex
--- a/day1/session2.tex	Fri Oct 23 16:16:10 2009 +0530
+++ b/day1/session2.tex	Fri Oct 23 16:59:50 2009 +0530
@@ -201,7 +201,75 @@
 \end{itemize}
 \end{frame}
 
+\begin{frame}[fragile]
+\frametitle{Plotting \it{L} vs \it{T^2}}
+\begin{lstlisting}
+In []: TSq = []
 
+In []: for t in T:
+ ....:     TSq.append(t*t)
+
+In []: plot(L, TSq, '.')
+Out[]: [<matplotlib.lines.Line2D object at 0xa5b05ac>]
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}{So what did we learn here??}
+  \begin{itemize}
+    \item lists
+    \item \alert{\kwrd{for}}
+  \end{itemize}
+\end{frame}
+
+\section{Lists}
+\begin{frame}[fragile]
+  \frametitle{How to create and use lists?}
+\begin{lstlisting}
+In []: lst = [1,2,3,4] 
+
+In []: lst[0]+lst[1]+lst[-1]
+Out[]: 7
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{List: Slicing}
+  \typ{list[initial:final:step]}
+\begin{lstlisting}
+In []: lst[1:3]  # A slice.
+Out[]: [2, 3]
+
+In []: lst[1:-1]
+Out[]: [2, 3]
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{List methods}
+\begin{lstlisting}
+In []: lst.append([6,7])
+In []: lst
+Out[]: [1, 2, 3, 4, 5, [6, 7]]
+\end{lstlisting}
+%\inctime{10}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{\typ{for}}
+Used to iterate over lists\\ Let us look at another example.
+\begin{lstlisting}
+In []: lst = [1,2,3,4,5,6]
+In []: for num in lst:
+ ....:     print num, num*num
+ ....:    
+1 1
+2 4
+3 9
+4 16
+5 25
+6 36
+\end{lstlisting}
+\end{frame}
 
 \section{File Handling}
 \begin{frame}[fragile]
@@ -240,42 +308,5 @@
 
 \section{Plotting points}
 
-\section{Lists}
-
-\begin{frame}[fragile]
-  \frametitle{List creation and indexing}
-\begin{lstlisting}
-In []: lst = [1,2,3,4] 
-
-In []: lst[0]+lst[1]+lst[-1]
-Out[]: 7
-\end{lstlisting}
-\begin{itemize}
-  \item Indices start with ?
-  \item Negative indices indicate ?
-  \end{itemize}
-\end{frame}
-
-\begin{frame}[fragile]
-  \frametitle{List: slices}
-  \typ{list[initial:final:step]}
-\begin{lstlisting}
-In []: lst[1:3]  # A slice.
-Out[]: [2, 3]
-
-In []: lst[1:-1]
-Out[]: [2, 3]
-\end{lstlisting}
-\end{frame}
-
-\begin{frame}[fragile]
-  \frametitle{List methods}
-\begin{lstlisting}
-In []: lst.append([6,7])
-In []: lst
-Out[]: [1, 2, 3, 4, 5, [6, 7]]
-\end{lstlisting}
-\inctime{10}
-\end{frame}
 
 \end{document}