diff options
author | Madhusudan.C.S | 2009-10-26 12:41:40 +0530 |
---|---|---|
committer | Madhusudan.C.S | 2009-10-26 12:41:40 +0530 |
commit | eca0584cda052a7eaa2935add6d9a8979d17d0af (patch) | |
tree | 1ccde7a5a4bedbe8e174a87eab68f6943a359bad /day1 | |
parent | 2c17abb44c8d85d158ab61cf8818432822737d4f (diff) | |
download | workshops-more-scipy-eca0584cda052a7eaa2935add6d9a8979d17d0af.tar.gz workshops-more-scipy-eca0584cda052a7eaa2935add6d9a8979d17d0af.tar.bz2 workshops-more-scipy-eca0584cda052a7eaa2935add6d9a8979d17d0af.zip |
Taken task based approach for Session 3, day 1.
Removed introduction to dictionaries slide and accommodated the same
content while solving the problem.
Diffstat (limited to 'day1')
-rw-r--r-- | day1/session3.tex | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/day1/session3.tex b/day1/session3.tex index eb5c518..ec07999 100644 --- a/day1/session3.tex +++ b/day1/session3.tex @@ -290,26 +290,25 @@ for record in open('sslc1.txt'): \end{frame} \begin{frame}[fragile] - \frametitle{Dictionary} + \frametitle{Dictionary - Building parsed data} \begin{itemize} - \item lists index: 0 \ldots n - \item dictionaries index using any hashable objects - \item d = \{ ``Hitchhiker's guide'' : 42, ``Terminator'' : ``I'll be back''\} - \item d[``Terminator''] => ``I'll be back'' - \item ``Terminator'' is called the key of \typ{d} - \item ``I'll be back'' is called the value of the key ``Terminator'' + \item Let the parsed data be stored in dictionary \typ{data} + \item \begin{lstlisting} +data = {} # is an empty dictionary +\end{lstlisting} + \item Index of a dictionary is called a \emph{key} + \item \emph{Keys} of \typ{data} are strings - region codes + \item Value of a \emph{key} can be any Python object \end{itemize} \end{frame} \begin{frame}[fragile] - \frametitle{Dictionary - Building parsed data} + \frametitle{Dictionary - Building parsed data...} \begin{itemize} - \item Let the parsed data be stored in dictionary \typ{data} - \item Keys of \typ{data} are strings - region codes - \item Value of the key is another dictionary. + \item In this problem let the value of a \emph{key} be another dictionary. \item This dictionary contains: \begin{itemize} - \item 'marks': A list of NumPy arrays + \item 'marks': A \emph{list} of NumPy arrays \item 'total': Total marks of each student \item 'P': Number of passes \item 'F': Number of failures @@ -327,8 +326,8 @@ for record in open('sslc1.txt'): fields = record.split(';') if fields[0] not in data: data[fields[0]] = { - 'marks': array([]), - 'total': array([]), + 'marks': [], + 'total': [], 'P': 0, 'F': 0, 'W': 0 @@ -398,5 +397,16 @@ for k in data: \end{lstlisting} \end{frame} -\end{document} +\begin{frame}[fragile] + \frametitle{New Concepts} + \begin{itemize} + \item Dictionaries + \item Slicing lists + \item New type of conditional + \item NumPy arrays + \item Slicing NumPy arrays + \item NumPy array operations - square, average, sqrt + \end{itemize} +\end{frame} +\end{document} |