# HG changeset patch # User Shantanu # Date 1256932992 -19800 # Node ID 9cce24d009577720865e5afd552f53a7ee40e73f # Parent bb77a470e00a1815a52e8ebcaca6623ce0a2b01a 1 quiz, seesion5 plots, added links to reference. diff -r bb77a470e00a -r 9cce24d00957 day1/data/missing_points.png Binary file day1/data/missing_points.png has changed diff -r bb77a470e00a -r 9cce24d00957 day1/links.tex --- a/day1/links.tex Thu Oct 29 00:39:33 2009 +0530 +++ b/day1/links.tex Sat Oct 31 01:33:12 2009 +0530 @@ -1,6 +1,7 @@ \documentclass[12pt]{article} \title{Links and References} -\author{Asokan Pichai\\Prabhu Ramachandran} +\author{FOSSEE} +\date{} \begin{document} \maketitle \begin{itemize} @@ -8,7 +9,9 @@ \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 \url{http://diveintopython.org/} \item How to Think Like a Computer Scientist: Learning with Python available at \url{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} \item Some assorted articles related to Python \url{http://effbot.org/zone/index.htm} + \item Reference manual to describe the standard libraries that are distributed with Python is available at \url{http://docs.python.org/library/} \item To read more on strings refer to: \\ \url{http://docs.python.org/library/stdtypes.html#string-methods} + \item Some coding conventions for using Python language are available at \\ \url{http://www.python.org/dev/peps/pep-0008/} \item For documentation on IPython refer: \\ \url{http://ipython.scipy.org/moin/Documentation} \item Documentation for Numpy and Scipy is available at: \url{http://docs.scipy.org/doc/} \item For "recipes" or worked examples of commonly-done tasks in SciPy explore: \url{http://www.scipy.org/Cookbook/} diff -r bb77a470e00a -r 9cce24d00957 day1/session5.tex --- a/day1/session5.tex Thu Oct 29 00:39:33 2009 +0530 +++ b/day1/session5.tex Sat Oct 31 01:33:12 2009 +0530 @@ -146,14 +146,13 @@ \section{Interpolation} \begin{frame}[fragile] -\frametitle{Interpolation} +\frametitle{Loading data (revisited)} \begin{itemize} \item Given data file \typ{points.txt}. \item It contains x,y position of particle. \item Plot the given points. %% \item Interpolate the missing region. \end{itemize} -\emphbar{Loading data (revisited)} \begin{lstlisting} In []: data = loadtxt('points.txt') In []: data.shape @@ -164,6 +163,12 @@ \end{lstlisting} \end{frame} +\begin{frame} + \frametitle{Plot} + \begin{center} + \includegraphics[height=2in, interpolate=true]{data/missing_points} + \end{center} +\end{frame} %% \begin{frame}[fragile] %% \frametitle{Interpolation \ldots} %% \begin{small} diff -r bb77a470e00a -r 9cce24d00957 day1quiz1.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/day1quiz1.tex Sat Oct 31 01:33:12 2009 +0530 @@ -0,0 +1,150 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Tutorial slides on Python. +% +% Author: FOSSEE +% Copyright (c) 2005-2009, FOSSEE Team +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\documentclass[14pt,compress]{beamer} + +\mode +{ + \useoutertheme{split} + \setbeamercovered{transparent} +} + +\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} + +\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Macros + +\newcounter{qno} +\setcounter{qno}{0} +\newcommand{\incqno}{\addtocounter{qno}{1}{Question \theqno}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Title page +\title[Basic Python]{Python: Quiz} + +\author[FOSSEE Team] {FOSSEE} + +\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} +\date[] {31, October 2009\\Day 1, Quiz 1} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\begin{document} + +\begin{frame} + \titlepage +\end{frame} + +\begin{frame} + \frametitle{Write your details...} +On the top right hand corner please write down the following: + \begin{itemize} + \item Name: + \item Affliation: + \item Occupation: + \end{itemize} +\end{frame} + +\begin{frame} +\frametitle{\incqno } + A sample line from a Comma Separated Values (CSV) file:\\ + \vspace*{0.2in} + \emph{Rossum, Guido, 42, 56, 34, 54}\\ + \vspace*{0.2in} + What method would you use to separate the line into fields? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } + \begin{lstlisting} + In [1]: a = [1, 2, 5, 9] + In [2]: a[:-1] + \end{lstlisting} + What is the output? +\end{frame} + +\begin{frame} +\frametitle{\incqno } + How do you combine the two lists \emph{a} and \emph{b}? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } + \begin{lstlisting} + In [1]: d = { + 'a': 1, + 'b': 2 + } + In [2]: print d['c'] + \end{lstlisting} + What is the output? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } + \begin{lstlisting} + for x in "abcd": + print x + + a + b + c + d + \end{lstlisting} + How do you get the following output? + \begin{lstlisting} + 0 a + 1 b + 2 c + 3 d + \end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the result? +\begin{lstlisting} + In [1]: x + array([[0, 1, 2], + [3, 4, 5], + [6, 7, 8]]) + In [2]: x[::-1,:] +\end{lstlisting} +\end{frame} + +\begin{frame} +\frametitle{\incqno } +How to read and print each line of file. +\end{frame} + +\begin{frame} +\frametitle{\incqno } +How to get list of third column of a data file. +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What is the output of: +\begin{lstlisting} +In []: x=linspace(0 , 2 * pi) +In []: plot(x, cos(x),'go') +\end{lstlisting} +\end{frame} + +\end{document} + diff -r bb77a470e00a -r 9cce24d00957 day1quiz2.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/day1quiz2.tex Sat Oct 31 01:33:12 2009 +0530 @@ -0,0 +1,178 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Tutorial slides on Python. +% +% Author: FOSSEE +% Copyright (c) 2005-2009, FOSSEE Team +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\documentclass[14pt,compress]{beamer} + +\mode +{ + \useoutertheme{split} + \setbeamercovered{transparent} +} + +\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} + +\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Macros + +\newcounter{qno} +\setcounter{qno}{0} +\newcommand{\incqno}{\addtocounter{qno}{1}{Question \theqno}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Title page +\title[Basic Python]{Python: Quiz} + +\author[FOSSEE Team] {FOSSEE} + +\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} +\date[] {11, October 2009\\Day 2} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\begin{document} + +\begin{frame} + \titlepage +\end{frame} + +\begin{frame} + \frametitle{Write your details...} +On the top right hand corner please write down the following: + \begin{itemize} + \item Name: + \item Affliation: + \item Occupation: + \end{itemize} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array([[1,2,3,4],[3,4,2,5]]) + >>> x.shape + (2, 4) +\end{lstlisting} +Change the shape of \lstinline+x+ to (4,2) +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array([[1,2,3,4]]) +\end{lstlisting} +How to change the third element of \lstinline+x+ to 0? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the result? +\begin{lstlisting} + >>> y = arange(3) + >>> x = linspace(0,3,3) + >>> x-y +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array([0, 1, 2, 3]) + >>> x.shape = 2,2 + >>> x + array([[0, 1], + [2, 3]]) + >>> x[::2,::2] +\end{lstlisting} +What is the output? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the result? +\begin{lstlisting} + >>> x + array([[0, 1, 2], + [3, 4, 5], + [6, 7, 8]]) + >>> x[::-1,:] +\end{lstlisting} +Hint: +\begin{lstlisting} + >>> x = arange(9) + >>> x[::-1] + array([8, 7, 6, 5, 4, 3, 2, 1, 0]) +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x + array([[ 0, 1, 2, 3], + [ 4, 5, 6, 7], + [ 8, 9, 10, 11], + [12, 13, 14, 15]]) +\end{lstlisting} +How will you get the following \lstinline+x+? +\begin{lstlisting} + array([[ 5, 7], + [ 9, 11]]) +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array(([1,2,3,4],[2,3,4,5])) + >>> x[-2][-3] = 4 + >>> x +\end{lstlisting} +What will be printed? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the output? +\begin{lstlisting} + >>> y = arange(4) + >>> x = array(([1,2,3,2],[1,3,6,0])) + >>> x + y +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> line = plot(x, sin(x)) +\end{lstlisting} +Use the \lstinline+set_linewidth+ method to set width of \lstinline+line+ to 2. +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the output? +\begin{lstlisting} + >>> x = arange(9) + >>> y = arange(9.) + >>> x == y +\end{lstlisting} +\end{frame} + + +\end{document} + diff -r bb77a470e00a -r 9cce24d00957 day2quiz2.tex --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/day2quiz2.tex Sat Oct 31 01:33:12 2009 +0530 @@ -0,0 +1,178 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Tutorial slides on Python. +% +% Author: FOSSEE +% Copyright (c) 2005-2009, FOSSEE Team +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\documentclass[14pt,compress]{beamer} + +\mode +{ + \useoutertheme{split} + \setbeamercovered{transparent} +} + +\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} + +\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Macros + +\newcounter{qno} +\setcounter{qno}{0} +\newcommand{\incqno}{\addtocounter{qno}{1}{Question \theqno}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Title page +\title[Basic Python]{Python: Quiz} + +\author[FOSSEE Team] {FOSSEE} + +\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} +\date[] {11, October 2009\\Day 2} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\begin{document} + +\begin{frame} + \titlepage +\end{frame} + +\begin{frame} + \frametitle{Write your details...} +On the top right hand corner please write down the following: + \begin{itemize} + \item Name: + \item Affliation: + \item Occupation: + \end{itemize} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array([[1,2,3,4],[3,4,2,5]]) + >>> x.shape + (2, 4) +\end{lstlisting} +Change the shape of \lstinline+x+ to (4,2) +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array([[1,2,3,4]]) +\end{lstlisting} +How to change the third element of \lstinline+x+ to 0? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the result? +\begin{lstlisting} + >>> y = arange(3) + >>> x = linspace(0,3,3) + >>> x-y +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array([0, 1, 2, 3]) + >>> x.shape = 2,2 + >>> x + array([[0, 1], + [2, 3]]) + >>> x[::2,::2] +\end{lstlisting} +What is the output? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the result? +\begin{lstlisting} + >>> x + array([[0, 1, 2], + [3, 4, 5], + [6, 7, 8]]) + >>> x[::-1,:] +\end{lstlisting} +Hint: +\begin{lstlisting} + >>> x = arange(9) + >>> x[::-1] + array([8, 7, 6, 5, 4, 3, 2, 1, 0]) +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x + array([[ 0, 1, 2, 3], + [ 4, 5, 6, 7], + [ 8, 9, 10, 11], + [12, 13, 14, 15]]) +\end{lstlisting} +How will you get the following \lstinline+x+? +\begin{lstlisting} + array([[ 5, 7], + [ 9, 11]]) +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> x = array(([1,2,3,4],[2,3,4,5])) + >>> x[-2][-3] = 4 + >>> x +\end{lstlisting} +What will be printed? +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the output? +\begin{lstlisting} + >>> y = arange(4) + >>> x = array(([1,2,3,2],[1,3,6,0])) + >>> x + y +\end{lstlisting} +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +\begin{lstlisting} + >>> line = plot(x, sin(x)) +\end{lstlisting} +Use the \lstinline+set_linewidth+ method to set width of \lstinline+line+ to 2. +\end{frame} + +\begin{frame}[fragile] +\frametitle{\incqno } +What would be the output? +\begin{lstlisting} + >>> x = arange(9) + >>> y = arange(9.) + >>> x == y +\end{lstlisting} +\end{frame} + + +\end{document} +