diff options
author | Santosh G. Vattam | 2009-10-23 16:59:50 +0530 |
---|---|---|
committer | Santosh G. Vattam | 2009-10-23 16:59:50 +0530 |
commit | 8a98d3d494cf93f5f04d5a79a4a82d3fcaf541fd (patch) | |
tree | e6b63a91e5ce5cef1759c560fbfd1133d83763da /day1 | |
parent | e8fda67c5ae28ab82449487ac3b18395de3f8012 (diff) | |
download | workshops-more-scipy-8a98d3d494cf93f5f04d5a79a4a82d3fcaf541fd.tar.gz workshops-more-scipy-8a98d3d494cf93f5f04d5a79a4a82d3fcaf541fd.tar.bz2 workshops-more-scipy-8a98d3d494cf93f5f04d5a79a4a82d3fcaf541fd.zip |
Added lists and for slides to session 2, day 1.
Diffstat (limited to 'day1')
-rw-r--r-- | day1/session2.tex | 105 |
1 files changed, 68 insertions, 37 deletions
diff --git a/day1/session2.tex b/day1/session2.tex index d5d96c7..c0dbcf1 100644 --- a/day1/session2.tex +++ b/day1/session2.tex @@ -201,7 +201,75 @@ In []: T = [0.6529, 0.8485, 1.0590, \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 @@ Out[]: ['KD', 'MCS', 'PC', 'SC', 'SV'] \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} |