From 5f91fcae4a93410621e09ca6b0f68b37b3f2ab14 Mon Sep 17 00:00:00 2001
From: Santosh G. Vattam
Date: Thu, 8 Oct 2009 22:48:06 +0530
Subject: Session 1 slides completed. Session 3 third iteration.

---
 day1/Session-3.tex | 75 +++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 51 insertions(+), 24 deletions(-)

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

diff --git a/day1/Session-3.tex b/day1/Session-3.tex
index 0a6cf81..c43db9c 100755
--- a/day1/Session-3.tex
+++ b/day1/Session-3.tex
@@ -33,7 +33,7 @@
 
 \usepackage{listings}
 \lstset{language=Python,
-    basicstyle=\ttfamily,
+    basicstyle=\ttfamily\bfseries,
     commentstyle=\color{red}\itshape,
   stringstyle=\color{darkgreen},
   showstringspaces=false,
@@ -86,12 +86,12 @@
 
 
 %% Delete this, if you do not want the table of contents to pop up at
-%% the beginning of each subsection:
-\AtBeginSubsection[]
+%% the beginning of each section:
+\AtBeginSection[]
 {
   \begin{frame}<beamer>
     \frametitle{Outline}
-    \tableofcontents[currentsection,currentsubsection]
+    \tableofcontents[currentsection]
   \end{frame}
 }
 
@@ -110,15 +110,7 @@
   \titlepage
 \end{frame}
 
-\begin{frame}
-  \frametitle{Outline}
-  \tableofcontents
-  % You might wish to add the option [pausesections]
-\end{frame}
-
-\section{Python}
-
-\subsection{Problem Set based on Lists and Tuples}
+\section{\typ{for}, Lists and Tuples}
 
 \begin{frame}
   {Problem set 3}
@@ -149,7 +141,7 @@
 \end{frame}
 
 \begin{frame}[fragile]
-  \frametitle{Problem 3.4a (optional)}
+  \frametitle{Problem 3.4a}
 
 Use the \typ{linspace} function and generate a list of N tuples of the form\\
 \typ{[($x_1$,f($x_1$)),($x_2$,f($x_2$)),\ldots,($x_N$,f($x_N$))]}\\for the following functions,\begin{itemize}
@@ -159,7 +151,7 @@ Use the \typ{linspace} function and generate a list of N tuples of the form\\
 \end{frame}
 
 \begin{frame}[fragile]
-  \frametitle{Problem 3.4b (optional)}
+  \frametitle{Problem 3.4b}
 
   Using the tuples generated earlier, determine the intervals where the roots of the functions lie.
 
@@ -170,7 +162,7 @@ Use the \typ{linspace} function and generate a list of N tuples of the form\\
 % TIME: 15 m, running 185m 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\subsection{IO}
+\section{Input/Output}
 
 \begin{frame}[fragile]
   \frametitle{Simple tokenizing and parsing}
@@ -239,7 +231,7 @@ Writing files
 % TIME: 30 m, running 215m 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\subsection{Modules}
+\section{Modules}
 
 \begin{frame}[fragile]
     {Modules}
@@ -347,11 +339,12 @@ def lcm(a, b):
 
 \inctime{25}
 \end{frame}
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % TIME: 25 m, running 230m 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\subsection{Coding Style in Python}
+\section{Coding Style in Python}
 \begin{frame}{Readability and Consistency}
     \begin{itemize}
         \item Readability Counts!-Code is read more often than its written.
@@ -396,8 +389,11 @@ def lcm(a, b):
 \inctime{10}
 \end{frame}
 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% TIME: 10 m, running 240m 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\subsection{Objects}
+\section{Objects}
 \begin{frame}{Objects in Python}
     \begin{itemize}
         \item What is an Object? (Types and classes)
@@ -407,8 +403,33 @@ def lcm(a, b):
       \end{itemize}
 \end{frame}
 
+\begin{frame}{Everything is an Object!}
+  \begin{itemize}
+    \item \typ{list, tuple}
+    \item \typ{string, dictionary}
+    \item \typ{function}
+    \item Of course, user defined class objects!
+  \end{itemize}
+\end {frame}
+
+\begin{frame}{Using Objects}
+  \begin{itemize}
+    \item Creating Objects: Initialization
+    \item Object Manipulation: Object methods and ``.'' operator
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{IPython Examples}
+  \begin{lstlisting}
+In [1]: l = [] #Initialising a list object
+In [2]: l?
+In [3]: l.<tab>
+  \end{lstlisting}
+\end{frame}
+
 \begin{frame}[fragile]
-  \frametitle{Why are they useful?}
+  \frametitle{Objects provide a certain consistency}
   \small
   \begin{lstlisting}
 for element in (1, 2, 3):
@@ -430,9 +451,15 @@ for line in urllib2.urlopen('http://site.com'):
   \inctime{10}
 \end{frame}
 
-\begin{frame}
-  \frametitle{What did we learn?}
-  \tableofcontents
-  % You might wish to add the option [pausesections]
+\section{Summary}
+
+\begin{frame}{What have we learnt so far?}
+  \begin{itemize}
+  \item Writing to and Reading from files using \typ{for}
+  \item Using and writing Python Modules
+  \item Coding Style
+  \item Objects in Python
+  \end{itemize}
 \end{frame}
+
 \end{document}
-- 
cgit 


From 4470b8e1445b091e9e06ec2c8adbc54c28a349e2 Mon Sep 17 00:00:00 2001
From: Santosh G. Vattam
Date: Fri, 9 Oct 2009 12:09:08 +0530
Subject: Session 3 slides completed.

---
 day1/Session-3.tex | 87 ++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 72 insertions(+), 15 deletions(-)

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

diff --git a/day1/Session-3.tex b/day1/Session-3.tex
index c43db9c..d518781 100755
--- a/day1/Session-3.tex
+++ b/day1/Session-3.tex
@@ -112,9 +112,13 @@
 
 \section{\typ{for}, Lists and Tuples}
 
-\begin{frame}
-  {Problem set 3}
-  As you can guess, idea is to use \kwrd{for}!
+\begin{frame}{Quick Recap}
+  \begin{itemize}
+    \item List indexing and slicing
+    \item The \kwrd{range()} function
+    \item \kwrd{for}
+    \item Iterating lists and tuples using \kwrd{for} and \kwrd{range()}
+  \end{itemize}
 \end{frame}
 
 \begin{frame}{Problem 3.1}
@@ -141,7 +145,7 @@
 \end{frame}
 
 \begin{frame}[fragile]
-  \frametitle{Problem 3.4a}
+  \frametitle{Problem 3.4}
 
 Use the \typ{linspace} function and generate a list of N tuples of the form\\
 \typ{[($x_1$,f($x_1$)),($x_2$,f($x_2$)),\ldots,($x_N$,f($x_N$))]}\\for the following functions,\begin{itemize}
@@ -151,7 +155,7 @@ Use the \typ{linspace} function and generate a list of N tuples of the form\\
 \end{frame}
 
 \begin{frame}[fragile]
-  \frametitle{Problem 3.4b}
+  \frametitle{Problem 3.5}
 
   Using the tuples generated earlier, determine the intervals where the roots of the functions lie.
 
@@ -162,7 +166,7 @@ Use the \typ{linspace} function and generate a list of N tuples of the form\\
 % TIME: 15 m, running 185m 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\section{Input/Output}
+\section{Parsing}
 
 \begin{frame}[fragile]
   \frametitle{Simple tokenizing and parsing}
@@ -182,6 +186,8 @@ for word in s.split():
   \end{lstlisting}
 \end{frame}
 
+\section{Input/Output}
+
 \begin{frame}[fragile]
   \frametitle{File handling}
 \begin{lstlisting}
@@ -205,13 +211,59 @@ Writing files
 \begin{frame}[fragile]
     \frametitle{File and \kwrd{for}}
 \begin{lstlisting}
->>> f = open('/path/to/file_name')
+$ cat dummyfile
+One 1
+Two 2
+Three 3
+Four 4
+Five 5
+Six 6
+Seven 7
+Eight 8
+Nine 9
+Ten 10
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{File and \kwrd{for}}
+\begin{lstlisting}
+>>> f = open('dummyfile')
 >>> for line in f:
 ...     print line
 ...
 \end{lstlisting}
 \end{frame}
 
+\begin{frame}[fragile]
+    \frametitle{File and \kwrd{for}}
+\begin{lstlisting}
+In [1]: f = open('dummyfile')
+
+In [2]: for line in f:
+   ...:     print line
+   ...:  
+\end{lstlisting}
+
+\begin{columns}
+  \column{0.3\textwidth}
+
+\begin{lstlisting}
+One 1
+
+Two 2
+
+Three 3
+\end{lstlisting}
+  \column{0.6\textwidth}
+\pause
+\begin{block}{What happens when ...}
+the \kwrd{print line} is replaced by \kwrd{print line,}
+\end{block}
+\end{columns}
+\ldots
+\end{frame}
+
 \begin{frame}{Problem 4.2}
     The given file has lakhs of records in the form:\\
     \typ{RGN;ID;NAME;MARK1;\ldots;MARK5;TOTAL;PFW}\\
@@ -344,10 +396,10 @@ def lcm(a, b):
 % TIME: 25 m, running 230m 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\section{Coding Style in Python}
+\section{Coding Style}
 \begin{frame}{Readability and Consistency}
     \begin{itemize}
-        \item Readability Counts!-Code is read more often than its written.
+        \item Readability Counts!\\Code is read more often than its written.
         \item Consistency!
         \item Know when to be inconsistent.
       \end{itemize}
@@ -386,6 +438,7 @@ def lcm(a, b):
         \item Ending the docstrings
         \item One liner docstrings
    \end{itemize}
+More information at PEP8: http://www.python.org/dev/peps/pep-0008/
 \inctime{10}
 \end{frame}
 
@@ -394,7 +447,7 @@ def lcm(a, b):
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 \section{Objects}
-\begin{frame}{Objects in Python}
+\begin{frame}{Objects in general}
     \begin{itemize}
         \item What is an Object? (Types and classes)
         \item identity
@@ -403,10 +456,12 @@ def lcm(a, b):
       \end{itemize}
 \end{frame}
 
-\begin{frame}{Everything is an Object!}
+\begin{frame}{Almost everything is an Object!}
   \begin{itemize}
-    \item \typ{list, tuple}
-    \item \typ{string, dictionary}
+    \item \typ{list}
+    \item \typ{tuple}
+    \item \typ{string}
+    \item \typ{dictionary}
     \item \typ{function}
     \item Of course, user defined class objects!
   \end{itemize}
@@ -429,7 +484,7 @@ In [3]: l.<tab>
 \end{frame}
 
 \begin{frame}[fragile]
-  \frametitle{Objects provide a certain consistency}
+  \frametitle{Objects provide consistency}
   \small
   \begin{lstlisting}
 for element in (1, 2, 3):
@@ -455,7 +510,9 @@ for line in urllib2.urlopen('http://site.com'):
 
 \begin{frame}{What have we learnt so far?}
   \begin{itemize}
-  \item Writing to and Reading from files using \typ{for}
+  \item Operating on lists and tuples using \kwrd{for}
+  \item Simple string tokenizing and parsing
+  \item Writing to and Reading from files using \kwrd{for}
   \item Using and writing Python Modules
   \item Coding Style
   \item Objects in Python
-- 
cgit 

