diff options
author | Puneeth Chaganti | 2010-01-12 19:03:34 +0530 |
---|---|---|
committer | Puneeth Chaganti | 2010-01-12 19:03:34 +0530 |
commit | 1fb43f5dcbc83f1330b72d2629746fe2a257ed2a (patch) | |
tree | 1aa4fed41387bb6e82a0cd5662eb5ad2891a6e7d /day2 | |
parent | 04aa87d31b234e6c7c2a36cc81fe92da2f587e23 (diff) | |
download | workshops-more-scipy-1fb43f5dcbc83f1330b72d2629746fe2a257ed2a.tar.gz workshops-more-scipy-1fb43f5dcbc83f1330b72d2629746fe2a257ed2a.tar.bz2 workshops-more-scipy-1fb43f5dcbc83f1330b72d2629746fe2a257ed2a.zip |
Changes made during REC Chennai workshop.
Diffstat (limited to 'day2')
-rw-r--r-- | day2/cheatsheet3.tex | 2 | ||||
-rwxr-xr-x | day2/day2quiz.tex | 122 | ||||
-rw-r--r-- | day2/session3.tex | 34 | ||||
-rw-r--r-- | day2/session5.tex | 12 |
4 files changed, 159 insertions, 11 deletions
diff --git a/day2/cheatsheet3.tex b/day2/cheatsheet3.tex index 03da579..97cd2ed 100644 --- a/day2/cheatsheet3.tex +++ b/day2/cheatsheet3.tex @@ -105,7 +105,7 @@ bye bye vattam \section{Self contained python script} Functions like \typ{plot}, \typ{linspace} etc are not inbuilt functions. One have to import them to use them. \begin{lstlisting} -from pylab import linspace, pi, sin +from scipy import linspace, pi, sin from pylab import plot, legend, annotate from pylab import xlim, ylim diff --git a/day2/day2quiz.tex b/day2/day2quiz.tex index badefbc..5561d3d 100755 --- a/day2/day2quiz.tex +++ b/day2/day2quiz.tex @@ -60,5 +60,127 @@ On the top right hand corner please write down the following: \end{itemize} \end{frame} +\begin{frame} +\frametitle{\incqno } + What is the largest integer value that can be represented natively by Python? +\end{frame} + +\begin{frame} +\frametitle{\incqno } + What is the result of 17.0 / 2? +\end{frame} + +\begin{frame} +\frametitle{\incqno } + Which of the following is not a type in Python? + \begin{enumerate} + \item int + \item float + \item char + \item string + \end{enumerate} +\end{frame} + +\begin{frame} +\frametitle{\incqno } +How do you create a complex number with real part 2 and imaginary part +0.5. +\end{frame} + +\begin{frame} +\frametitle{\incqno } + What is the difference between \kwrd{print} \emph{x} and \kwrd{print} \emph{x,} ? +\end{frame} + +\begin{frame} +\frametitle{\incqno } + What does '*' * 40 produce? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } + What is the output of: + \begin{lstlisting} +In []: ', '.join(['a', 'b', 'c']) + \end{lstlisting} +\end{frame} + + +\begin{frame}[fragile] + \frametitle{\incqno} + \begin{lstlisting} +In []: 47 % 3 + \end{lstlisting} + What is the output? +\end{frame} + +\begin{frame} + \frametitle{\incqno} + How do you find the presence of an element \emph{x} in the list \emph{a}? +\end{frame} + + +\begin{frame}[fragile] + \frametitle{\incqno} + \begin{lstlisting} +In []: set([1, 2, 8, 2, 13, 8, 9]) + \end{lstlisting} + What is the output? +\end{frame} + +\begin{frame}[fragile] + \frametitle{\incqno} + \begin{lstlisting} +In []: a = {'a': 1, 'b': 2} +In []: a['a'] = 10 +pIn []: print a + \end{lstlisting} + What is the output? +\end{frame} + +\begin{frame}[fragile] + \frametitle{\incqno} + \begin{lstlisting} +In []: for i in range(3, 10, 2): + ...: print i + \end{lstlisting} + What is the output? +\end{frame} + +\begin{frame}[fragile] + \frametitle{\incqno} + \begin{lstlisting} +In []: a = [1, 2, 3] +In []: a.extend([5, 6]) + \end{lstlisting} + What is the value of a? +\end{frame} + +\begin{frame}[fragile] + \frametitle{\incqno} + \begin{lstlisting} +In []: a = (1, 2, 3) +In []: a[1] = 10 + \end{lstlisting} + What is the result? +\end{frame} + +\begin{frame}[fragile] + \frametitle{\incqno} + \begin{lstlisting} +def func(x, y=10): + print x+1, y+10 + +func(1) + + \end{lstlisting} + What is the output? +\end{frame} + +\begin{frame} + \frametitle{\incqno} + How many items can a function return? +\end{frame} + \end{document} diff --git a/day2/session3.tex b/day2/session3.tex index 8e08271..8b2a12f 100644 --- a/day2/session3.tex +++ b/day2/session3.tex @@ -250,6 +250,23 @@ NameError: name 'linspace' is not defined \begin{frame}[fragile] \frametitle{Remedy \ldots} \begin{lstlisting} +from scipy import * + \end{lstlisting} +\alert{Now run python four\_plot.py again} +\end{frame} + +\begin{frame}[fragile] + \begin{lstlisting} +Traceback (most recent call last): + File "four_plot.py", line 1, in <module> + x = plot(x, x, 'b') +NameError: name 'plot' is not defined + \end{lstlisting} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Remedy \ldots} + \begin{lstlisting} from pylab import * \end{lstlisting} \alert{Now run python four\_plot.py again!!} @@ -261,8 +278,8 @@ from pylab import * \item The \kwrd{import} keyword ``loads'' a module \item One can also use: \begin{lstlisting} -In []: from pylab import * -In []: from pylab import linspace +In []: from scipy import * +In []: from scipy import linspace \end{lstlisting} \item What is the difference? \item \alert{Use the former only in interactive mode} @@ -282,7 +299,7 @@ from scipy.optimize import fsolve \frametitle{\texttt{from} \ldots \texttt{import} - conventional way!} \small \begin{lstlisting} -from pylab import linspace, pi, sin +from scipy import linspace, pi, sin from pylab import plot, legend, annotate from pylab import xlim, ylim @@ -302,17 +319,18 @@ ylim(-5*pi, 5*pi) \frametitle{\texttt{from} \ldots \texttt{import} - conventional way!} \small \begin{lstlisting} +import scipy import pylab -x = pylab.linspace(-5*pylab.pi, 5*pylab.pi, 500) +x = scipy.linspace(-5*scipy.pi, 5*scipy.pi, 500) pylab.plot(x, x, 'b') pylab.plot(x, -x, 'b') -pylab.plot(x, pylab.sin(x), 'g', linewidth=2) -pylab.plot(x, x*pylab.sin(x), 'r', linewidth=3) +pylab.plot(x, scipy.sin(x), 'g', linewidth=2) +pylab.plot(x, x*scipy.sin(x), 'r', linewidth=3) pylab.legend(['x', '-x', 'sin(x)', 'xsin(x)']) pylab.annotate('origin', xy = (0, 0)) -pylab.xlim(-5*pylab.pi, 5*pylab.pi) -pylab.ylim(-5*pylab.pi, 5*pylab.pi) +pylab.xlim(-5*scipy.pi, 5*scipy.pi) +pylab.ylim(-5*scipy.pi, 5*scipy.pi) \end{lstlisting} \end{frame} diff --git a/day2/session5.tex b/day2/session5.tex index c5809c5..abbd2af 100644 --- a/day2/session5.tex +++ b/day2/session5.tex @@ -138,9 +138,17 @@ aliquot(12) = 1 + 2 + 3 + 4 + 6 = 16.\\ \inctime{10} \end{frame} -\begin{frame} + +\begin{frame} \frametitle{Problem 3} - Count frequencies of words in a file. +Given a list of words, find all the anagrams in the list. +Solve the problem without using dictionaries. + +\end{frame} + +\begin{frame} + \frametitle{Problem 4} + Count frequencies of words in a file named 'holmes.txt'. \inctime{25} \end{frame} |