From 5e3fb1f1e3c2bf7cad7160e020c8ad782fc224a6 Mon Sep 17 00:00:00 2001
From: Madhusudan.C.S
Date: Thu, 8 Oct 2009 19:45:43 +0530
Subject: Added quiz questions.

---
 day1/Session-4.tex | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

(limited to 'day1/Session-4.tex')

diff --git a/day1/Session-4.tex b/day1/Session-4.tex
index 4dc586b..8dd7150 100755
--- a/day1/Session-4.tex
+++ b/day1/Session-4.tex
@@ -254,11 +254,13 @@ ask_ok(complaint='[y/n]', prompt='?')
 \subsection{Functional programming}
 \begin{frame}[fragile]
     \frametitle{Functional programming}
-What is the basic idea?\\
-Why is it interesting?\\
-\typ{map, reduce, filter}\\
-list comprehension\\
-generators
+    \begin{itemize}
+      \item What is the basic idea?
+      \item Why is it interesting?
+      \item \typ{map, reduce, filter}
+      \item list comprehension
+      \item generators
+    \end{itemize}
 \end{frame}
 
 \begin{frame}[fragile]
-- 
cgit 


From d1bcdc4243d67495c1e23fdff1b528843472ac4d Mon Sep 17 00:00:00 2001
From: Madhusudan.C.S
Date: Fri, 9 Oct 2009 12:59:55 +0530
Subject: Final set of changes.

---
 day1/Session-4.tex | 65 ++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 49 insertions(+), 16 deletions(-)

(limited to 'day1/Session-4.tex')

diff --git a/day1/Session-4.tex b/day1/Session-4.tex
index 8dd7150..c80d566 100755
--- a/day1/Session-4.tex
+++ b/day1/Session-4.tex
@@ -112,7 +112,7 @@
   \titlepage
 \end{frame}
 
-\section{Advanced Data structures, Functions and Debugging}
+\section{Advanced Data structures}
 
 \subsection{Dictionary}
 \begin{frame}{Dictionary}
@@ -120,7 +120,7 @@
     \item lists and tuples index: 0 \ldots n
     \item dictionaries index using strings
     \item \typ{ d = \{ ``Hitchhiker's guide'' : 42, ``Terminator'' : ``I'll be back''\}}
-    \item \typ{d[``Terminator'']\\``I'll be back''}
+    \item \typ{d[``Terminator''] => ``I'll be back''}
     \item aka associative array, key-value pair, hashmap, hashtable \ldots    
     \item what can be keys?
   \end{itemize}
@@ -131,7 +131,7 @@
     \item \alert{Unordered}
       \begin{block}{Standard usage}
         for key in dict:\\
-            <use> dict[key] \# => value
+        \ \ \ \ print dict[key]
       \end{block}
     \item \typ{d.keys()} returns a list
     \item can we have duplicate keys?
@@ -189,7 +189,6 @@ False
 \inctime{5}
 \end{frame}
 
-
 \begin{frame}
   \frametitle{Problem set 6.2}
   \begin{description}
@@ -199,7 +198,8 @@ False
 \inctime{10}
 \end{frame}
 
-\subsection{Functions Reloaded!}
+
+\section{Functions Reloaded!}
 \begin{frame}[fragile]
     \frametitle{Advanced functions}
     \begin{itemize}
@@ -211,6 +211,7 @@ False
       \end{itemize}
 \end{frame}
 
+\subsection{Default arguments}
 \begin{frame}[fragile]
   \frametitle{Functions: default arguments}
   \small
@@ -230,6 +231,7 @@ ask_ok('?', '[Y/N]')
   \end{lstlisting}
 \end{frame}
 
+\subsection{Keyword arguments}
 \begin{frame}[fragile]
   \frametitle{Functions: keyword arguments}
   \small
@@ -251,7 +253,7 @@ ask_ok(complaint='[y/n]', prompt='?')
 \inctime{15} 
 \end{frame}
 
-\subsection{Functional programming}
+\section{Functional programming}
 \begin{frame}[fragile]
     \frametitle{Functional programming}
     \begin{itemize}
@@ -263,6 +265,7 @@ ask_ok(complaint='[y/n]', prompt='?')
     \end{itemize}
 \end{frame}
 
+\subsection{List comprehensions}
 \begin{frame}[fragile]
     \frametitle{List Comprehensions}
 Lets say we want to squares of all the numbers from 1 to 100
@@ -294,11 +297,22 @@ squares = [i*i for i in range(1, 100)
            if i % 10 in [1, 2, 5, 7]]
      \end{lstlisting}
 Which is more readable?
-\inctime{15}
 \end{frame}
 
+\begin{frame}[fragile]
+    \frametitle{map() function}
+    map() function accomplishes the same as list comprehensions
+    \begin{lstlisting}
+>>> def square(x): return x*x
+...
+>>> map(square, range(1, 100))
+[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
+    \end{lstlisting}
+\inctime{15}
+\end{frame}
 
-\subsection{Debugging}
+\section{Debugging}
+\subsection{Errors and Exceptions}
 \begin{frame}[fragile]
  \frametitle{Errors}
  \begin{lstlisting}
@@ -340,6 +354,7 @@ or modulo by zero
 \end{lstlisting}
 \end{frame}
 
+\subsection{Strategy}
 \begin{frame}[fragile]
     \frametitle{Debugging effectively}
     \begin{itemize}
@@ -352,7 +367,7 @@ or modulo by zero
 \begin{frame}[fragile]
     \frametitle{Debugging effectively}
     \begin{itemize}
-      \item Using \typ{\%debug} and \typ{\%pdb} in IPython
+      \item Using \typ{\%debug} in IPython
     \end{itemize}
 \end{frame}
 
@@ -364,33 +379,51 @@ In [1]: import mymodule
 In [2]: mymodule.test()
 ---------------------------------------------
 NameError   Traceback (most recent call last)
-/media/python/iitb/workshops/day1/<ipython console> in <module>()
-/media/python/iitb/workshops/day1/mymodule.py in test()
+<ipython console> in <module>()
+mymodule.py in test()
       1 def test():
 ----> 2     print spam
 NameError: global name 'spam' is not defined
+
 In [3]: %debug
-> /media/python/iitb/workshops/day1/mymodule.py(2)test()
+> mymodule.py(2)test()
       0     print spam
 ipdb> 
 \end{lstlisting}
 \inctime{15} 
 \end{frame}
 
+\subsection{Exercise}
 \begin{frame}[fragile]
 \frametitle{Debugging: Exercise}
+\small
+\begin{lstlisting}
+import keyword
+f = open('/path/to/file')
+
+freq = {}
+for line in f:
+    words = line.split()
+    for word in words:
+        key = word.strip(',.!;?()[]: ')
+        if keyword.iskeyword(key):
+            value = freq[key]
+            freq[key] = value + 1
+
+print freq
+\end{lstlisting}
 \inctime{10}
 \end{frame}
 
 \begin{frame}
   \frametitle{What did we learn?}
   \begin{itemize}
-    \item Creating and using Dictionaries
-    \item Creating and using Sets
-    \item Advances Functions: default arguments, keyword arguments
+    \item Dictionaries
+    \item Sets
+    \item Default and keyword arguments
     \item Functional Programming, list comprehensions
     \item Errors and Exceptions in Python
-    \item Debugging: \%pdb and \%debug in IPython
+    \item Debugging: \%debug in IPython
   \end{itemize}
 \end{frame}
 \end{document}
-- 
cgit 


From 52c6683bb2792631e91481e74786dc6bf569e312 Mon Sep 17 00:00:00 2001
From: Madhusudan.C.S
Date: Fri, 9 Oct 2009 13:20:08 +0530
Subject: Added emphbar to boxes in Session 2.

---
 day1/Session-4.tex | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

(limited to 'day1/Session-4.tex')

diff --git a/day1/Session-4.tex b/day1/Session-4.tex
index c80d566..a4a25b0 100755
--- a/day1/Session-4.tex
+++ b/day1/Session-4.tex
@@ -89,11 +89,11 @@
 
 %% Delete this, if you do not want the table of contents to pop up at
 %% the beginning of each subsection:
-\AtBeginSubsection[]
+\AtBeginSection[]
 {
   \begin{frame}<beamer>
     \frametitle{Outline}
-    \tableofcontents[currentsection,currentsubsection]
+    \tableofcontents[currentsection,subsections]
   \end{frame}
 }
 
@@ -297,17 +297,6 @@ squares = [i*i for i in range(1, 100)
            if i % 10 in [1, 2, 5, 7]]
      \end{lstlisting}
 Which is more readable?
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{map() function}
-    map() function accomplishes the same as list comprehensions
-    \begin{lstlisting}
->>> def square(x): return x*x
-...
->>> map(square, range(1, 100))
-[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
-    \end{lstlisting}
 \inctime{15}
 \end{frame}
 
-- 
cgit 

