Branches merged.
authorSantosh G. Vattam <vattam.santosh@gmail.com>
Thu, 08 Oct 2009 22:48:59 +0530
changeset 75 090d03e43e95
parent 74 a476c09dcf24 (current diff)
parent 73 9a93e8901e99 (diff)
child 76 b24c2560f626
child 79 04b620d3f172
Branches merged.
day1/Session-1.snm
day1/Session-1.vrb
day1/Session-2.snm
day1/Session-2.vrb
day1/Session-3.snm
day1/Session-4.snm
day1/Session-4.vrb
Binary file day1/DebugginDiagram.png has changed
--- a/day1/Session-1.vrb	Thu Oct 08 22:48:06 2009 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-\frametitle {Basic looping}
-  \begin{lstlisting}
-# Fibonacci series:
-# the sum of two elements
-# defines the next
-a, b = 0, 1
-while b < 10:
-    print b,
-    a, b = b, a + b
-
-\end{lstlisting}
-\typ{1 1 2 3 5 8}\\
-\alert{Recall it is easy to write infinite loops with \kwrd{while}}
-  \inctime{20}
--- a/day1/Session-2.tex	Thu Oct 08 22:48:06 2009 +0530
+++ b/day1/Session-2.tex	Thu Oct 08 22:48:59 2009 +0530
@@ -110,7 +110,7 @@
   \titlepage
 \end{frame}
 
-\section{Python}
+\section{Functions and basic data structures}
 
 \subsection{Exercises on Control flow}
 \begin{frame}
--- a/day1/Session-2.vrb	Thu Oct 08 22:48:06 2009 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-\frametitle {\typ{for}: the list companion}
-  \begin{lstlisting}
-In [89]: for p, ch in enumerate( a ):
-   ....:     print p, ch
-   ....:
-   ....:
-0 a
-1 b
-2 c
-  \end{lstlisting}
-Try: \typ{print enumerate(a)}
-\inctime{10}
--- a/day1/Session-4.tex	Thu Oct 08 22:48:06 2009 +0530
+++ b/day1/Session-4.tex	Thu Oct 08 22:48:59 2009 +0530
@@ -39,6 +39,8 @@
   showstringspaces=false,
   keywordstyle=\color{blue}\bfseries}
 
+\usepackage{pgf}
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Macros
 \setbeamercolor{emphbar}{bg=blue!20, fg=black}
@@ -110,16 +112,16 @@
   \titlepage
 \end{frame}
 
-\section{Python}
+\section{Advanced Data structures, Functions and Debugging}
 
 \subsection{Dictionary}
 \begin{frame}{Dictionary}
   \begin{itemize}
-    \item aka associative arrays, key-value pairs, hashmaps, hashtables \ldots    
-    \item \typ{ d = \{ ``Hitchhiker's guide'' : 42, ``Terminator'' : ``I'll be back''\}}
     \item lists and tuples index: 0 \ldots n
     \item dictionaries index using strings
-    \item aka key-value pairs
+    \item \typ{ d = \{ ``Hitchhiker's guide'' : 42, ``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}
 \end{frame}
@@ -137,11 +139,11 @@
   \inctime{5}
 \end{frame}
 
-\begin{frame} {Problem Set 2.1}
+\begin{frame} {Problem Set 6.1}
   \begin{description}
-\item[2.1.1] You are given date strings of the form ``29, Jul 2009'', or ``4 January 2008''. In other words a number a string and another number, with a comma sometimes separating the items.Write a function that takes such a string and returns a tuple (yyyy, mm, dd) where all three elements are ints.
-    \item[2.1.2] Count word frequencies in a file.
-    \item[2.1.3] Find the most used Python keywords in your Python code (import keyword).
+\item[6.1.1] You are given date strings of the form ``29, Jul 2009'', or ``4 January 2008''. In other words a number a string and another number, with a comma sometimes separating the items.Write a function that takes such a string and returns a tuple (yyyy, mm, dd) where all three elements are ints.
+    \item[6.1.2] Count word frequencies in a file.
+    \item[6.1.3] Find the most used Python keywords in your Python code (import keyword).
 \end{description}
 
 \inctime{10}
@@ -189,10 +191,10 @@
 
 
 \begin{frame}
-  \frametitle{Problem set 2.2}
+  \frametitle{Problem set 6.2}
   \begin{description}
-    \item[2.2.1] Given a dictionary of the names of students and their marks, identify how many duplicate marks are there? and what are these?
-    \item[2.2.2] Given a string of the form ``4-7, 9, 12, 15'' find the numbers missing in this list for a given range.
+    \item[6.2.1] Given a dictionary of the names of students and their marks, identify how many duplicate marks are there? and what are these?
+    \item[6.2.2] Given a string of the form ``4-7, 9, 12, 15'' find the numbers missing in this list for a given range.
 \end{description}
 \inctime{10}
 \end{frame}
@@ -243,8 +245,8 @@
         print complaint
 
 ask_ok(prompt='?')
-ask_ok(prompt='?', complaint='[Y/N]')
-ask_ok(complaint='[Y/N]', prompt='?')
+ask_ok(prompt='?', complaint='[y/n]')
+ask_ok(complaint='[y/n]', prompt='?')
 \end{lstlisting}
 \inctime{15} 
 \end{frame}
@@ -299,6 +301,9 @@
  \frametitle{Errors}
  \begin{lstlisting}
 >>> while True print 'Hello world'
+ \end{lstlisting}
+\pause
+  \begin{lstlisting}
   File "<stdin>", line 1, in ?
     while True print 'Hello world'
                    ^
@@ -310,11 +315,22 @@
  \frametitle{Exceptions}
  \begin{lstlisting}
 >>> print spam
+\end{lstlisting}
+\pause
+\begin{lstlisting}
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 NameError: name 'spam' is not defined
+\end{lstlisting}
+\end{frame}
 
+\begin{frame}[fragile]
+ \frametitle{Exceptions}
+ \begin{lstlisting}
 >>> 1 / 0
+\end{lstlisting}
+\pause
+\begin{lstlisting}
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
 ZeroDivisionError: integer division 
@@ -324,54 +340,37 @@
 
 \begin{frame}[fragile]
     \frametitle{Debugging effectively}
-
     \begin{itemize}
-        \item  \kwrd{print} based strategy
-        \item Process: Hypothesis, test, refine, rinse-repeat
-        \item Using \typ{\%debug} and \typ{\%pdb} in IPython
+        \item \kwrd{print} based strategy
+        \item Process:
     \end{itemize}
+\pgfimage[interpolate=true,width=5cm,height=5cm]{DebugginDiagram.png}
 \end{frame}
 
 \begin{frame}[fragile]
-\frametitle{Debugging: example}
-\small
-\begin{lstlisting}
->>> import pdb
->>> import mymodule
->>> pdb.run('mymodule.test()')
-> <string>(1)<module>()
-(Pdb) continue
-Traceback (most recent call last):
-  File "<stdin>", line 1, in <module>
-  File "/usr/lib/python2.6/pdb.py", line 1207, in run
-    Pdb().run(statement, globals, locals)
-  File "/usr/lib/python2.6/bdb.py", line 368, in run
-    exec cmd in globals, locals
-  File "<string>", line 1, in <module>
-  File "mymodule.py", line 2, in test
-    print spam
-NameError: global name 'spam' is not defined
-\end{lstlisting}
+    \frametitle{Debugging effectively}
+    \begin{itemize}
+      \item Using \typ{\%debug} and \typ{\%pdb} in IPython
+    \end{itemize}
 \end{frame}
 
 \begin{frame}[fragile]
 \frametitle{Debugging in IPython}
 \small
 \begin{lstlisting}
-In [1]: %pdb
-Automatic pdb calling has been turned ON
-In [2]: import mymodule
-In [3]: mymodule.test()
-----------------------------------------------
-NameError    Traceback (most recent call last)
+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.pyc in test()
+/media/python/iitb/workshops/day1/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()
       0     print spam
-ipdb>
+ipdb> 
 \end{lstlisting}
 \inctime{15} 
 \end{frame}
@@ -389,7 +388,7 @@
     \item Advances Functions: default arguments, keyword arguments
     \item Functional Programming, list comprehensions
     \item Errors and Exceptions in Python
-    \item Debugging: How to use pdb, \%pdb and \%debug in IPython
+    \item Debugging: \%pdb and \%debug in IPython
   \end{itemize}
 \end{frame}
 \end{document}
--- a/day1/Session-4.vrb	Thu Oct 08 22:48:06 2009 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-\frametitle {Debugging: Exercise}
-\inctime{10}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/aliquot.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,8 @@
+def aliquot(n):
+    sum = 0
+    for i in range(1, (n/2)+1):
+        if n % i == 0:
+            sum += i
+    return sum
+
+print aliquot(14)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/amicable.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,18 @@
+import math
+
+def aliquot(n):
+    sum = 0
+    for i in range(1, int(math.sqrt(n))+1):
+        if n % i == 0:
+            sum += i + n/i
+    return sum
+
+amicable = []
+for n in range(10000, 100000):
+    m = aliquot(n)
+    if aliquot(m) == n:
+        amicable.append((m, n))
+
+print amicable
+
+# please please please profile this.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/amicable_debug.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,18 @@
+import math
+
+def aliquot(n):
+    sum = 0
+    for i in range(1, math.sqrt(n)+1):
+        if n % i == 0:
+            sum += i + n/i
+    return sum
+
+amicable = []
+for n in range(10000, 100000):
+    m = aliquot(n)
+    if aliquot(m) == n:
+        amicable.append((m, n))
+
+print amicable
+
+# please please please profile this.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/arm.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,10 @@
+cubes = []
+for i in range(10):
+    cubes.append(i ** 3)
+
+for i in range(100, 1000):
+    a = i % 10
+    b = (i / 10) % 10
+    c = (i / 100) % 10
+    if i == cubes[a] + cubes[b] + cubes[c]:
+        print "Armstrong Number: ", i
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/bishop.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,7 @@
+r, c = 5, 4
+for i in range(1, 9):
+    for j in range(1, 9):
+        a = r - i
+        b = c - j
+        if a and b and a == b or a == -b:
+            print i, j
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/collatz.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,7 @@
+a = -1
+while a > 1:
+    print a
+    if a % 2:
+        a = a * 3 + 1
+    else:
+        a /= 2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/datestring.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,23 @@
+def get_date_from_str(date_str):
+    month2mm = {
+        'January': 1,
+        'February': 2,
+        'March': 3,
+        'April': 4,
+        'May': 5,
+        'June': 6,
+        'July': 7,
+        'August': 8,
+        'September': 9,
+        'October': 10,
+        'November': 11,
+        'December': 12,
+        }
+
+    dd, month, yyyy = date_str.split()
+
+    mm = month2mm[month]
+    return int(yyyy), int(dd.strip(',')), mm
+
+date_str = raw_input('Enter a date string? ')
+print get_date_from_str(date_str)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/duplicate_marks.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,13 @@
+students = {
+    'Madhu': 12,
+    'Shantanu':45,
+    'Puneeth': 54,
+    'Vattam': 35,
+    'KD': 50,
+    }
+
+all_marks = students.values()
+unique_marks = set(all_marks)
+
+print "Number of Duplicate marks: ", len(all_marks) - len(unique_marks)
+print "Duplicate marks: ", set(all_marks - list(unique_marks))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/even_perfect_4.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,17 @@
+def is_perfect_square(n):
+    i = 1
+    while i * i < n:
+        i += 1
+    return i * i == n
+
+def all_digits_even(n):
+    if n < 0: n = -n
+    while n > 0:
+        if n % 2 == 1:
+            return False
+        n /= 10
+    return True
+
+for i in range(2222, 8888):
+    if all_digits_even(i) and is_perfect_square(i):
+        print i
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/find_pow_2.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,29 @@
+def is_pow_2(n):
+    bin_count = 0
+    while n > 0:
+        if n % 2 == 1:
+            bin_count += 1
+        if bin_count > 1:
+            return False
+        n /= 2
+
+    return bin_count == 1
+
+def collatz_pow_2(n):
+    if n == 1: return 4
+    if n == 2: return 4
+    collatz_pow_2 = []
+    while n > 2:
+        print n, 
+        if is_pow_2(n):
+            collatz_pow_2.append(n)
+
+        if n % 2:
+            n = n * 3 - 1
+        else:
+            n /= 2 
+
+    return max(collatz_pow_2)
+
+import sys
+collatz_pow_2(int(sys.argv[1]))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/funcs2.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,28 @@
+import math
+
+def linspace(a, b, N):
+    lns = []
+    step = (float(b) - float(a)) / float(N - 1)
+    print step
+    for i in range(N):
+        lns.append(a + i*step)
+
+    return lns
+
+def sin_func():
+    x = linspace(0, 5, 11)
+    sin_list = []
+    for i in x:
+        sin_list.append(math.sin(i))
+
+    print sin_list
+
+def sinsin_func():
+    x = linspace(0, 5, 11)
+    sin_list = []
+    for i in x:
+        sin_list.append(math.sin(i) + math.sin(10*i))
+
+    print sin_list
+
+sinsin_func()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/gcd.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,8 @@
+def gcd(a, b):
+  if a % b == 0:
+    return b
+  return gcd(b, a%b)
+
+print gcd(5, 40)
+print gcd(11, 60)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/gcd_another.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,13 @@
+def gcd(a, b):
+  if a - b == 0:
+    return b
+  if a > b:
+    return gcd(b, a-b)
+  else:
+    return gcd(b, b-a)
+
+def lcm(a, b):
+    return (a * b) / gcd(a, b)
+
+print lcm(21, 14)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/kwfreq.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,14 @@
+import keyword
+f = open('/home/madhu/pyprogs/pytriads.py')
+
+freq = {}
+for line in f:
+    words = line.split()
+    for word in words:
+        key = word.strip(',.!;?()[]: ')
+        if keyword.iskeyword(key):
+            value = freq.get(key, 1)
+            freq[key] = value + 1
+
+print freq
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/linspace.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,10 @@
+def linspace(a, b, N):
+    lns = []
+    step = (float(b) - float(a)) / float(N - 1)
+    print step
+    for i in range(N):
+        lns.append(a + i*step)
+
+    return lns
+
+print linspace(0, 5, 11)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/markstats.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,22 @@
+import math
+
+f = open('/home/madhu/Desktop/marks.dat')
+    
+subj_marks = [[]] * 5
+names = []
+for line in f:
+    fields = line.split(';')
+    names.append(fields[2])
+    for i in range(5):
+        subj_marks[i].append(int(fields[i+3]))
+
+for i in range(5):
+    avg_marks = float(sum(subj_marks[i])) / len(subj_marks[i])
+    student = names[subj_marks[i].index(max(subj_marks[i]))]
+    sigma = 0
+    for j in subj_marks[i]:
+        sigma += (j - avg_marks) ** 2
+
+    std_dev = math.sqrt(sigma)
+    print "Average marks for subject: %f is Standard Deviation is %f, Student with Highest Marks is %s" % (avg_marks, std_dev, student)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/missing_num.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,16 @@
+str_range = '4-7, 9, 12, 15'
+
+ranges = str_range.split(',')
+
+lst = []
+for r in ranges:
+    vals = r.split('-')
+    if len(vals) == 2:
+       lst.extend(range(int(vals[0]), int(vals[1]) + 1))
+    else:
+       lst.append(int(vals[0]))
+
+set_range = set(lst)
+all_elems = set(range(min(lst), max(lst)))
+
+print all_elems - set_range
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/pyramid1.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,5 @@
+n = input('How many lines? ')
+for i in range(1, n + 1):
+    for j in range(i):
+        print i,
+    print
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/pytriads.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,18 @@
+def is_perfect_square(n):
+    i = 1
+    while i * i < n:
+        i += 1
+    return i * i == n, i
+
+def gcd(a, b):
+    if a % b == 0:
+        return b
+    else:
+        return gcd(b, a%b)
+
+for a in range(3, 100):
+    for b in range(a+1, 100):
+        ips, c = is_perfect_square((a * a) + (b * b))
+        if ips and gcd(a, b) == 1:
+            print a, b, c
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/readmarks.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,5 @@
+f = open('/home/madhu/Desktop/marks.dat')
+
+for line in f:
+    fields = line.split(';')
+    print "Name: %s, Total Marks: %s" % (fields[2].strip(), fields[8].strip())
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/roots.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,28 @@
+import math
+
+def linspace(a, b, N):
+    lns = []
+    step = (float(b) - float(a)) / float(N - 1)
+    print step
+    for i in range(N):
+        lns.append(a + i*step)
+
+    return lns
+
+def sinsin_func():
+    x = linspace(0, 5, 11)
+    sin_list = []
+    for i in x:
+        sin_list.append(math.sin(i) + math.sin(10*i))
+
+    return sin_list
+
+def find_root_range():
+    sin_list = sinsin_func()
+    for i, sins in enumerate(sin_list):
+        if (sin_list[i] > 0 and sin_list[i+1] < 0) or (sin_list[i] > 0 and sin_list[i+1] < 0):
+            print "Roots lie between: %f and %f" % (sin_list[i], sin_list[i+1])
+        if sin_list[i] == 0:
+            print "%f is the root" % sin_list[i]
+
+find_root_range()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/round_float.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,12 @@
+# round using int
+n = 17.3 # any float
+int (n + .5)
+
+# round it off to first decimal place
+round(amount * 10) / 10.0
+
+# round it off to nearest 5 paise
+round(amount * 20) / 20.0
+
+# exchange two variables
+a, b = b, a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/strrange.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,13 @@
+str_ranges = "1, 3-7, 12, 15, 18-21"
+
+ranges = str_ranges.split(',')
+
+lst = []
+for r in ranges:
+    vals = r.split('-')
+    if len(vals) == 2:
+       lst.extend(range(int(vals[0]), int(vals[1]) + 1))
+    else:
+       lst.append(int(vals[0]))
+
+print lst
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/exercise/word_frequencies.py	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,11 @@
+f = open('/home/madhu/pyprogs/pytriads.py')
+
+freq = {}
+for line in f:
+    words = line.split()
+    for word in words:
+        key = word.strip(',.!;?\'" ')
+        value = freq.get(key, 1)
+        freq[key] = value + 1
+
+print freq
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day1/handout.tex	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,681 @@
+\documentclass[12pt]{article}
+\title{Python Workshop\\Problems and Exercises}
+\author{Asokan Pichai\\Prabhu Ramachandran}
+\begin{document}
+\maketitle
+
+\section{Python}
+\subsection{Getting started}
+   \begin{verbatim}
+>>> print 'Hello Python' 
+>>> print 3124 * 126789
+>>> 1786 % 12
+>>> 3124 * 126789
+>>> a = 3124 * 126789
+>>> big = 12345678901234567890 ** 3
+>>> verybig = big * big * big * big 
+>>> 12345**6, 12345**67, 12345**678
+
+>>> s = 'Hello '
+>>> p = 'World'
+>>> s + p 
+>>> s * 12 
+>>> s * s
+>>> s + p * 12, (s + p)* 12
+>>> s * 12 + p * 12
+>>> 12 * s 
+\end{verbatim}
+\newpage
+
+\begin{verbatim}
+>>> 17/2
+>>> 17/2.0
+>>> 17.0/2
+>>> 17.0/8.5
+>>> int(17/2.0)
+>>> float(17/2)
+>>> str(17/2.0)
+>>> round( 7.5 )
+\end{verbatim}
+  
+\subsection{Mini exercises}
+\begin{itemize}
+  \item Round a float to the nearest integer, using \texttt{int()}?
+  \item What does this do?  \\\texttt{round(amount * 10) /10.0 }
+  \item How to round a number to the nearest  5 paise?
+    \begin{description}
+      \item[Remember] 17.23 $\rightarrow$ 17.25,\\ while 17.22 $\rightarrow$ 17.20
+    \end{description}
+  \item How to round a number to the nearest 20 paise?
+\end{itemize}
+
+\begin{verbatim}
+    amount = 12.68
+    denom = 0.05
+    nCoins = round(amount/denom)
+    rAmount = nCoins * denom
+\end{verbatim}
+
+\subsection{Dynamic typing}
+\begin{verbatim}
+a = 1
+a = 1.1
+a = "Now I am a string!"
+\end{verbatim}
+
+\subsection{Comments}
+\begin{verbatim}
+a = 1  # In-line comments
+# Comment in a line to itself.
+a = "# This is not a comment!"
+  \end{verbatim}
+
+\section{Data types}
+\subsection{Numbers}
+  \begin{verbatim}
+>>> a = 1 # Int.
+>>> l = 1000000L # Long
+>>> e = 1.01325e5 # float
+>>> f = 3.14159 # float
+>>> c = 1+1j # Complex!
+>>> print f*c/a
+(3.14159+3.14159j)
+>>> print c.real, c.imag
+1.0 1.0
+>>> abs(c)
+1.4142135623730951
+>>> abs( 8 - 9.5 )
+1.5
+  \end{verbatim}
+
+\subsection{Boolean}
+  \begin{verbatim}
+>>> t = True
+>>> f = not t
+False
+>>> f or t
+True
+>>> f and t
+False
+>>>  NOT True
+\ldots ???
+>>>  not TRUE
+\ldots ???
+\end{verbatim}
+
+\subsection{Relational and logical operators}
+  \begin{verbatim}
+>>> a, b, c = -1, 0, 1
+>>> a == b
+False
+>>> a <= b 
+True
+>>> a + b != c
+True
+>>> a < b < c
+True
+>>> c >= a + b
+True
+  \end{verbatim}
+
+\subsection{Strings}
+  \begin{verbatim}
+s = 'this is a string'
+s = 'This one has "quotes" inside!'
+s = "I have 'single-quotes' inside!"
+l = "A string spanning many lines\
+one more line\
+yet another"
+t = """A triple quoted string does
+not need to be escaped at the end and 
+"can have nested quotes" etc."""
+  \end{verbatim}
+
+  \begin{verbatim}
+>>> w = "hello"    
+>>> print w[0] + w[2] + w[-1]
+hlo
+>>> len(w) # guess what
+5
+>>> s = u'Unicode strings!'
+>>> # Raw strings (note the leading 'r')
+... r_s = r'A string $\alpha \nu$'
+  \end{verbatim}
+  \begin{verbatim}
+>>> w[0] = 'H' # Can't do that!
+Traceback (most recent call last):
+  File "<stdin>", line 1, in ?
+TypeError: object does not support item assignment
+  \end{verbatim}
+
+  \subsection{IPython}
+  \begin{verbatim}
+In [1]: a = 'hello world'
+In [2]: a.startswith('hell')
+Out[2]: True
+In [3]: a.endswith('ld')
+Out[3]: True
+In [4]: a.upper()
+Out[4]: 'HELLO WORLD'
+In [5]: a.upper().lower()
+Out[5]: 'hello world'
+
+In [6]: a.split()
+Out[6]: ['hello', 'world']
+In [7]: ''.join(['a', 'b', 'c'])
+Out[7]: 'abc'
+In [8] 'd' in ''.join( 'a', 'b', 'c')
+Out[8]: False
+a.split( 'o' )}
+???
+'x'.join( a.split( 'o' ) )
+???
+
+In [11]: x, y = 1, 1.2
+In [12]: 'x is %s, y is %s' %(x, y)
+Out[12]: 'x is 1, y is 1.234'
+
+'x is \%d, y is \%f' \%(x, y)
+???
+'x is \%3d, y is \%4.2f' \%(x, y)
+??? 
+  \end{verbatim}
+
+\subsection{A classic problem}
+    How to interchange values of two variables? Please note that the type of either variable is unknown and it is not necessary that both be of the same type even!
+
+\subsection{Basic conditional flow}
+  \begin{verbatim}
+In [21]: a = 7
+In [22]: b = 8
+In [23]: if a > b:
+   ....:    print 'Hello'
+   ....: else:
+   ....:     print 'World'
+   ....:
+   ....:
+World
+  \end{verbatim}
+
+\subsection{\texttt{If...elif...else} example}
+\begin{verbatim}
+x = int(raw_input("Enter an integer:"))
+if x < 0:
+     print 'Be positive!'
+elif x == 0:
+     print 'Zero'
+elif x == 1:
+     print 'Single'
+else:
+     print 'More'
+\end{verbatim}
+
+\subsection{Basic looping}
+  \begin{verbatim}
+# Fibonacci series:
+# the sum of two elements
+# defines the next
+a, b = 0, 1
+while b < 10:
+    print b,
+    a, b = b, a + b
+ 
+\end{verbatim}
+
+\section{Problem set 1}
+All the problems can be solved using \texttt{if} and \texttt{while} 
+\begin{description}
+  \item[1.1] Write a program that displays all three digit numbers that are equal to the sum of the cubes of their digits. That is, print numbers $abc$ that have the property $abc = a^3 + b^3 + c^3$\\
+These are called $Armstrong$ numbers.
+  
+\item[1.2 Collatz sequence]
+\begin{enumerate}
+  \item Start with an arbitrary (positive) integer. 
+  \item If the number is even, divide by 2; if the number is odd multiply by 3 and add 1.
+  \item Repeat the procedure with the new number.
+  \item There is a cycle of 4, 2, 1 at which the procedure loops.
+\end{enumerate}
+    Write a program that accepts the starting value and prints out the Collatz sequence.
+
+\item[1.3]
+  Write a program that prints the following pyramid on the screen. 
+  \begin{verbatim}
+1
+2  2
+3  3  3
+4  4  4  4
+  \end{verbatim}
+The number of lines must be obtained from the user as input.\\
+When can your code fail?
+\end{description}
+
+\subsection{Functions: examples}
+  \begin{verbatim}
+def signum( r ):
+    """returns 0 if r is zero
+    -1 if r is negative
+    +1 if r is positive"""
+    if r < 0:
+        return -1
+    elif r > 0:
+        return 1
+    else:
+        return 0
+
+def pad( n, size ): 
+    """pads integer n with spaces
+    into a string of length size
+    """
+    SPACE = ' '
+    s = str( n )
+    padSize = size - len( s )
+    return padSize * SPACE + s
+  \end{verbatim}
+What about \%3d?
+
+\subsection  {What does this function do?}
+  \begin{verbatim}
+def what( n ):
+    if n < 0: n = -n
+    while n > 0:
+        if n % 2 == 1:
+            return False
+        n /= 10
+    return True
+  \end{verbatim}
+\newpage
+
+\subsection{What does this function do?}
+\begin{verbatim}
+def what( n ):
+    i = 1    
+    while i * i < n:
+        i += 1
+    return i * i == n, i
+  \end{verbatim}
+
+\subsection{What does this function do?}
+  \begin{verbatim}
+def what( n, x ):
+    z = 1.0
+    if n < 0:
+        x = 1.0 / x
+        n = -n
+    while n > 0:
+        if n % 2 == 1:
+            z *= x
+        n /= 2
+        x *= x
+    return z
+  \end{verbatim}
+
+\section{Problem set 2}
+  The focus is on writing functions and calling them.
+\begin{description}
+  \item[2.1] Write a function to return the gcd of two numbers.
+  \item[2.2 Primitive Pythagorean Triads] A pythagorean triad $(a,b,c)$ has the property $a^2 + b^2 = c^2$.\\By primitive we mean triads that do not `depend' on others. For example, (4,3,5) is a variant of (3,4,5) and hence is not primitive. And (10,24,26) is easily derived from (5,12,13) and should not be displayed by our program. \\
+Write a program to print primitive pythagorean triads. The program should generate all triads with a, b values in the range 0---100
+\item[2.3] Write a program that generates a list of all four digit numbers that have all their digits even and are perfect squares.\\For example, the output should include 6400 but not 8100 (one digit is odd) or 4248 (not a perfect square).
+\item[2.4 Aliquot] The aliquot of a number is defined as: the sum of the \emph{proper} divisors of the number. For example, the aliquot(12) = 1 + 2 + 3 + 4 + 6 = 16.\\
+  Write a function that returns the aliquot number of a given number. 
+\item[2.5 Amicable pairs] A pair of numbers (a, b) is said to be \emph{amicable} if the aliquot number of a is b and the aliquot number of b is a.\\
+  Example: \texttt{220, 284}\\
+  Write a program that prints all five digit amicable pairs.
+\end{description}
+
+\section{Lists}
+\subsection{List creation and indexing}
+\begin{verbatim}
+>>> a = [] # An empty list.
+>>> a = [1, 2, 3, 4] # More useful.
+>>> len(a) 
+4
+>>> a[0] + a[1] + a[2] + a[-1]
+10
+\end{verbatim}
+
+\begin{verbatim}
+>>> a[1:3] # A slice.
+[2, 3]
+>>> a[1:-1]
+[2, 3, 4]
+>>> a[1:] == a[1:-1]
+False  
+\end{verbatim}
+Explain last result
+
+\newpage
+\subsection{List: more slices}
+\begin{verbatim}
+>>> a[0:-1:2] # Notice the step!
+[1, 3]
+>>> a[::2]
+[1, 3]
+>>> a[-1::-1]
+\end{verbatim}
+What do you think the last one will do?\\
+\emph{Note: Strings also use same indexing and slicing.}
+  \subsection{List: examples}
+\begin{verbatim}
+>>> a = [1, 2, 3, 4]
+>>> a[:2]
+[1, 3]
+>>> a[0:-1:2]
+[1, 3]
+\end{verbatim}
+\emph{Lists are mutable (unlike strings)}
+
+\begin{verbatim}
+>>> a[1] = 20
+>>> a
+[1, 20, 3, 4]
+\end{verbatim}
+
+  \subsection{Lists are mutable and heterogenous}
+\begin{verbatim}
+>>> a = ['spam', 'eggs', 100, 1234]
+>>> a[2] = a[2] + 23
+>>> a
+['spam', 'eggs', 123, 1234]
+>>> a[0:2] = [1, 12] # Replace items
+>>> a
+[1, 12, 123, 1234]
+>>> a[0:2] = [] # Remove items
+>>> a.append( 12345 )
+>>> a
+[123, 1234, 12345]
+\end{verbatim}
+
+  \subsection{List methods}
+\begin{verbatim}
+>>> a = ['spam', 'eggs', 1, 12]
+>>> a.reverse() # in situ
+>>> a
+[12, 1, 'eggs', 'spam']
+>>> a.append(['x', 1]) 
+>>> a
+[12, 1, 'eggs', 'spam', ['x', 1]]
+>>> a.extend([1,2]) # Extend the list.
+>>> a.remove( 'spam' )
+>>> a
+[12, 1, 'eggs', ['x', 1], 1, 2]
+\end{verbatim}
+
+  \subsection{List containership}
+  \begin{verbatim}
+>>> a = ['cat', 'dog', 'rat', 'croc']
+>>> 'dog' in a
+True
+>>> 'snake' in a
+False
+>>> 'snake' not in a
+True
+>>> 'ell' in 'hello world'
+True
+  \end{verbatim}
+  \subsection{Tuples: immutable}
+\begin{verbatim}
+>>> t = (0, 1, 2)
+>>> print t[0], t[1], t[2], t[-1] 
+0 1 2 2
+>>> t[0] = 1
+Traceback (most recent call last):
+  File "<stdin>", line 1, in ?
+TypeError: object does not support item assignment
+\end{verbatim}  
+    Multiple return values are actually a tuple.\\
+    Exchange is tuple (un)packing
+  \subsection{\texttt{range()} function}
+  \begin{verbatim}
+>>> range(7)
+[0, 1, 2, 3, 4, 5, 6]
+>>> range( 3, 9)
+[3, 4, 5, 6, 7, 8]
+>>> range( 4, 17, 3)
+[4, 7, 10, 13, 16]
+>>> range( 5, 1, -1)
+[5, 4, 3, 2]
+>>> range( 8, 12, -1)
+[]
+  \end{verbatim}
+
+  \subsection{\texttt{for\ldots range(\ldots)} idiom}
+  \begin{verbatim}
+In [83]: for i in range(5):
+   ....:     print i, i * i
+   ....:     
+   ....:     
+0 0
+1 1
+2 4
+3 9
+4 16
+\end{verbatim}
+
+  \subsection{\texttt{for}: the list companion}
+  
+  \begin{verbatim}
+In [84]: a = ['a', 'b', 'c']
+In [85]: for x in a:
+   ....:    print x, chr( ord(x) + 10 )
+   ....:
+a  k
+b  l
+c  m
+  \end{verbatim}
+
+  \subsection{\texttt{for}: the list companion}
+  \begin{verbatim}
+In [89]: for p, ch in enumerate( a ):
+   ....:     print p, ch
+   ....:     
+   ....:     
+0 a
+1 b
+2 c
+  \end{verbatim}
+Try: \texttt{print enumerate(a)}
+
+\section{Problem set 3}
+  As you can guess, idea is to use \texttt{for}!
+
+\begin{description}
+  \item[3.1] Which of the earlier problems is simpler when we use \texttt{for} instead of \texttt{while}? 
+  \item[3.2] Given an empty chessboard and one Bishop placed in any square, say (r, c), generate the list of all squares the Bishop could move to.
+  \item[3.3] Given two real numbers \texttt{a, b}, and an integer \texttt{N}, write a
+  function named \texttt{linspace( a, b, N)} that returns an ordered list
+  of \texttt{N} points starting with \texttt{a} and ending in \texttt{b} and
+  equally spaced.\\
+  For example, \texttt{linspace(0, 5, 11)}, should return, \\
+\begin{verbatim}
+[ 0.0 ,  0.5,  1.0 ,  1.5,  2.0 ,  2.5,  
+  3.0 ,  3.5,  4.0 ,  4.5,  5.0 ]
+\end{verbatim}
+  \item[3.4a] Use the \texttt{linspace} function and generate a list of N tuples of the form\\
+\texttt{[($x_1$,f($x_1$)),($x_2$,f($x_2$)),\ldots,($x_N$,f($x_N$))]}\\for the following functions,
+\begin{itemize}
+  \item \texttt{f(x) = sin(x)}
+  \item \texttt{f(x) = sin(x) + sin(10*x)}.
+\end{itemize}
+
+\item[3.4b] Using the tuples generated earlier, determine the intervals where the roots of the functions lie.
+\end{description}
+
+\section{IO}
+  \subsection{Simple tokenizing and parsing}
+  \begin{verbatim}
+s = """The quick brown fox jumped
+       over the lazy dog"""
+for word in s.split():
+    print word.capitalize()
+  \end{verbatim}
+
+  \begin{description}
+    \item[4.1] Given a string like, ``1, 3-7, 12, 15, 18-21'', produce the list\\
+      \texttt{[1,3,4,5,6,7,12,15,18,19,20,21]}
+\end{description}
+
+  \subsection{File handling}
+\begin{verbatim}
+>>> f = open('/path/to/file_name')
+>>> data = f.read() # Read entire file.
+>>> line = f.readline() # Read one line.
+>>> f.close() # close the file.
+\end{verbatim}
+Writing files
+\begin{verbatim}
+>>> f = open('/path/to/file_name', 'w')
+>>> f.write('hello world\n')
+>>> f.close()
+\end{verbatim}
+
+    \subsection{File and \texttt{for}}
+\begin{verbatim}
+>>> f = open('/path/to/file_name')
+>>> for line in f:
+...     print line
+...
+\end{verbatim}
+
+  \begin{description}
+    \item[4.2] The given file has lakhs of records in the form:
+    \texttt{RGN;ID;NAME;MARK1;\ldots;MARK5;TOTAL;PFW}.
+    Some entries may be empty.  Read the data from this file and print the
+    name of the student with the maximum total marks.
+  \item[4.3] For the same data file compute the average marks in different
+    subjects, the student with the maximum mark in each subject and also
+    the standard deviation of the marks.  Do this efficiently.
+\end{description}
+
+\section{Modules}
+\begin{verbatim}
+>>> sqrt(2)
+Traceback (most recent call last):
+  File "<stdin>", line 1, in <module>
+NameError: name 'sqrt' is not defined
+>>> import math        
+>>> math.sqrt(2)
+1.4142135623730951
+
+>>> from math import sqrt
+>>> from math import *
+>>> from os.path import exists
+\end{verbatim}
+
+  \subsection{Modules: example}
+  \begin{verbatim}
+# --- arith.py ---
+def gcd(a, b):
+    if a%b == 0: return b
+    return gcd(b, a%b)
+def lcm(a, b):
+    return a*b/gcd(a, b)
+# ------------------
+>>> import arith
+>>> arith.gcd(26, 65)
+13
+>>> arith.lcm(26, 65)
+130
+  \end{verbatim}
+\section{Problem set 5}
+  \begin{description}
+    \item[5.1] Put all the functions you have written so far as part of the problems
+  into one module called \texttt{iitb.py} and use this module from IPython.
+  \end{description}
+\newpage
+
+\section{Data Structures}
+
+   \subsection{Dictonary}
+   \begin{verbatim}
+>>>d = { 'Hitchhiker\'s guide' : 42, 'Terminator' : 'I\'ll be back'}
+>>>d['Terminator']
+"I'll be back"
+   \end{verbatim}
+
+\subsection{Problem Set 6.1}
+\begin{description}
+\item[6.1.1] You are given date strings of the form ``29, Jul 2009'', or ``4 January 2008''. In other words a number a string and another number, with a comma sometimes separating the items.Write a function that takes such a string and returns a tuple (yyyy, mm, dd) where all three elements are ints.
+\item[6.1.2] Count word frequencies in a file.
+\item[6.1.3] Find the most used Python keywords in your Python code (import keyword).
+\end{description}
+\subsection{Set}
+\begin{verbatim}
+>>> f10 = set([1,2,3,5,8])
+>>> p10 = set([2,3,5,7])
+>>> f10|p10
+set([1, 2, 3, 5, 7, 8])
+>>> f10&p10
+set([2, 3, 5])
+>>> f10-p10
+set([8, 1])
+>>> p10-f10, f10^p10
+set([7]), set([1, 7, 8])
+>>> set([2,3]) < p10
+True
+>>> set([2,3]) <= p10
+True
+>>> 2 in p10
+True
+>>> 4 in p10
+False
+>>> len(f10)
+5
+\end{verbatim}
+
+\subsection{Problem Set 6.2}
+\begin{description}
+  \item[6.2.1] Given a dictionary of the names of students and their marks, identify how many duplicate marks are there? and what are these?
+  \item[6.2.2] Given a string of the form ``4-7, 9, 12, 15'' find the numbers missing in this list for a given range.
+\end{description}
+\subsection{Fuctions: default arguments}
+\begin{verbatim}
+def ask_ok(prompt, complaint='Yes or no!'):
+    while True:
+        ok = raw_input(prompt)
+        if ok in ('y', 'ye', 'yes'): 
+            return True
+        if ok in ('n', 'no', 'nop',
+                  'nope'): 
+            return False
+        print complaint
+
+ask_ok('?')
+ask_ok('?', '[Y/N]')
+\end{verbatim}
+\newpage
+\subsection{Fuctions: keyword arguments}
+\begin{verbatim}
+def ask_ok(prompt, complaint='Yes or no!'):
+    while True:
+        ok = raw_input(prompt)
+        if ok in ('y', 'ye', 'yes'): 
+            return True
+        if ok in ('n', 'no', 'nop',
+                  'nope'): 
+            return False
+        print complaint
+
+ask_ok(prompt='?')
+ask_ok(prompt='?', complaint='[y/n]')
+ask_ok(complaint='[y/n]', prompt='?')
+\end{verbatim}
+\subsection{List Comprehensions}
+Lets say we want to squares of all the numbers from 1 to 100
+\begin{verbatim}
+squares = []
+for i in range(1, 100):
+    squares.append(i * i)
+# list comprehension
+squares = [i*i for i in range(1, 100)
+           if i % 10 in [1, 2, 5, 7]]
+\end{verbatim}
+\newpage
+\section{Further Reference:}
+\begin{itemize}
+  \item Most referred and trusted material for learning \emph{Python} language is available at docs.python.org/tutorial/
+  \item ``may be one of the thinnest programming language books on my shelf, but it's also one of the best.'' -- \emph{Slashdot, AccordianGuy, September 8, 2004}- available at diveintopython.org/
+  \item How to Think Like a Computer Scientist: Learning with Python available at http://www.openbookproject.net/thinkcs/python/english/ \\
+    ``The concepts covered here apply to all programming languages and to problem solving in general.'' -- \emph{Guido van Rossum, creator of Python}
+\end{itemize}
+\end{document}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day2/handout.tex	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,423 @@
+\documentclass[12pt]{article}
+\usepackage{amsmath}
+\title{Python Workshop\\Problems and Exercises}
+\author{Asokan Pichai\\Prabhu Ramachandran}
+\begin{document}
+\maketitle
+
+\section{Matrices and Arrays \& 2D Plotting}
+\subsection{Matrices and Arrays}
+\begin{verbatim}
+# Simple array math example
+>>> import numpy as np
+>>> a = np.array([1,2,3,4])
+>>> b = np.arange(2,6)
+>>> b
+array([2,3,4,5])
+>>> a*2 + b + 1 # Basic math!
+array([5, 8, 11, 14])
+
+# Pi and e are defined.
+>>> x = np.linspace(0.0, 10.0, 1000)
+>>> x *= 2*np.pi/10 # inplace.
+# apply functions to array.
+>>> y = np.sin(x)
+>>> z = np.exp(y)
+
+>>> x = np.array([1., 2, 3, 4])
+>>> np.size(x)
+4
+>>> x.dtype # What is a.dtype?
+dtype('float64')
+>>> x.shape
+(4,)
+>>> print np.rank(x), x.itemsize
+1 8
+>>> x[0] = 10
+>>> print x[0], x[-1]
+10.0 4.0
+
+>>> a = np.array([[ 0, 1, 2, 3],
+...            [10,11,12,13]])
+>>> a.shape # (rows, columns)
+(2, 4)
+# Accessing and setting values
+>>> a[1,3] 
+13
+>>> a[1,3] = -1
+>>> a[1] # The second row
+array([10,11,12,-1])
+
+>>> b=np.array([[0,2,4,2],[1,2,3,4]])
+>>> np.add(a,b,a)
+>>> np.sum(x,axis=1)
+
+>>> np.greater(a,4)
+>>> np.sqrt(a)
+
+>>> np.array([2,3,4])  
+array([2, 3, 4])
+
+>>> np.linspace(0, 2, 4)   
+array([0.,0.6666667,1.3333333,2.])
+
+>>>np.ones([2,2])
+array([[ 1.,  1.],
+     [ 1.,  1.]])
+
+>>>a = np.array([[1,2,3],[4,5,6]])
+>>>np.ones_like(a)
+array([[1, 1, 1],
+       [1, 1, 1]])
+
+>>> a = np.array([[1,2,3], [4,5,6], 
+               [7,8,9]])
+>>> a[0,1:3]
+array([2, 3])
+>>> a[1:,1:]
+array([[5, 6],
+       [8, 9]])
+>>> a[:,2]
+array([3, 6, 9])
+>>> a[...,2]
+array([3, 6, 9])
+
+>>> a[0::2,0::2]
+array([[1, 3],
+       [7, 9]])
+# Slices are references to the 
+# same memory!
+
+>>> np.random.rand(3,2)
+array([[ 0.96276665,  0.77174861],
+       [ 0.35138557,  0.61462271],
+       [ 0.16789255,  0.43848811]])
+>>> np.random.randint(1,100)
+42
+\end{verbatim}
+
+\subsection{Problem Set}
+\begin{verbatim}
+    >>> from scipy import misc
+    >>> A=misc.imread(name)
+    >>> misc.imshow(A)
+\end{verbatim}
+\begin{enumerate}
+  \item Convert an RGB image to Grayscale. $ Y = 0.5R + 0.25G + 0.25B $.
+  \item Scale the image to 50\%.
+  \item Introduce some random noise.
+  \item Smooth the image using a mean filter.
+  \\\small{Each element in the array is replaced by mean of all the neighbouring elements}
+  \\\small{How fast does your code run?}
+\end{enumerate}
+
+\subsection{2D Plotting}
+\begin{verbatim}
+$ ipython -pylab
+>>> x = linspace(0, 2*pi, 1000)
+>>> plot(x, sin(x)) 
+>>> plot(x, sin(x), 'ro')
+>>> xlabel(r'$\chi$', color='g')
+# LaTeX markup!
+>>> ylabel(r'sin($\chi$)', color='r')
+>>> title('Simple figure', fontsize=20)
+>>> savefig('/tmp/test.eps')
+
+# Set properties of objects:
+>>> l, = plot(x, sin(x))
+# Why "l,"?
+>>> setp(l, linewidth=2.0, color='r')
+>>> l.set_linewidth(2.0)
+>>> draw() # Redraw.
+>>> setp(l) # Print properties.
+>>> clf() # Clear figure.
+>>> close() # Close figure.
+
+>>> w = arange(-2,2,.1)
+>>> plot(w,exp(-(w*w))*cos)
+>>> ylabel('$f(\omega)$')
+>>> xlabel('$\omega$')
+>>> title(r"$f(\omega)=e^{-\omega^2}
+            cos({\omega^2})$")
+>>> annotate('maxima',xy=(0, 1), 
+             xytext=(1, 0.8), 
+             arrowprops=dict(
+             facecolor='black', 
+             shrink=0.05))
+
+>>> x = linspace(0, 2*np.pi, 1000)
+>>> plot(x, cos(5*x), 'r--', 
+         label='cosine')
+>>> plot(x, sin(5*x), 'g--', 
+         label='sine')
+>>> legend() 
+# Or use:
+>>> legend(['cosine', 'sine'])
+
+>>> figure(1)
+>>> plot(x, sin(x))
+>>> figure(2)
+>>> plot(x, tanh(x))
+>>> figure(1)
+>>> title('Easy as 1,2,3')
+
+\end{verbatim}
+
+\subsection{Problem Set}
+  \begin{enumerate}
+    \item Write a function that plots any regular n-gon given n.
+    \item Consider the logistic map, $f(x) = kx(1-x)$, plot it for
+          $k=2.5, 3.5$ and $4$ in the same plot.
+
+  \item Consider the iteration $x_{n+1} = f(x_n)$ where $f(x) =
+        kx(1-x)$.  Plot the successive iterates of this process.
+  \item Plot this using a cobweb plot as follows:
+  \begin{enumerate}
+    \item Start at $(x_0, 0)$
+    \item Draw line to $(x_i, f(x_i))$; 
+    \item Set $x_{i+1} = f(x_i)$
+    \item Draw line to $(x_i, x_i)$
+    \item Repeat from 2 for as long as you want 
+  \end{enumerate}
+\end{enumerate}
+
+\section{Advanced Numpy}
+
+\subsection{Broadcasting}
+\begin{verbatim}
+>>> a = np.arange(4)
+>>> b = np.arange(5)
+>>> a+b
+>>> a+3
+>>> c=np.array([3])
+>>> a+c
+>>> b+c
+
+>>> a = np.arange(4)
+>>> a+3
+array([3, 4, 5, 6])
+
+>>> x = np.ones((3, 5))
+>>> y = np.ones(8)
+>>> (x[..., None] + y).shape
+(3, 5, 8)
+
+\end{verbatim}
+
+\subsection{Copies \& Views}
+\begin{verbatim}
+>>> a = np.array([[1,2,3],[4,5,6]])
+>>> b = a
+>>> b is a
+>>> b[0,0]=0; print a
+>>> c = a.view()
+>>> c is a
+>>> c.base is a
+>>> c.flags.owndata
+>>> d = a.copy()
+>>> d.base is a
+>>> d.flags.owndata
+
+>>> a = np.arange(1,9)
+>>> a.shape=3,3
+>>> b = a[0,1:3]
+>>> c = a[0::2,0::2]
+>>> a.flags.owndata
+>>> b.flags.owndata
+>>> b.base
+>>> c.base is a
+
+>>> b = a[np.array([0,1,2])]
+array([[1, 2, 3],
+       [4, 5, 6],
+       [7, 8, 9]])
+>>> b.flags.owndata
+>>> abool=np.greater(a,2)
+>>> c = a[abool]
+>>> c.flags.owndata
+
+\end{verbatim}
+
+\section{Scipy}
+\subsection{Linear Algebra}
+\begin{verbatim}
+>>> import scipy as sp
+>>> from scipy import linalg
+>>> A=sp.mat(np.arange(1,10))
+>>> A.shape=3,3
+>>> linalg.inv(A)
+>>> linalg.det(A)
+>>> linalg.norm(A)
+>>> linalg.expm(A) #logm
+>>> linalg.sinm(A) #cosm, tanm, ...
+
+>>> A = sp.mat(np.arange(1,10))
+>>> A.shape=3,3
+>>> linalg.lu(A)
+>>> linalg.eig(A)
+>>> linalg.eigvals(A)
+\end{verbatim}
+
+\subsection{Solving Linear Equations}
+
+\begin{align*}
+  3x + 2y - z  & = 1 \\
+  2x - 2y + 4z  & = -2 \\
+  -x + \frac{1}{2}y -z & = 0
+\end{align*}
+To Solve this, 
+\begin{verbatim}
+>>> A = sp.mat([[3,2,-1],[2,-2,4]
+              ,[-1,1/2,-1]])
+>>> B = sp.mat([[1],[-2],[0]])
+>>> linalg.solve(A,B)
+\end{verbatim}
+
+\subsection{Integrate}
+\subsubsection{Quadrature}
+Calculate the area under $(sin(x) + x^2)$ in the range $(0,1)$
+\begin{verbatim}
+>>> def f(x):
+        return np.sin(x)+x**2
+>>> integrate.quad(f, 0, 1)
+\end{verbatim}
+
+\subsubsection{ODE Integration}
+Numerically solve ODEs\\
+\begin{align*}
+\frac{dx}{dt} &=-e^{-t}x^2\\ 
+         x(0) &=2    
+\end{align*}
+\begin{verbatim}
+>>> def dx_dt(x,t):
+...     return -np.exp(-t)*x**2
+>>> x=integrate.odeint(dx_dt, 2, t)
+>>> plt.plot(x,t)
+\end{verbatim}
+
+\subsection{Interpolation}
+\subsubsection{1D Interpolation}
+\begin{verbatim}
+>>> from scipy import interpolate
+>>> interpolate.interp1d?
+>>> x = np.arange(0,2*np.pi,np.pi/4)
+>>> y = np.sin(x)
+>>> fl = interpolate.interp1d(
+            x,y,kind='linear')
+>>> fc = interpolate.interp1d(
+             x,y,kind='cubic')
+>>> fl(np.pi/3)
+>>> fc(np.pi/3)
+\end{verbatim}
+
+\subsubsection{Splines}
+Plot the Cubic Spline of $sin(x)$
+\begin{verbatim}
+>>> x = np.arange(0,2*np.pi,np.pi/4)
+>>> y = np.sin(x)
+>>> tck = interpolate.splrep(x,y)
+>>> X = np.arange(0,2*np.pi,np.pi/50)
+>>> Y = interpolate.splev(X,tck,der=0)
+>>> plt.plot(x,y,'o',x,y,X,Y)
+>>> plt.show()
+\end{verbatim}
+
+\subsection{Signal \& Image Processing}
+Applying a simple median filter
+\begin{verbatim}
+>>> from scipy import signal, ndimage
+>>> from scipy import lena
+>>> A=lena().astype('float32')
+>>> B=signal.medfilt2d(A)
+>>> imshow(B)
+\end{verbatim}
+Zooming an array - uses spline interpolation
+\begin{verbatim}
+>>> b=ndimage.zoom(A,0.5)
+>>> imshow(b)
+\end{verbatim}
+
+\section{3D Data Visualization}
+\subsection{Using mlab}
+\begin{verbatim}
+>>> from enthought.mayavi import mlab
+
+>>> mlab.test_<TAB>
+>>> mlab.test_contour3d()
+>>> mlab.test_contour3d??
+\end{verbatim}
+
+\subsubsection{Plotting Functions}
+\begin{verbatim}
+>>> from numpy import *
+>>> t = linspace(0, 2*pi, 50)
+>>> u = cos(t)*pi
+>>> x, y, z = sin(u), cos(u), sin(t)
+
+>>> x = mgrid[-3:3:100j,-3:3:100j]
+>>> z = sin(x*x + y*y)
+>>> mlab.surf(x, y, z)
+\end{verbatim}
+
+\subsubsection{Large 2D Data}
+\begin{verbatim}
+>>> mlab.mesh(x, y, z)
+
+>>> phi, theta = numpy.mgrid[0:pi:20j, 
+...                         0:2*pi:20j]
+>>> x = sin(phi)*cos(theta)
+>>> y = sin(phi)*sin(theta)
+>>> z = cos(phi)
+>>> mlab.mesh(x, y, z, 
+...           representation=
+...           'wireframe')
+\end{verbatim}
+
+\subsubsection{Large 3D Data}
+\begin{verbatim}
+>>> x, y, z = ogrid[-5:5:64j, 
+...                -5:5:64j, 
+...                -5:5:64j]
+>>> mlab.contour3d(x*x*0.5 + y*y + 
+                   z*z*2)
+
+>>> mlab.test_quiver3d()
+\end{verbatim}
+
+\subsection{Motivational Problem}
+Atmospheric data of temperature over the surface of the earth. Let temperature ($T$) vary linearly with height ($z$)\\
+$T = 288.15 - 6.5z$
+
+\begin{verbatim}
+lat = linspace(-89, 89, 37)
+lon = linspace(0, 360, 37)
+z = linspace(0, 100, 11)
+\end{verbatim}
+
+\begin{verbatim}
+x, y, z = mgrid[0:360:37j,-89:89:37j,
+                0:100:11j]
+t = 288.15 - 6.5*z
+mlab.contour3d(x, y, z, t)
+mlab.outline()
+mlab.colorbar()
+\end{verbatim}
+
+\subsection{Lorenz equation}
+\begin{eqnarray*}
+\frac{d x}{dt} &=& s (y-x)\\
+\frac{d y}{d t} &=& rx -y -xz\\
+\frac{d z}{d t} &=& xy - bz\\
+\end{eqnarray*}
+
+Let $s=10,$
+$r=28,$ 
+$b=8./3.$
+
+\begin{verbatim}
+x, y, z = mgrid[-50:50:20j,-50:50:20j,
+                -10:60:20j]
+
+\end{verbatim}
+
+\end{document}
--- a/day2/session1.tex	Thu Oct 08 22:48:06 2009 +0530
+++ b/day2/session1.tex	Thu Oct 08 22:48:59 2009 +0530
@@ -146,16 +146,25 @@
   \frametitle{Examples of \num}
 \begin{lstlisting}
 # Simple array math example
->>> from numpy import *
->>> a = array([1,2,3,4])
->>> b = array([2,3,4,5])
+>>> import numpy as np
+>>> a = np.array([1,2,3,4])
+>>> b = np.arange(2,6)
+>>> b
+array([2,3,4,5])
 >>> a*2 + b + 1 # Basic math!
 array([5, 8, 11, 14])
+\end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Examples of \num}
+\begin{lstlisting}
 # Pi and e are defined.
->>> x = linspace(0.0, 10.0, 1000)
->>> x *= 2*pi/10 # inplace.
+>>> x = np.linspace(0.0, 10.0, 1000)
+>>> x *= 2*np.pi/10 # inplace.
 # apply functions to array.
->>> y = sin(x)
+>>> y = np.sin(x)
+>>> z = np.exp(y)
 \end{lstlisting}
 \inctime{5}
 \end{frame}
@@ -178,14 +187,14 @@
   \frametitle{More examples of \num}
 \vspace*{-8pt}
 \begin{lstlisting}
->>> x = array([1., 2, 3, 4])
->>> size(x)
+>>> x = np.array([1., 2, 3, 4])
+>>> np.size(x)
 4
 >>> x.dtype # What is a.dtype?
 dtype('float64')
 >>> x.shape
 (4,)
->>> print rank(x), x.itemsize
+>>> print np.rank(x), x.itemsize
 1 8
 >>> x[0] = 10
 >>> print x[0], x[-1]
@@ -196,7 +205,7 @@
 \begin{frame}[fragile]
   \frametitle{Multi-dimensional arrays}
 \begin{lstlisting}
->>> a = array([[ 0, 1, 2, 3],
+>>> a = np.array([[ 0, 1, 2, 3],
 ...            [10,11,12,13]])
 >>> a.shape # (rows, columns)
 (2, 4)
@@ -206,78 +215,85 @@
 >>> a[1,3] = -1
 >>> a[1] # The second row
 array([10,11,12,-1])
-
 \end{lstlisting}
 \end{frame}
+
 \begin{frame}[fragile]
   \frametitle{Array math}
   \begin{itemize}
   \item Basic \alert{elementwise} math (given two arrays \typ{a, b}):
       \typ{+, -, *, /, \%}
-  \item Inplace operators: \typ{a += b}, or \typ{add(a, b, a)} etc. 
-  \item \typ{sum(x, axis=0)}, 
-        \typ{product(x, axis=0)},
-        \typ{dot(a, bp)}   
+  \item Inplace operators: \typ{a += b}, or \typ{np.add(a, b, a)} etc. 
+  \item \typ{np.sum(x, axis=0)}, 
+        \typ{np.product(x, axis=0)},
+        \typ{np.dot(a, bp)}   
   \end{itemize}
+\begin{lstlisting}
+>>> b=np.array([[0,2,4,2],[1,2,3,4]])
+>>> np.add(a,b,a)
+>>> np.sum(x,axis=1)
+\end{lstlisting}
 \end{frame}
 
 \begin{frame}[fragile]
   \frametitle{Array math cont.}
   \begin{itemize}
-  \item Logical operations: \typ{equal (==)}, \typ{not\_equal (!=)},
-    \typ{less (<)}, \typ{greater (>)} etc.
-  \item Trig and other functions: \typ{sin(x),}
-        \typ{arcsin(x), sinh(x),}
-      \typ{exp(x), sqrt(x)} etc.
+  \item Logical operations: \typ{np.equal (==)}, \typ{np.not\_equal (!=)},
+    \typ{np.less (<)}, \typ{np.greater (>)} etc.
+  \item Trig and other functions: \typ{np.sin(x),}
+        \typ{np.arcsin(x), np.sinh(x),}
+      \typ{np.exp(x), np.sqrt(x)} etc.
   \end{itemize}
+\begin{lstlisting}
+>>> np.greater(a,4)
+>>> np.sqrt(a)
+\end{lstlisting}
 \inctime{10}
 \end{frame}
 
 \subsection{Array Creation \& Slicing, Striding Arrays}
 \begin{frame}[fragile]
   \frametitle{Array creation functions}
-  \begin {block}{\typ{array(object, dtype=None, ...)}}
-  \begin{lstlisting}
-  >>> array( [2,3,4] )  
-  array([2, 3, 4])
-  \end{lstlisting}
-  \end {block}
-  \begin{block}{\typ{linspace(start, stop, num=50, ...)}}
-  \begin{lstlisting}
-  >>> linspace( 0, 2, 4 )   
-  array([0.,0.6666667,1.3333333,2.])
-  \end{lstlisting}
-  \end{block}
   \begin{itemize}
-  \item also try \typ{arange} command
+    \item {\typ{np.array(object,dtype=None,...)}
+    \begin{lstlisting}
+>>> np.array([2,3,4])  
+array([2, 3, 4])
+    \end{lstlisting}
+    \item \typ{np.linspace(start,stop,...)}
+    \begin{lstlisting}
+>>> np.linspace(0, 2, 4)   
+array([0.,0.6666667,1.3333333,2.])
+    \end{lstlisting}
+    \item Also try \typ{np.arange}
   \end{itemize}
 \end{frame}
 
 \begin{frame}[fragile]
   \frametitle{Array creation functions cont.}
   \begin{itemize}  
-  \item \typ{ones(shape, dtype=None, ...)}  
+  \item \typ{np.ones(shape, dtype=None, ...)}  
   \begin{lstlisting} 
-  >>>ones([2,2])
-  array([[ 1.,  1.],
-       [ 1.,  1.]])
+>>>np.ones([2,2])
+array([[ 1.,  1.],
+     [ 1.,  1.]])
   \end{lstlisting}  
-  \item \typ{identity(n)} 
-  \item \typ{ones\_like(x)}  
+  \item \typ{np.identity(n)} 
+  \item \typ{np.ones\_like(x)}  
   \begin{lstlisting} 
-  >>>a = array([[1,2,3],[4,5,6]])
-  >>>ones_like(a)
-    array([[1, 1, 1],
-           [1, 1, 1]])
+>>>a = np.array([[1,2,3],[4,5,6]])
+>>>np.ones_like(a)
+array([[1, 1, 1],
+       [1, 1, 1]])
   \end{lstlisting}
-  \item check out \typ{zeros, zeros\_like, empty}
+  \item Also try \typ{zeros, zeros\_like, empty}
   \end{itemize}
 \end{frame}
 
 \begin{frame}[fragile]
   \frametitle{Slicing arrays}
 \begin{lstlisting}
->>> a = array([[1,2,3], [4,5,6], 
+>>> a = np.array([[1,2,3], [4,5,6], 
                [7,8,9]])
 >>> a[0,1:3]
 array([2, 3])
@@ -327,8 +343,8 @@
     \item Scale the image to 50\%
     \item Introduce some random noise
     \item Smooth the image using a mean filter
-      \\\small{Take the mean of all the neighbouring elements}
-      \\\small{How fast can you do it?}
+      \\\small{Each element in the array is replaced by mean of all the neighbouring elements}
+      \\\small{How fast does your code run?}
     \end{enumerate}
 \inctime{15}
 \end{frame}
@@ -408,7 +424,7 @@
 \begin{frame}[fragile]
   \frametitle{Legends}
 \begin{lstlisting}
->>> x = linspace(0, 2*pi, 1000)
+>>> x = linspace(0, 2*np.pi, 1000)
 >>> plot(x, cos(5*x), 'r--', 
          label='cosine')
 >>> plot(x, sin(5*x), 'g--', 
@@ -435,7 +451,7 @@
 \end{frame}
 
 \begin{frame}[fragile]
-    \frametitle{Note: \typ{pylab} in Python scripts}
+    \frametitle{\typ{pylab} in Python scripts}
 \begin{lstlisting}
 import pylab
 x = pylab.linspace(0, 20, 1000)
@@ -444,7 +460,7 @@
 # Can also use:
 from pylab import linspace, sin, plot
 \end{lstlisting}
-\inctime{5}
+\inctime{10}
 \end{frame}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -742,7 +758,6 @@
     \tiny
     For details see \url{http://matplotlib.sourceforge.net/screenshots/plotmap.py}
   \end{center}
-\inctime{5}
 \end{frame}
 
 
@@ -753,6 +768,7 @@
   \item \url{http://matplotlib.sf.net/tutorial.html}
   \item \url{http://matplotlib.sf.net/screenshots.html}
   \end{itemize}
+\inctime{5}
 \end{frame}
 
 \begin{frame}
--- a/day2/session2.tex	Thu Oct 08 22:48:06 2009 +0530
+++ b/day2/session2.tex	Thu Oct 08 22:48:59 2009 +0530
@@ -117,34 +117,52 @@
   \maketitle
 \end{frame}
 
+\section{Advanced Numpy}
 \begin{frame}[fragile]
   \frametitle{Broadcasting}
+  Try it!
+  \begin{lstlisting}
+    >>> a = np.arange(4)
+    >>> b = np.arange(5)
+    >>> a+b
+    >>> a+3
+    >>> c=np.array([3])
+    >>> a+c
+    >>> b+c
+  \end{lstlisting}
   \begin{itemize}
-    \item Used so that functions can take inputs that are not of the same shape.
-    \item 2 rules -
-      \begin{enumerate}
-      \item 1 (repeatedly) pre-pended to shapes of smaller arrays
-      \item Size 1 in a dimension -> Largest size in that dimension
-      \end{enumerate}
+    \item Enter Broadcasting!
   \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Broadcasting}
   \begin{columns}
     \column{0.65\textwidth}
     \hspace*{-1.5in}
     \begin{lstlisting}
-      >>> x = np.arange(4)
-      >>> x+3
+      >>> a = np.arange(4)
+      >>> a+3
       array([3, 4, 5, 6])
     \end{lstlisting}
     \column{0.35\textwidth}
     \includegraphics[height=0.7in, interpolate=true]{data/broadcast_scalar}
   \end{columns}
+  \begin{itemize}
+    \item Allows functions to take inputs not of the same shape
+    \item 2 rules -
+      \begin{enumerate}
+      \item 1 is (repeatedly) prepended to shapes of smaller arrays
+      \item Size 1 in a dimension changed to Largest size in that dimension
+      \end{enumerate}
+  \end{itemize}
 \end{frame}
 
 \begin{frame}[fragile]
   \frametitle{Broadcasting in 3D}
     \begin{lstlisting}
-      >>> x = np.zeros((3, 5))
-      >>> y = np.zeros(8)
+      >>> x = np.ones((3, 5))
+      >>> y = np.ones(8)
       >>> (x[..., None] + y).shape
       (3, 5, 8)
     \end{lstlisting}
@@ -157,14 +175,34 @@
 
 \begin{frame}[fragile]
   \frametitle{Copies \& Views}
+  Try it!
   \begin{lstlisting}
-    >>> a = array([[1,2,3], [4,5,6],     
-                   [7,8,9]])
-    >>> a[0,1:3]
-    array([2, 3])
-    >>> a[0::2,0::2]
-    array([[1, 3],
-          [7, 9]])
+    >>> a = np.array([[1,2,3],[4,5,6]])
+    >>> b = a
+    >>> b is a
+    >>> b[0,0]=0; print a
+    >>> c = a.view()
+    >>> c is a
+    >>> c.base is a
+    >>> c.flags.owndata
+    >>> d = a.copy()
+    >>> d.base is a
+    >>> d.flags.owndata
+  \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Copies \& Views}
+  Try it!
+  \begin{lstlisting}
+    >>> a = np.arange(1,9)
+    >>> a.shape=3,3
+    >>> b = a[0,1:3]
+    >>> c = a[0::2,0::2]
+    >>> a.flags.owndata
+    >>> b.flags.owndata
+    >>> b.base
+    >>> c.base is a
   \end{lstlisting}
   \begin{itemize}
   \item Slicing and Striding just reference the same memory
@@ -175,37 +213,23 @@
 \begin{frame}[fragile]
   \frametitle{Copies contd \ldots}
   \begin{lstlisting}
-    >>> a[np.array([0,1,2])]
+    >>> b = a[np.array([0,1,2])]
     array([[1, 2, 3],
            [4, 5, 6],
            [7, 8, 9]])
+    >>> b.flags.owndata
+    >>> abool=np.greater(a,2)
+    >>> c = a[abool]
+    >>> c.flags.owndata
   \end{lstlisting}
   \begin{itemize}
-  \item Index arrays or Boolean arrays produce copies
+  \item Indexing arrays or Boolean arrays produce copies
   \end{itemize}
 \inctime{15}
 \end{frame}
 
-\begin{frame}
-  \frametitle{More Numpy Functions \& Methods}
-  More functions
-  \begin{itemize}
-    \item \typ{take}
-    \item \typ{choose}
-    \item \typ{where}
-    \item \typ{compress}
-    \item \typ{concatenate}
-  \end{itemize}
-  Ufunc methods 
-  \begin{itemize}
-    \item \typ{reduce}
-    \item \typ{accumulate}
-    \item \typ{outer}
-    \item \typ{reduceat}
-  \end{itemize}
-\inctime{5}
-\end{frame}
-
+\section{SciPy}
+\subsection{Introduction}
 \begin{frame}
     {Intro to SciPy}
   \begin{itemize}
@@ -235,37 +259,72 @@
 \end{frame}
 
 \begin{frame}[fragile]
-  \frametitle{Linear Algebra}
-  \typ{>>> from scipy import linalg}
+  \frametitle{SciPy - Functions \& Submodules}
   \begin{itemize}
-    \item \typ{linalg.det, linalg.norm}
-    \item \typ{linalg.eig, linalg.lu}
-    \item \typ{linalg.expm, linalg.logm}
-    \item \typ{linalg.sinm, linalg.sinhm}
+    \item All \typ{numpy} functions are in \typ{scipy} namespace
+    \item Domain specific functions organized into subpackages
+    \item Subpackages need to be imported separately
   \end{itemize}
+  \begin{lstlisting}
+    >>> from scipy import linalg
+  \end{lstlisting}
+\end{frame}
+
+\subsection{Linear Algebra}
+\begin{frame}[fragile]
+  \frametitle{Linear Algebra}
+  Try it!
+  \begin{lstlisting}
+    >>> import scipy as sp
+    >>> from scipy import linalg
+    >>> A=sp.mat(np.arange(1,10))
+    >>> A.shape=3,3
+    >>> linalg.inv(A)
+    >>> linalg.det(A)
+    >>> linalg.norm(A)
+    >>> linalg.expm(A) #logm
+    >>> linalg.sinm(A) #cosm, tanm, ...
+  \end{lstlisting}
 \end{frame}
 
 \begin{frame}[fragile]
-  \frametitle{Linear Algebra \ldots}
+  \frametitle{Linear Algebra ...}
+  Try it!
+  \begin{lstlisting}
+    >>> A = sp.mat(np.arange(1,10))
+    >>> A.shape=3,3
+    >>> linalg.lu(A)
+    >>> linalg.eig(A)
+    >>> linalg.eigvals(A)
+  \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Solving Linear Equations}
   \begin{align*}
     3x + 2y - z  & = 1 \\
     2x - 2y + 4z  & = -2 \\
     -x + \frac{1}{2}y -z & = 0
   \end{align*}
+  To Solve this, 
   \begin{lstlisting}
+    >>> A = sp.mat([[3,2,-1],[2,-2,4]
+                  ,[-1,1/2,-1]])
+    >>> B = sp.mat([[1],[-2],[0]])
     >>> linalg.solve(A,B)
   \end{lstlisting}
 \inctime{15}
 \end{frame}
 
+\subsection{Integration}
 \begin{frame}[fragile]
+  \frametitle{Integrate}
   \begin{itemize}
     \item Integrating Functions given function object
     \item Integrating Functions given fixed samples
     \item Numerical integrators of ODE systems
   \end{itemize}
-  \frametitle{Integrate}
-  Calculate $\int^1_0sin(x) + x^2$
+  Calculate the area under $(sin(x) + x^2)$ in the range $(0,1)$
   \begin{lstlisting}
     >>> def f(x):
             return np.sin(x)+x**2
@@ -277,39 +336,53 @@
   \frametitle{Integrate \ldots}
   Numerically solve ODEs\\
   \begin{align*}
-  \frac{dx}{dt}&=-e^{(-t)}x^2(t)\\ 
+  \frac{dx}{dt}&=-e^{-t}x^2\\ 
            x(0)&=2    
   \end{align*}
   \begin{lstlisting}
-    def dx_dt(x,t):
+>>> def dx_dt(x,t):
         return -np.exp(-t)*x**2
 
-    x=integrate.odeint(dx_dt, 2, t)
-    plt.plot(x,t)
+>>> x=integrate.odeint(dx_dt, 2, t)
+>>> plt.plot(x,t)
   \end{lstlisting}
 \inctime{10}
 \end{frame}
 
+\subsection{Interpolation}
 \begin{frame}[fragile]
   \frametitle{Interpolation}
-  \begin{itemize}
-    \item \typ{interpolate.interp1d, ...}
-    \item \typ{interpolate.splrep, splev}
-  \end{itemize}
-  Cubic Spline of $sin(x)$
+  Try it!
   \begin{lstlisting}
-    x = np.arange(0,2*np.pi,np.pi/8)
-    y = np.sin(x)
-    t = interpolate.splrep(x,y,s=0)
-    X = np.arange(0,2*np.pi,np.pi/50)
-    Y = interpolate.splev(X,t,der=0)
+>>> from scipy import interpolate
+>>> interpolate.interp1d?
+>>> x = np.arange(0,2*np.pi,np.pi/4)
+>>> y = np.sin(x)
+>>> fl = interpolate.interp1d(
+            x,y,kind='linear')
+>>> fc = interpolate.interp1d(
+             x,y,kind='cubic')
+>>> fl(np.pi/3)
+>>> fc(np.pi/3)
+  \end{lstlisting}
+\end{frame}
 
-    plt.plot(x,y,'o',x,y,X,Y)
-    plt.show()
+\begin{frame}[fragile]
+  \frametitle{Interpolation - Splines}
+  Plot the Cubic Spline of $sin(x)$
+  \begin{lstlisting}
+>>> x = np.arange(0,2*np.pi,np.pi/4)
+>>> y = np.sin(x)
+>>> tck = interpolate.splrep(x,y)
+>>> X = np.arange(0,2*np.pi,np.pi/50)
+>>> Y = interpolate.splev(X,tck,der=0)
+>>> plt.plot(x,y,'o',x,y,X,Y)
+>>> plt.show()
   \end{lstlisting}
 \inctime{10}
 \end{frame}
 
+\subsection{Signal Processing}
 \begin{frame}[fragile]
   \frametitle{Signal \& Image Processing}
     \begin{itemize}
@@ -330,19 +403,18 @@
   \frametitle{Signal \& Image Processing}
   Applying a simple median filter
   \begin{lstlisting}
-    from scipy import signal, ndimage
-    from scipy import lena
-    A=lena().astype('float32')
-    B=signal.medfilt2d(A)
-    imshow(B)
+>>> from scipy import signal, ndimage
+>>> from scipy import lena
+>>> A=lena().astype('float32')
+>>> B=signal.medfilt2d(A)
+>>> imshow(B)
   \end{lstlisting}
   Zooming an array - uses spline interpolation
   \begin{lstlisting}
-    b=ndimage.zoom(A,0.5)
-    imshow(b)
+>>> b=ndimage.zoom(A,0.5)
+>>> imshow(b)
+  \end{lstlisting}
     \inctime{5}
-  \end{lstlisting}
-
 \end{frame}
 
 \begin{frame}[fragile]
@@ -351,7 +423,8 @@
   \begin{equation*}
   \frac{d^2x}{dt^2}+\mu(x^2-1)\frac{dx}{dt}+x= 0
   \end{equation*}
-\inctime{25}
+  Make a plot of $\frac{dx}{dt}$ vs. $x$.
+\inctime{30}
 \end{frame}
 
 
@@ -362,5 +435,3 @@
     - random number generation.
     - Image manipulation: jigsaw puzzle.
     - Monte-carlo integration.
-
-
--- a/day2/session3.tex	Thu Oct 08 22:48:06 2009 +0530
+++ b/day2/session3.tex	Thu Oct 08 22:48:59 2009 +0530
@@ -22,7 +22,7 @@
 
 \mode<presentation>
 {
-  \usetheme{CambridgeUS}
+  \usetheme{Warsaw}
   %\usetheme{Boadilla}
   %\usetheme{default}
   \useoutertheme{split}
@@ -95,7 +95,7 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Title page
-\title[]{3D data Vizualization\\ \& \\Test Driven Approach}
+\title[]{3D data Visualization}
 
 \author[FOSSEE Team] {Asokan Pichai\\Prabhu Ramachandran}
 
@@ -192,7 +192,67 @@
 \inctime{10}
 \end{frame}
 
-\section{Tools at your disposal:}
+\section{Tools at your disposal}
+
+\subsection{Mayavi2.0}
+
+\begin{frame}
+  \frametitle{Introduction to Mayavi}
+  \begin{itemize}
+  \item Most scientists not interested in details of visualization
+  \item Visualization of data files with a nice UI
+  \item Interactive visualization of data (think Matlab)
+  \item Embedding visualizations in applications
+  \item Customization
+  \end{itemize}
+  \pause
+  \begin{block}{The Goal}
+      Provide a \alert{flexible} library/app for every one of these needs!
+  \end{block}
+\end{frame}
+
+\begin{frame}
+    {Overview of features}
+      \vspace*{-0.3in}
+  \begin{center}    
+    \hspace*{-0.2in}\pgfimage[width=5in]{MEDIA/m2/m2_app3_3}
+  \end{center}    
+\end{frame}
+
+
+\begin{frame}
+    \frametitle{Mayavi in applications}
+      \vspace*{-0.3in}
+  \begin{center}    
+    \hspace*{-0.2in}\pgfimage[width=4.5in]{MEDIA/m2/m2_envisage}
+  \end{center}
+\end{frame}
+
+\begin{frame}
+    {Exploring the documentation}
+    \begin{center}
+    \pgfimage[width=4in]{MEDIA/m2/m2_ug_doc}
+    \end{center}
+\end{frame}
+
+
+\begin{frame}
+  \frametitle{Summary}
+      \begin{itemize}
+          \item \url{http://code.enthought.com/projects/mayavi}
+          \item Uses VTK (\url{www.vtk.org})
+          \item BSD license
+          \item Linux, win32 and Mac OS X
+          \item Highly scriptable
+          \item Embed in Traits UIs (wxPython and PyQt4)
+          \item Envisage Plugins
+          \item Debian/Ubuntu/Fedora
+          \item \alert{Pythonic}
+      \end{itemize}
+    
+      \inctime{10}
+
+\end{frame}
 
 \subsection{mlab}
 
@@ -220,7 +280,7 @@
 \end{frame}
 
 \begin{frame}[fragile]
-    \frametitle{Using mlab:}
+    \frametitle{Using mlab}
 
     \begin{lstlisting}
 >>> from enthought.mayavi import mlab
@@ -228,7 +288,7 @@
 
     \vspace*{0.5in}
 
-    \myemph{\Large Try these:}
+    \myemph{\Large Try these}
 
     \vspace*{0.25in}
 
@@ -249,7 +309,7 @@
             \item Mouse
             \item Keyboard
             \item Toolbar
-            \item Mayavi icon(wait for it...) \pgfimage[width=0.2in]{MEDIA/m2/m2_icon}
+            \item Mayavi icon\pgfimage[width=0.2in]{MEDIA/m2/m2_icon}
         \end{itemize}
     \end{columns}
 \end{frame}
@@ -319,7 +379,8 @@
 >>> y = sin(phi)*sin(theta)
 >>> z = cos(phi)
 >>> mlab.mesh(x, y, z, 
-...           representation='wireframe')
+...           representation=
+...           'wireframe')
 \end{lstlisting}
 
 \end{frame}
@@ -356,66 +417,6 @@
 \inctime{20}
 \end{frame}
 
-\subsection{Mayavi2.0}
-
-\begin{frame}
-  \frametitle{Introduction to Mayavi}
-  \begin{itemize}
-  \item Most scientists not interested in details of visualization
-  \item Visualization of data files with a nice UI
-  \item Interactive visualization of data (think Matlab)
-  \item Embedding visualizations in applications
-  \item Customization
-  \end{itemize}
-  \pause
-  \begin{block}{The Goal}
-      Provide a \alert{flexible} library/app for every one of these needs!
-  \end{block}
-\end{frame}
-
-\begin{frame}
-    {Overview of features}
-      \vspace*{-0.3in}
-  \begin{center}    
-    \hspace*{-0.2in}\pgfimage[width=5in]{MEDIA/m2/m2_app3_3}
-  \end{center}    
-\end{frame}
-
-
-\begin{frame}
-    \frametitle{Mayavi in applications}
-      \vspace*{-0.3in}
-  \begin{center}    
-    \hspace*{0.2in}\pgfimage[width=4.5in]{MEDIA/m2/m2_envisage}
-  \end{center}
-\end{frame}
-
-\begin{frame}
-    {Exploring the documentation}
-    \begin{center}
-    \pgfimage[width=4.5in]{MEDIA/m2/m2_ug_doc}
-    \end{center}
-\end{frame}
-
-
-\begin{frame}
-  \frametitle{Summary}
-      \begin{itemize}
-          \item \url{http://code.enthought.com/projects/mayavi}
-          \item Uses VTK (\url{www.vtk.org})
-          \item BSD license
-          \item Linux, win32 and Mac OS X
-          \item Highly scriptable
-          \item Embed in Traits UIs (wxPython and PyQt4)
-          \item Envisage Plugins
-          \item Debian/Ubuntu/Fedora
-          \item \alert{Pythonic}
-      \end{itemize}
-    
-      \inctime{10}
-
-\end{frame}
-
 \begin{frame}
     {Getting hands dirty!}
 
@@ -468,118 +469,6 @@
   \end{lstlisting}
 \inctime{20}
 \end{frame}
-
-\section{Test Driven Approach}
-
-\begin{frame}
-    \frametitle{Testing code with \typ{nosetests}}
-   
-    \begin{itemize}
-        \item Writing tests is really simple!
-
-        \item Using nose
-
-        \item Example!
-    \end{itemize}
-\end{frame}
-
-\begin{frame}
-    \frametitle{Need of Testing!}
-   
-    \begin{itemize}
-        \item Quality
-
-        \item Regression
-
-        \item Documentation
-    \end{itemize}
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{Nosetest}
-  \begin{lstlisting}
-def gcd(a, b):
-    """Returns gcd of a and b, 
-     handles only positive numbers."""
-    if a%b == 0: return b
-    return gcd(b, a%b)
-def lcm(a, b):
-    return a*b/gcd(a, b)
-
-if __name__ == '__main__':
-    import nose
-    nose.main()
-  \end{lstlisting}
-\inctime{15}
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{Example}
-    \begin{block}{Problem Statement:}
-      Write a function to check whether a given input
-      string is a palindrome.
-    \end{block}
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{Function: code.py}
-\begin{lstlisting}    
-def is_palindrome(input_str):
-  return input_str == input_str[::-1]
-\end{lstlisting}    
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{Test for the palindrome: code.py}
-\begin{lstlisting}    
-from code import is_palindrome
-def test_function_normal_words():
-  input = "noon"
-  assert is_palindrome(input) == True
-\end{lstlisting}    
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{Running the tests.}
-\begin{lstlisting}    
-$ nosetests test.py 
-.
-----------------------------------------------
-Ran 1 test in 0.001s
-
-OK
-\end{lstlisting}    
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{Exercise: Including new tests.}
-\begin{lstlisting}    
-def test_function_ignore_cases_words():
-  input = "Noon"
-  assert is_palindrome(input) == True
-\end{lstlisting}
-Check
-
-\PythonCode{$ nosetests test.py} 
-
-Tweak the code to pass this test.
-\end{frame}
-
-\begin{frame}[fragile]
-    \frametitle{Exercise: Some more tests.}
-\begin{lstlisting}    
-def test_function_ignore_spaces_in_text():
-    input = "ab raca carba"
-    assert is_palindrome(input) == True
-\end{lstlisting}
-Check
-
-\PythonCode{$ nosetests test.py} 
-
-Tweak the code to pass this test.
-
-\inctime{15} 
-\end{frame}
-
+  
 \end{document}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/day2/tda.tex	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,299 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Tutorial slides on Python.
+%
+% Author: Prabhu Ramachandran <prabhu at aero.iitb.ac.in>
+% Copyright (c) 2005-2009, Prabhu Ramachandran
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\documentclass[compress,14pt]{beamer}
+% \documentclass[handout]{beamer}
+% \usepackage{pgfpages}
+% \pgfpagesuselayout{4 on 1}[a4paper,border, shrink=5mm,landscape]
+\usepackage{tikz}
+\newcommand{\hyperlinkmovie}{}
+%\usepackage{movie15}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Note that in presentation mode 
+% \paperwidth  364.19536pt
+% \paperheight 273.14662pt
+% h/w = 0.888
+
+
+\mode<presentation>
+{
+  \usetheme{Warsaw}
+  %\usetheme{Boadilla}
+  %\usetheme{default}
+  \useoutertheme{split}
+  \setbeamercovered{transparent}
+}
+
+% To remove navigation symbols
+\setbeamertemplate{navigation symbols}{}
+
+\usepackage{amsmath}
+\usepackage[english]{babel}
+\usepackage[latin1]{inputenc}
+\usepackage{times}
+\usepackage[T1]{fontenc}
+
+% Taken from Fernando's slides.
+\usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler}
+\usepackage[scaled=.95]{helvet}
+\usepackage{pgf}
+
+\definecolor{darkgreen}{rgb}{0,0.5,0}
+
+\usepackage{listings}
+\lstset{language=Python,
+    basicstyle=\ttfamily\bfseries,
+    commentstyle=\color{red}\itshape,
+  stringstyle=\color{darkgreen},
+  showstringspaces=false,
+  keywordstyle=\color{blue}\bfseries}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% My Macros
+\setbeamercolor{postit}{bg=yellow,fg=black}
+\setbeamercolor{emphbar}{bg=blue!20, fg=black}
+\newcommand{\emphbar}[1]
+{\begin{beamercolorbox}[rounded=true]{emphbar} 
+      {#1}
+ \end{beamercolorbox}
+}
+%{\centerline{\fcolorbox{gray!50} {blue!10}{
+%\begin{minipage}{0.9\linewidth}
+%    {#1} 
+%\end{minipage}
+%    }}}
+
+\newcommand{\myemph}[1]{\structure{\emph{#1}}}
+\newcommand{\PythonCode}[1]{\lstinline{#1}}
+
+\newcommand{\tvtk}{\texttt{tvtk}}
+\newcommand{\mlab}{\texttt{mlab}}
+
+\newcounter{time}
+\setcounter{time}{0}
+\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\vspace*{0.1in}\tiny \thetime\ m}}
+
+\newcommand\BackgroundPicture[1]{%
+  \setbeamertemplate{background}{%
+      \parbox[c][\paperheight]{\paperwidth}{%
+      \vfill \hfill
+ \hfill \vfill
+}}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Configuring the theme
+%\setbeamercolor{normal text}{fg=white}
+%\setbeamercolor{background canvas}{bg=black}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Title page
+\title[]{Test Driven Approach}
+
+\author[FOSSEE Team] {Asokan Pichai\\Prabhu Ramachandran}
+
+\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\date[] {11, October 2009}
+\date[] % (optional)
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%\pgfdeclareimage[height=0.75cm]{iitblogo}{iitblogo}
+%\logo{\pgfuseimage{iitblogo}}
+
+\AtBeginSection[]
+{
+  \begin{frame}<beamer>
+    \frametitle{Outline}
+      \Large
+    \tableofcontents[currentsection,currentsubsection]
+  \end{frame}
+}
+
+%% Delete this, if you do not want the table of contents to pop up at
+%% the beginning of each subsection:
+\AtBeginSubsection[]
+{
+  \begin{frame}<beamer>
+    \frametitle{Outline}
+    \tableofcontents[currentsection,currentsubsection]
+  \end{frame}
+}
+
+\AtBeginSection[]
+{
+  \begin{frame}<beamer>
+    \frametitle{Outline}
+    \tableofcontents[currentsection,currentsubsection]
+  \end{frame}
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% DOCUMENT STARTS
+\begin{document}
+
+\begin{frame}
+  \maketitle
+\end{frame}
+
+\section{Test Driven Approach}
+
+\begin{frame}
+    \frametitle{Testing code with \typ{nosetests}}
+   
+    \begin{itemize}
+        \item Writing tests is really simple!
+
+        \item Using nose.
+
+        \item Example!
+    \end{itemize}
+\end{frame}
+
+\begin{frame}
+    \frametitle{Need of Testing!}
+   
+    \begin{itemize}
+        \item Quality
+
+        \item Regression
+
+        \item Documentation
+    \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Nosetest}
+  \begin{lstlisting}
+def gcd(a, b):
+    """Returns gcd of a and b, 
+     handles only positive numbers."""
+    if a%b == 0: return b
+    return gcd(b, a%b)
+def lcm(a, b):
+    return a*b/gcd(a, b)
+
+if __name__ == '__main__':
+    import nose
+    nose.main()
+  \end{lstlisting}
+\inctime{10}
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Example}
+    \begin{block}{Problem Statement:}
+      Write a function to check whether a given input
+      string is a palindrome.
+    \end{block}
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Function: palindrome.py}
+\begin{lstlisting}    
+def is_palindrome(input_str):
+  return input_str == input_str[::-1]
+\end{lstlisting}    
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Test for the palindrome: palindrome.py}
+\begin{lstlisting}    
+from plaindrome import is_palindrome
+def test_function_normal_words():
+  input = "noon"
+  assert is_palindrome(input) == True
+\end{lstlisting}    
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Running the tests.}
+\begin{lstlisting}    
+$ nosetests test.py 
+.
+----------------------------------------------
+Ran 1 test in 0.001s
+
+OK
+\end{lstlisting}    
+\end{frame}
+
+\begin{frame}[fragile]
+    \frametitle{Exercise: Including new tests.}
+\begin{lstlisting}    
+def test_function_ignore_cases_words():
+  input = "Noon"
+  assert is_palindrome(input) == True
+\end{lstlisting}
+     \vspace*{0.25in}
+     Check\\
+     \PythonCode{$ nosetests test.py} \\
+     \begin{block}{Task}
+     Tweak the code to pass this test.
+     \end{block}
+\end{frame}
+
+%\begin{frame}[fragile]
+%    \frametitle{Lets write some test!}
+%\begin{lstlisting}    
+%#for form of equation y=mx+c
+%#given m and c for two equation,
+%#finding the intersection point.
+%def intersect(m1,c1,m2,c2):
+%    x = (c2-c1)/(m1-m2)
+%    y = m1*x+c1
+%    return (x,y)
+%\end{lstlisting}
+%
+%Create a simple test for this
+%
+%function which will make it fail.
+%
+%\inctime{15} 
+%\end{frame}
+%
+
+\begin{frame}[fragile]
+    \frametitle{Exercise}
+    Based on Euclid's theorem:
+        $gcd(a,b)=gcd(b,b\%a)$\\
+    gcd function can be written as:
+    \begin{lstlisting}
+    def gcd(a, b):
+      if a%b == 0: return b
+      return gcd(b, a%b)
+    \end{lstlisting}
+    \begin{block}{Task}
+      For given gcd implementation write
+      at least two tests.
+    \end{block}
+    \begin{block}{Task}
+      Write a non recursive implementation
+      of gcd(), and test it using already 
+      written tests.
+    \end{block}
+    
+\inctime{15} 
+\end{frame}
+
+\begin{frame}{In this session we have covered:}
+  \begin{itemize}
+    \item Need for visualization.
+    \item Tools available.
+    \item How to follow Test Driven Approach.
+  \end{itemize}
+\end{frame}
+\begin{frame}
+    \begin{center}
+        \Huge    
+        Thank you!
+    \end{center}
+\end{frame}
+
+\end{document}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/quiz.tex	Thu Oct 08 22:48:59 2009 +0530
@@ -0,0 +1,11 @@
+\documentclass[a4paper,10pt]{book}
+
+
+\begin{document}
+Which version of Python were you using? 
+List some key differences between IPython and Vanilla Python
+What is the biggest integer number that can be represented by Python?
+What is the result of 17.0 / 2?
+What does '*' * 40 produce?
+ 
+\end{document}