--- a/accessing-pieces-arrays/quickref.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/accessing-pieces-arrays/quickref.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,8 +1,12 @@
-Creating a linear array:\\
-{\ex \lstinline| x = linspace(0, 2*pi, 50)|}
+\textbf{Accessing parts of arrays}
+
+\lstinline|C[i-1, j-1]| to access element i, j in C (mxn).
+\lstinline|C[i-1]| to access i^{th} row
+\lstinline|C[:, j-1]| to access j^{th} column
-Plotting two variables:\\
-{\ex \lstinline| plot(x, sin(x))|}
+Assigning to accessed elements, changes them.
-Plotting two lists of equal length x, y:\\
-{\ex \lstinline| plot(x, y)|}
+\lstinline|A[m:n:o]| accesses the rows from \lstinline|m|
+to \lstinline|n| (excluded) in steps of \lstinline|o|
+
+Similarly, \lstinline|C[m:n:o, p:q:r]|
--- a/accessing-pieces-arrays/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/accessing-pieces-arrays/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -298,8 +298,7 @@
Following is an exercise that you must do.
-%%5%% Pause the video here, and obtain the square in the center
-of the image.
+%%5%% Obtain the square in the center of the image.
Following is an exercise that you must do.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/accessing-pieces-arrays/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,123 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Accessing parts of arrays
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - Manipulating one and multi dimensional arrays
+ - Access and change individual elements
+ - Access and change rows and columns
+ - Slicing and striding on arrays to access chunks
+ - Read images into arrays and manipulations
+* Sample Arrays
+ #+begin_src python
+ In []: A = array([12, 23, 34, 45, 56])
+
+ In []: C = array([[11, 12, 13, 14, 15],
+ [21, 22, 23, 24, 25],
+ [31, 32, 33, 34, 35],
+ [41, 42, 43, 44, 45],
+ [51, 52, 53, 54, 55]])
+
+ #+end_src
+* Question 1
+ Change the last column of ~C~ to zeroes.
+* Solution 1
+ #+begin_src python
+ In []: C[:, -1] = 0
+ #+end_src
+* Question 2
+ Change ~A~ to ~[11, 12, 13, 14, 15]~.
+* Solution 2
+ #+begin_src python
+ In []: A[:] = [11, 12, 13, 14, 15]
+ #+end_src
+* squares.png
+ #+begin_latex
+ \begin{center}
+ \includegraphics[scale=0.6]{squares}
+ \end{center}
+ #+end_latex
+* Question 3
+ - obtain ~[22, 23]~ from ~C~.
+ - obtain ~[11, 21, 31, 41]~ from ~C~.
+ - obtain ~[21, 31, 41, 0]~.
+* Solution 3
+ #+begin_src python
+ In []: C[1, 1:3]
+ In []: C[0:4, 0]
+ In []: C[1:5, 0]
+ #+end_src
+* Question 4
+ Obtain ~[[23, 24], [33, -34]]~ from ~C~
+* Solution 4
+ #+begin_src python
+ In []: C[1:3, 2:4]
+ #+end_src
+* Question 5
+ Obtain the square in the center of the image
+* Solution 5
+ #+begin_src python
+ In []: imshow(I[75:225, 75:225])
+ #+end_src
+* Question 6
+ Obtain the following
+ #+begin_src python
+ [[12, 0], [42, 0]]
+ [[12, 13, 14], [0, 0, 0]]
+ #+end_src
+
+* Solution 6
+ #+begin_src python
+ In []: C[::3, 1::3]
+ In []: C[::4, 1:4]
+ #+end_src
+* Summary
+ You should now be able to --
+ - Manipulate 1D \& Multi dimensional arrays
+ - Access and change individual elements
+ - Access and change rows and columns
+ - Slice and stride on arrays
+ - Read images into arrays and manipulate them.
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/accessing-pieces-arrays/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/accessing-pieces-arrays/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,203 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 18:48
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Accessing parts of arrays}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Manipulating one and multi dimensional arrays
+\item Access and change individual elements
+\item Access and change rows and columns
+\item Slicing and striding on arrays to access chunks
+\item Read images into arrays and manipulations
+\end{itemize}
\end{frame}
+\begin{frame}[fragile]
+\frametitle{Sample Arrays}
+\label{sec-2}
+\lstset{language=Python}
+\begin{lstlisting}
+In []: A = array([12, 23, 34, 45, 56])
+
+In []: C = array([[11, 12, 13, 14, 15],
+ [21, 22, 23, 24, 25],
+ [31, 32, 33, 34, 35],
+ [41, 42, 43, 44, 45],
+ [51, 52, 53, 54, 55]])
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-3}
+
+ Change the last column of \texttt{C} to zeroes.
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 1}
+\label{sec-4}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: C[:, -1] = 0
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 2}
+\label{sec-5}
+
+ Change \texttt{A} to \texttt{[11, 12, 13, 14, 15]}.
\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 2}
+\label{sec-6}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: A[:] = [11, 12, 13, 14, 15]
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{squares.png}
+\label{sec-7}
+
+ \begin{center}
+ \includegraphics[scale=0.6]{squares}
+ \end{center}
+\end{frame}
+\begin{frame}
+\frametitle{Question 3}
+\label{sec-8}
+
+\begin{itemize}
+\item obtain \texttt{[22, 23]} from \texttt{C}.
+\item obtain \texttt{[11, 21, 31, 41]} from \texttt{C}.
+\item obtain \texttt{[21, 31, 41, 0]}.
+\end{itemize}
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 3}
+\label{sec-9}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\lstset{language=Python}
+\begin{lstlisting}
+In []: C[1, 1:3]
+In []: C[0:4, 0]
+In []: C[1:5, 0]
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 4}
+\label{sec-10}
+
+ Obtain \texttt{[[23, 24], [33, -34]]} from \texttt{C}
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 4}
+\label{sec-11}
+\lstset{language=Python}
+\begin{lstlisting}
+In []: C[1:3, 2:4]
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 5}
+\label{sec-12}
+
+ Obtain the square in the center of the image
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 5}
+\label{sec-13}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: imshow(I[75:225, 75:225])
+\end{lstlisting}
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Question 6}
+\label{sec-14}
+
+ Obtain the following
+\lstset{language=Python}
+\begin{lstlisting}
+[[12, 0], [42, 0]]
+[[12, 13, 14], [0, 0, 0]]
+\end{lstlisting}
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 6}
+\label{sec-15}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: C[::3, 1::3]
+In []: C[::4, 1:4]
+\end{lstlisting}
\end{frame}
-
\begin{frame}
- \frametitle{Thank you!}
+\frametitle{Summary}
+\label{sec-16}
+
+ You should now be able to --
+\begin{itemize}
+\item Manipulate 1D \& Multi dimensional arrays
+
+\begin{itemize}
+\item Access and change individual elements
+\item Access and change rows and columns
+\item Slice and stride on arrays
+\end{itemize}
+
+\item Read images into arrays and manipulate them.
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-17}
+
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/additional_ipython/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/additional_ipython/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -6,6 +6,14 @@
C -
D -
+.. By the end of this tutorial you will be able to
+
+.. #. Retrieve your ipython history
+.. #. View a part of the history
+.. #. Save a part of your history to a file.
+.. #. Run a script from within ipython
+
+
.. Prerequisites
.. -------------
@@ -81,8 +89,8 @@
{{{ Pause here and try out the following exercises }}}
-%% 1 %% Read through the %hist documenatation and find out how can we list all
- the commands between 5 and 10
+%% 1 %% Read through the documentation of %hist and find out how to
+ list all the commands between 5 and 10
{{{ continue from paused state }}}
@@ -128,7 +136,7 @@
{{{ Pause here and try out the following exercises }}}
-%% 2 %% change the label on y-axis to "y" and save the lines of code
+%% 2 %% Change the label on y-axis to "y" and save the lines of code
accordingly
{{{ continue from paused state }}}
@@ -210,5 +218,5 @@
This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
Hope you have enjoyed and found it useful.
-Thankyou
+Thank you!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/additional_ipython/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,90 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER:\usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Additional Features of =ipython=
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ + Retrieving ipython history
+ + Viewing a part of the history
+ + Saving (relevant) parts of the history to a file
+ + Running a script from within ipython
+* Question 1
+ Read through the documentation of ~%hist~ and find out how to list
+ all the commands between 5 and 10
+* Solution 1
+ #+begin_src python
+ In []: %hist 5 10
+ #+end_src
+* Question 2
+ Change the label on y-axis to "y" and save the lines of code
+ accordingly
+* Solution 2
+ #+begin_src python
+ In []: ylabel("y")
+ In []: %save /home/fossee/example_plot.py 1 3-6 10
+ #+end_src
+* Question 3
+ Use =%hist= and =%save= and create a script that has show in it and
+ run it to produce and show the plot.
+
+* Solution 3
+ #+begin_src python
+ In []: %hist 20
+
+ In []: %save /home/fossee/show_included.py 1 3-6 8 10 13
+ In []: %run -i /home/fossee/show_included.py
+ #+end_src
+* Question 4
+ Run the script without using the -i option. Do you find any
+ difference?
+* Solution 4
+ We see that it raises ~NameError~ saying the name ~linspace~ is not
+ found.
+* Summary
+ + Retreiving history using =%hist= command
+ + Vieweing only a part of history by passing an argument to %hist
+ + Saving the required lines of code in required order using %save
+ + Using %run -i command to run the saved script
+
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/additional_ipython/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/additional_ipython/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,138 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 17:30
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Additional Features of \texttt{ipython}}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Retrieving ipython history
+\item Viewing a part of the history
+\item Saving (relevant) parts of the history to a file
+\item Running a script from within ipython
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+ Read through the documentation of \texttt{\%hist} and find out how to list
+ all the commands between 5 and 10
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 1}
+\label{sec-3}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: %hist 5 10
+\end{lstlisting}
\end{frame}
+\begin{frame}
+\frametitle{Question 2}
+\label{sec-4}
+
+ Change the label on y-axis to ``y'' and save the lines of code
+ accordingly
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 2}
+\label{sec-5}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\lstset{language=Python}
+\begin{lstlisting}
+In []: ylabel("y")
+In []: %save /home/fossee/example_plot.py 1 3-6 10
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 3}
+\label{sec-6}
+ Use \texttt{\%hist} and \texttt{\%save} and create a script that has show in it and
+ run it to produce and show the plot.
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 3}
+\label{sec-7}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: %hist 20
+
+In []: %save /home/fossee/show_included.py 1 3-6 8 10 13
+In []: %run -i /home/fossee/show_included.py
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 4}
+\label{sec-8}
+
+ Run the script without using the -i option. Do you find any
+ difference?
\end{frame}
+\begin{frame}
+\frametitle{Solution 4}
+\label{sec-9}
+ We see that it raises \texttt{NameError} saying the name \texttt{linspace} is not
+ found.
+\end{frame}
\begin{frame}
- \frametitle{Thank you!}
+\frametitle{Summary}
+\label{sec-10}
+
+\begin{itemize}
+\item Retreiving history using \texttt{\%hist} command
+\item Vieweing only a part of history by passing an argument to \%hist
+\item Saving the required lines of code in required order using \%save
+\item Using \%run -i command to run the saved script
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-11}
+
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/advanced-features-functions/quickref.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/advanced-features-functions/quickref.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,8 +1,8 @@
-Creating a linear array:\\
-{\ex \lstinline| x = linspace(0, 2*pi, 50)|}
+\textbf{Advanced features of functions}
+
+Arguments of functions can have default arguments.
-Plotting two variables:\\
-{\ex \lstinline| plot(x, sin(x))|}
+All arguments with default arguments are at the end of the definition.
-Plotting two lists of equal length x, y:\\
-{\ex \lstinline| plot(x, y)|}
+Functions can be called with keyword arguments. All the keyword
+arguments should be at the end of the argument list.
--- a/advanced-features-functions/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/advanced-features-functions/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -103,7 +103,7 @@
%%1%% Redefine the function ``welcome``, by interchanging it's
arguments. Place the ``name`` argument with it's default value of
-"Hello" before the ``greet`` argument.
+"World" before the ``greet`` argument.
Please, pause the video here. Do the exercise and then continue.
@@ -142,7 +142,7 @@
welcome()
-
+
Let us now learn what keyword arguments are.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/advanced-features-functions/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,86 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Advanced features of functions
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - Assigning default values to arguments
+ - Calling functions using Keyword arguments
+ - functions in standard library
+* Question 1
+ Redefine the function ~welcome~, by interchanging it's
+ arguments. Place the ~name~ argument with it's default value of
+ "World" before the ~greet~ argument.
+* Solution 1
+ #+begin_src python
+ def welcome(name="World", greet):
+ print greet, name
+ #+end_src
+ We get an error that reads ~SyntaxError: non-default argument
+ follows default argument~. When defining a function all the
+ argument with default values should come at the end.
+
+* Question 2
+ See the definition of linspace using ~?~ and observe how all the
+ arguments with default values are towards the end.
+* Solution 2
+ #+begin_src python
+ linspace?
+ #+end_src
+* Question 3
+ Redefine the function ~welcome~ with a default value of
+ "Hello" to the ~greet~ argument. Then, call the function without any
+ arguments.
+* Solution 3
+ #+begin_src python
+ def welcome(greet="Hello", name="World"):
+ print greet, name
+
+ welcome()
+ #+end_src
+* Summary
+ You should now be able to --
+ + define functions with default arguments
+ + call functions using keyword arguments
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/advanced-features-functions/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/advanced-features-functions/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,125 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-11 Mon 00:34
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Advanced features of functions}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Assigning default values to arguments
+\item Calling functions using Keyword arguments
+\item functions in standard library
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+ Redefine the function \texttt{welcome}, by interchanging it's
+ arguments. Place the \texttt{name} argument with it's default value of
+ ``World'' before the \texttt{greet} argument.
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 1}
+\label{sec-3}
+
+\lstset{language=Python}
+\begin{lstlisting}
+def welcome(name="World", greet):
+ print greet, name
+\end{lstlisting}
+ We get an error that reads \texttt{SyntaxError: non-default argument follows default argument}. When defining a function all the
+ argument with default values should come at the end.
\end{frame}
+\begin{frame}
+\frametitle{Question 2}
+\label{sec-4}
+
+ See the definition of linspace using \texttt{?} and observe how all the
+ arguments with default values are towards the end.
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 2}
+\label{sec-5}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\lstset{language=Python}
+\begin{lstlisting}
+linspace?
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 3}
+\label{sec-6}
+ Redefine the function \texttt{welcome} with a default value of
+ ``Hello'' to the \texttt{greet} argument. Then, call the function without any
+ arguments.
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 3}
+\label{sec-7}
+
+\lstset{language=Python}
+\begin{lstlisting}
+def welcome(greet="Hello", name="World"):
+ print greet, name
+
+welcome()
+\end{lstlisting}
\end{frame}
-
\begin{frame}
- \frametitle{Thank you!}
+\frametitle{Summary}
+\label{sec-8}
+
+ You should now be able to --
+\begin{itemize}
+\item define functions with default arguments
+\item call functions using keyword arguments
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-9}
+
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/embellishing_a_plot/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/embellishing_a_plot/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -6,6 +6,15 @@
C -
D -
+.. By the end of this tutorial you will be able to
+
+.. * Modify the attributes of the plot -- color, line style, linewidth
+.. * Add a title to the plot with embedded LaTeX.
+.. * Label x and y axes.
+.. * Add annotations to the plot.
+.. * Set and Get the limits of axes.
+
+
.. Prerequisites
.. -------------
@@ -174,6 +183,10 @@
.. #[Madhu: I did not understand the question]
+::
+ clf()
+ plot(x, cos(x), 'r--')
+
Now that we know how to produce a bare minimum plot with colour, style
and thickness of our interest, we shall look at decorating the plot.
@@ -184,8 +197,8 @@
{{{ Show the plot window and switch back to terminal }}}
-We now have the plot in a colour and linewidth of our interest. As you can see,
-the figure does not have any description describing the plot.
+We now have the plot in a colour and linewidth of our interest. As you
+can see, the figure does not have any description describing the plot.
.. #[Madhu: Added "not". See the diff]
@@ -204,10 +217,10 @@
The formatting in title is messed and it does not look clean. You can imagine
what would be the situation if there were fractions and more complex functions
-like log and exp. Wouldn't it be good if there was LaTex like formatting?
+like log and exp. Wouldn't it be good if there was LaTeX like formatting?
That is also possible by adding a $ sign before and after the part of the
-string that should be in LaTex style.
+string that should be in LaTeX style.
for instance, we can use
::
@@ -217,9 +230,9 @@
and we get the polynomial formatted properly.
.. #[Nishanth]: Unsure if I have to give this exercise since enclosing the whole
- string in LaTex style is not good
+ string in LaTeX style is not good
-.. #[[Anoop: I guess you can go ahead with the LaTex thing, it's
+.. #[[Anoop: I guess you can go ahead with the LaTeX thing, it's
cool!]]
.. #[Madhu: Instead of saying LaTeX style you can say Typeset math
since that is how it is called as. I am not sure as well. It
@@ -228,7 +241,7 @@
{{{ Pause here and try out the following exercises }}}
%% 4 %% Change the title of the figure such that the whole title is formatted
- in LaTex style
+ in LaTeX style
{{{ continue from the paused state }}}
@@ -262,11 +275,11 @@
{{{ Pause here and try out the following exercises }}}
-%% 5 %% Set the x and y labels as "x" and "f(x)" in LaTex style.
+%% 5 %% Set the x and y labels as "x" and "f(x)" in LaTeX style.
{{{ continue from paused state }}}
-Since we need LaTex style formatting, all we have to do is enclose the string
+Since we need LaTeX style formatting, all we have to do is enclose the string
in between two $. Hence,
::
@@ -303,6 +316,10 @@
{{{ continue from paused state }}}
+::
+
+ annotate("root", xy=(-4,0))
+
As we can see, every annotate command makes a new annotation on the figure.
Now we have everything we need to decorate a plot. but the plot would be
@@ -354,7 +371,7 @@
* Modifying the attributes of plot by passing additional arguments
* How to add title
- * How to incorporate LaTex style formatting
+ * How to incorporate LaTeX style formatting
* How to label x and y axes
* How to add annotations
* How to set the limits of axes
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/embellishing_a_plot/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,111 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER:\usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Embellishing a Plot
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ + Modifying the color, line style & linewidth of a plot
+ + Adding a title to the plot (with embedded LaTeX)
+ + Labelling the axes
+ + Annotating the plot
+ + Setting the limits of axes.
+* Question 1
+ Plot sin(x) in blue colour and with linewidth as 3
+* Solution 1
+ #+begin_src python
+ In []: clf()
+ In []: plot(x, sin(x), 'b', linewidth=3)
+ #+end_src
+* Question 2
+ Plot the sine curve with green filled circles.
+* Solution 2
+ #+begin_src python
+ In []: clf()
+ In []: plot(x, cos(x), 'go')
+ #+end_src
+* Question 3
+ Plot the curve of x vs tan(x) in red dashed line and linewidth 3
+* Solution 3
+ #+begin_src python
+ In []: clf()
+ In []: plot(x, cos(x), 'r--')
+ #+end_src
+* Question 4
+ Change the title of the figure such that the whole title is
+ formatted in LaTex style
+* Solution 4
+ #+begin_src python
+ In []: title("$Parabolic function -x^2+4x-5$")
+ #+end_src
+* Question 5
+ Set the x and y labels as "x" and "f(x)" in LaTex style.
+* Solution 5
+ #+begin_src python
+ In []: xlabel("$x$")
+ In []: yalbel("$f(x)$")
+ #+end_src
+* Question 6
+ Make an annotation called "root" at the point (-4, 0). What happens
+ to the first annotation?
+* Solution 6
+ #+begin_src python
+ In []: annotate("root", xy=(-4,0))
+ #+end_src
+* Question 7
+ Set the limits of axes such that the area of interest is the
+ rectangle (-1, -15) and (3, 0)
+* Solution 7
+ #+begin_src python
+ In []: xlim(-1, 3)
+ In []: ylim(-15, 0)
+ #+end_src
+* Summary
+ + Modifying the attributes of plot by passing additional arguments
+ + How to add title
+ + How to incorporate LaTeX style formatting
+ + How to label x and y axes
+ + How to add annotations
+ + How to set the limits of axes
+
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/embellishing_a_plot/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/embellishing_a_plot/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,187 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 17:32
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Embellishing a Plot}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Modifying the color, line style \& linewidth of a plot
+\item Adding a title to the plot (with embedded \LaTeX{})
+\item Labelling the axes
+\item Annotating the plot
+\item Setting the limits of axes.
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+
+ Plot sin(x) in blue colour and with linewidth as 3
\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 1}
+\label{sec-3}
+\lstset{language=Python}
+\begin{lstlisting}
+In []: clf()
+In []: plot(x, sin(x), 'b', linewidth=3)
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 2}
+\label{sec-4}
+
+ Plot the sine curve with green filled circles.
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 2}
+\label{sec-5}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: clf()
+In []: plot(x, cos(x), 'go')
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 3}
+\label{sec-6}
+
+ Plot the curve of x vs tan(x) in red dashed line and linewidth 3
\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 3}
+\label{sec-7}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: clf()
+In []: plot(x, cos(x), 'r--')
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 4}
+\label{sec-8}
+
+ Change the title of the figure such that the whole title is
+ formatted in LaTex style
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 4}
+\label{sec-9}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\lstset{language=Python}
+\begin{lstlisting}
+In []: title("$Parabolic function -x^2+4x-5$")
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 5}
+\label{sec-10}
+ Set the x and y labels as ``x'' and ``f(x)'' in LaTex style.
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 5}
+\label{sec-11}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: xlabel("$x$")
+In []: yalbel("$f(x)$")
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 6}
+\label{sec-12}
+
+ Make an annotation called ``root'' at the point (-4, 0). What happens
+ to the first annotation?
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 6}
+\label{sec-13}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: annotate("root", xy=(-4,0))
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 7}
+\label{sec-14}
+
+ Set the limits of axes such that the area of interest is the
+ rectangle (-1, -15) and (3, 0)
\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 7}
+\label{sec-15}
+\lstset{language=Python}
+\begin{lstlisting}
+In []: xlim(-1, 3)
+In []: ylim(-15, 0)
+\end{lstlisting}
+\end{frame}
\begin{frame}
- \frametitle{Thank you!}
+\frametitle{Summary}
+\label{sec-16}
+
+\begin{itemize}
+\item Modifying the attributes of plot by passing additional arguments
+\item How to add title
+\item How to incorporate \LaTeX{} style formatting
+\item How to label x and y axes
+\item How to add annotations
+\item How to set the limits of axes
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-17}
+
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/getting-started-files/quickref.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/getting-started-files/quickref.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,8 +1,12 @@
-Creating a linear array:\\
-{\ex \lstinline| x = linspace(0, 2*pi, 50)|}
+\textbf{Getting Started -- files}
+
+\lstinline|f = open('filename')| returns a file object. \lstinline|f|
+can be used to perform further operations on the file.
-Plotting two variables:\\
-{\ex \lstinline| plot(x, sin(x))|}
+\lstinline|f.read()| reads the whole file and returns the contents.
+
+\lstinline|f.close()| closes the file.
-Plotting two lists of equal length x, y:\\
-{\ex \lstinline| plot(x, y)|}
+\lstinline|for line in open('filename'):| -- iterate over the file
+line-by-line.
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/getting-started-files/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,73 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Getting started with files
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - Opening and reading contents of a file
+ - Closing open files
+ - Reading all the contents of the file at once
+ - Reading files line by line
+* Question 1
+ Split the variable into a list, =pend_list=, of the lines in the
+ file. Hint, use the tab command to see what methods the string
+ variable has.
+* Solution 1
+ #+begin_src python
+ In []: pend_list = pend.splitlines()
+
+ In []: pend_list
+ #+end_src
+* Question 2
+ Re-open the file =pendulum.txt= with =f= as the file object.
+* Solution 2
+ #+begin_src python
+ In []: f = open('/home/fossee/pendulum.txt')
+ #+end_src
+* Summary
+ - Opening a file using =open= function
+ - Reading all the contents of the file at once using =read()= method
+ - Closing open files using the =close= method
+ - Reading files line by line by iterating using a =for= loop
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/getting-started-files/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/getting-started-files/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,106 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 17:51
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Getting started with files}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Opening and reading contents of a file
+\item Closing open files
+\item Reading all the contents of the file at once
+\item Reading files line by line
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+ Split the variable into a list, \texttt{pend\_list}, of the lines in the
+ file. Hint, use the tab command to see what methods the string
+ variable has.
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
-\end{frame}
+\frametitle{Solution 1}
+\label{sec-3}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: pend_list = pend.splitlines()
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+In []: pend_list
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 2}
+\label{sec-4}
+ Re-open the file \texttt{pendulum.txt} with \texttt{f} as the file object.
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 2}
+\label{sec-5}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: f = open('/home/fossee/pendulum.txt')
+\end{lstlisting}
\end{frame}
-
\begin{frame}
- \frametitle{Thank you!}
+\frametitle{Summary}
+\label{sec-6}
+
+\begin{itemize}
+\item Opening a file using \texttt{open} function
+\item Reading all the contents of the file at once using \texttt{read()} method
+\item Closing open files using the \texttt{close} method
+\item Reading files line by line by iterating using a \texttt{for} loop
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-7}
+
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/getting-started-ipython/quickref.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/getting-started-ipython/quickref.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,8 +1,14 @@
-Creating a linear array:\\
-{\ex \lstinline| x = linspace(0, 2*pi, 50)|}
+\textbf{Getting started -- \texttt{ipython}}
+
+To start \lstinline|ipython| with \lstinline|pylab|:\\
+\lstinline| $ ipython -pylab| %$
+
+To exit: \lstinline|^D| (Ctrl-D)
-Plotting two variables:\\
-{\ex \lstinline| plot(x, sin(x))|}
+To interrupt: \lstinline|^C| (Ctrl-C)
+
+Tab completes partial commands
-Plotting two lists of equal length x, y:\\
-{\ex \lstinline| plot(x, y)|}
+\texttt{?} to look up documentation.
+
+Arrow keys to navigate the history.
--- a/getting-started-ipython/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/getting-started-ipython/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -105,7 +105,7 @@
Following is an exercise that you must do.
-%%1%% Type ``ab`` and hit tab to see what happens. Next, jut type
+%%1%% Type ``ab`` and hit tab to see what happens. Next, just type
``a`` and hit tab to see what happens.
Please, pause the video here. Do the exercise and then continue.
@@ -202,9 +202,16 @@
This brings us to the end of the tutorial on getting started with
``ipython``.
-In this tutorial we have learnt
+In this tutorial we have learnt, how to
{{{ show the outline/summary slide. }}}
+ 1. invoke the ``ipython`` interpreter.
+ #. quit the ``ipython`` interpreter.
+ #. navigate in the history of ``ipython``.
+ #. use tab-completion.
+ #. look-up documentation of functions.
+ #. interrupt incomplete or incorrect commands.
+
{{{ Show the "sponsored by FOSSEE" slide }}}
This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/getting-started-ipython/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,61 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER:\usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Getting Started -- ~ipython~
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ + invoke the ~ipython~ interpreter
+ + quit the ~ipython~ interpreter
+ + navigate in the history of ~ipython~
+ + use tab-completion
+ + look-up documentation of functions
+ + interrupt incomplete or incorrect commands
+* Summary
+ + invoking and quitting the ~ipython~ interpreter
+ + navigating the history
+ + using tab-completion to work faster
+ + looking-up documentation using ~?~
+ + sending keyboard interrupts using ~Ctrl-C~
+
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/getting-started-ipython/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/getting-started-ipython/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,74 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 17:34
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Getting Started -- \texttt{ipython}}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
-\end{frame}
-
-\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
-\end{frame}
+\frametitle{Outline}
+\label{sec-1}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{itemize}
+\item invoke the \texttt{ipython} interpreter
+\item quit the \texttt{ipython} interpreter
+\item navigate in the history of \texttt{ipython}
+\item use tab-completion
+\item look-up documentation of functions
+\item interrupt incomplete or incorrect commands
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Summary}
+\label{sec-2}
-\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+\begin{itemize}
+\item invoking and quitting the \texttt{ipython} interpreter
+\item navigating the history
+\item using tab-completion to work faster
+\item looking-up documentation using \texttt{?}
+\item sending keyboard interrupts using \texttt{Ctrl-C}
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-3}
-\begin{frame}
- \frametitle{Thank you!}
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/input_output/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/input_output/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -6,6 +6,12 @@
C -
D -
+.. #. How to print some value
+.. #. How to print using modifiers
+.. #. How to take input from user
+.. #. How to display a prompt to the user before taking the input
+
+
.. Prerequisites
.. -------------
@@ -73,7 +79,7 @@
{{{ Pause here and try out the following exercises }}}
-%% 1 %% What happens when you do print "x is %d y is %f"%(x)
+%% 1 %% What happens when you do ``print "x is %d y is %f" %(x, y)``
{{{ continue from paused state }}}
@@ -172,6 +178,9 @@
{{{ continue from paused state }}}
+.. #[Puneeth: We didn't talk of new-line character till now, did we?]
+.. #[Puneeth: non-programmers might not know?]
+
The trick is to include a newline character at the end of the prompt string.
::
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/input_output/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,84 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: I/O
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - Showing output to the user.
+ - Taking input from the user.
+* Question 1
+ What happens when you do ~print "x is %d y is %f" %(x, y)~
+* Solution 1
+ ~int~ value of ~x~ and ~float~ value of ~y~ are printed corresponding to the
+ modifiers used in the ~print~ statement
+* Question 2
+ Enter the number 5.6 as input and store it in a variable called
+ ~c~.
+* Solution 2
+ #+begin_src python
+ In []: c = raw_input()
+ 5.6
+ In []: c
+ #+end_src
+* Question 3
+ What happens when you do not enter anything and hit enter
+* Solution 3
+ #+begin_src python
+ In []: c = raw_input()
+ <RET>
+ In []: c
+ #+end_src
+* Question 4
+ How do you display a prompt and let the user enter input in a new line
+* Solution 4
+ #+begin_src python
+ In []: ip = raw_input("Please enter a number in the next line\n> ")
+ #+end_src
+* Summary
+ You should now be able to --
+ + Print a value "as is"
+ + Print a value using using modifiers
+ + Accept input from user
+ + Display a prompt before accepting input
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/input_output/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/input_output/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,133 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 21:00
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{I/O}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Showing output to the user.
+\item Taking input from the user.
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+
+ What happens when you do \texttt{print "x is \%d y is \%f" \%(x, y)}
\end{frame}
+\begin{frame}
+\frametitle{Solution 1}
+\label{sec-3}
+ \texttt{int} value of \texttt{x} and \texttt{float} value of \texttt{y} are printed corresponding to the
+ modifiers used in the \texttt{print} statement
+\end{frame}
+\begin{frame}
+\frametitle{Question 2}
+\label{sec-4}
+
+ Enter the number 5.6 as input and store it in a variable called
+ \texttt{c}.
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 2}
+\label{sec-5}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: c = raw_input()
+5.6
+In []: c
+\end{lstlisting}
\end{frame}
+\begin{frame}
+\frametitle{Question 3}
+\label{sec-6}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ What happens when you do not enter anything and hit enter
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 3}
+\label{sec-7}
+\lstset{language=Python}
+\begin{lstlisting}
+In []: c = raw_input()
+<RET>
+In []: c
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 4}
+\label{sec-8}
+
+ How do you display a prompt and let the user enter input in a new line
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 4}
+\label{sec-9}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: ip = raw_input("Please enter a number in the next line\n> ")
+\end{lstlisting}
\end{frame}
-
\begin{frame}
- \frametitle{Thank you!}
+\frametitle{Summary}
+\label{sec-10}
+
+ You should now be able to --
+\begin{itemize}
+\item Print a value ``as is''
+\item Print a value using using modifiers
+\item Accept input from user
+\item Display a prompt before accepting input
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-11}
+
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/loading-data-from-files/quickref.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/loading-data-from-files/quickref.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,8 +1,12 @@
-Creating a linear array:\\
-{\ex \lstinline| x = linspace(0, 2*pi, 50)|}
+\textbf{Loading data from files}
+
+\lstinline|loadtxt('filename')| returns the columns of file in one
+sequence.
-Plotting two variables:\\
-{\ex \lstinline| plot(x, sin(x))|}
+\lstinline|x, y = loadtxt('filename', unpack=True)| to obtain a file
+with 2 columns in separate sequences.
-Plotting two lists of equal length x, y:\\
-{\ex \lstinline| plot(x, y)|}
+\lstinline|loadtxt('filename', delimiter=';')|, if the file has
+columns separated by ';' instead of spaces/tabs.
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loading-data-from-files/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,67 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Loading data from files
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ + Read data from files with a single column of data
+ + Read data from files with multiple columns
+* Question 1
+ Read the file ~pendulum_semicolon.txt~ which contains the same data
+ as ~pendulum.txt~, but the columns are separated by semi-colons
+ instead of spaces. Use the IPython help to see how to do this.
+* Solution 1
+ #+begin_src python
+ In []: L, T = loadtxt('/home/fossee/pendulum_semicolon.txt', unpack=True, delimiter=';')
+
+ In []: print L
+
+ In []: print T
+ #+end_src
+* Summary
+ + Read data from files, containing a single column of data using the
+ ~loadtxt~ command.
+ + Read multiple columns of data, separated by spaces or other
+ delimiters.
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/loading-data-from-files/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/loading-data-from-files/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,90 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 18:12
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Loading data from files}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Read data from files with a single column of data
+\item Read data from files with multiple columns
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+ Read the file \texttt{pendulum\_semicolon.txt} which contains the same data
+ as \texttt{pendulum.txt}, but the columns are separated by semi-colons
+ instead of spaces. Use the IPython help to see how to do this.
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
-\end{frame}
+\frametitle{Solution 1}
+\label{sec-3}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\lstset{language=Python}
+\begin{lstlisting}
+In []: L, T = loadtxt('/home/fossee/pendulum_semicolon.txt', unpack=True, delimiter=';')
+
+In []: print L
-\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+In []: print T
+\end{lstlisting}
\end{frame}
-
\begin{frame}
- \frametitle{Thank you!}
+\frametitle{Summary}
+\label{sec-4}
+
+\begin{itemize}
+\item Read data from files, containing a single column of data using the
+ \texttt{loadtxt} command.
+\item Read multiple columns of data, separated by spaces or other
+ delimiters.
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-5}
+
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/loops/quickref.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/loops/quickref.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,8 +1,16 @@
-Creating a linear array:\\
-{\ex \lstinline| x = linspace(0, 2*pi, 50)|}
+\textbf{loops}
+
+To iterate over a sequence: \lstinline|for i in sequence:|\\
+\texttt{i} is the looping variable.
+
+To iterate while a condition is true: \lstinline|while condition:|
-Plotting two variables:\\
-{\ex \lstinline| plot(x, sin(x))|}
+Blocks in python are indented. To end block return to the previous
+indentation.
+
+To break out of the innermost loop: \lstinline|break|
-Plotting two lists of equal length x, y:\\
-{\ex \lstinline| plot(x, y)|}
+To skip to end of current iteration: \lstinline|continue|
+
+\lstinline|pass| is just a syntactic filler.
+
--- a/loops/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/loops/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -63,7 +63,7 @@
Following is an exercise that you must do.
%%1%% Write a ``while`` loop to print the squares of all the even
-numbers below 10. Then, return to the video.
+numbers below 10.
Please, pause the video here. Do the exercise and then continue.
@@ -88,8 +88,8 @@
Following is an exercise that you must do.
-%%2%% Pause the video here and write a ``for`` loop to print the
-squares of all the even numbers below 10. Then, return to the video.
+%%2%% Write a ``for`` loop to print the squares of all the even
+numbers below 10.
Please, pause the video here. Do the exercise and then continue.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loops/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,87 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Loops
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - Loop while a condition is true.
+ - Iterate over a sequence
+ - Breaking out of loops.
+ - Skipping iterations.
+* Question 1
+ Write a ~while~ loop to print the squares of all the even
+ numbers below 10.
+* Solution 1
+ #+begin_src python
+ In []: i = 2
+
+ In []: while i<10:
+ ....: print i*i
+ ....: i += 2
+ #+end_src
+* Question 2
+ Write a ~for~ loop to print the squares of all the even numbers
+ below 10.
+* Solution 2
+ #+begin_src python
+ In []: for n in range(2, 10, 2):
+ ....: print n*n
+ #+end_src
+* Question 3
+ Using the ~continue~ keyword modify the ~for~ loop to print the
+ squares of even numbers below 10, to print the squares of only
+ multiples of 4. (Do not modify the range function call.)
+* Solution 3
+ #+begin_src python
+ for n in range(2, 10, 2):
+ if n%4:
+ continue
+ print n*n
+ #+end_src
+* Summary
+ You should now be able to --
+ - use the ~for~ loop
+ - use the ~while~ loop
+ - Use ~break~, ~continue~ and ~pass~ statements
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/loops/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/loops/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,128 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 21:15
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Loops}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Loop while a condition is true.
+\item Iterate over a sequence
+\item Breaking out of loops.
+\item Skipping iterations.
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+ Write a \texttt{while} loop to print the squares of all the even
+ numbers below 10.
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 1}
+\label{sec-3}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: i = 2
+
+In []: while i<10:
+ ....: print i*i
+ ....: i += 2
+\end{lstlisting}
\end{frame}
+\begin{frame}
+\frametitle{Question 2}
+\label{sec-4}
+
+ Write a \texttt{for} loop to print the squares of all the even numbers
+ below 10.
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 2}
+\label{sec-5}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\lstset{language=Python}
+\begin{lstlisting}
+In []: for n in range(2, 10, 2):
+ ....: print n*n
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 3}
+\label{sec-6}
+ Using the \texttt{continue} keyword modify the \texttt{for} loop to print the
+ squares of even numbers below 10, to print the squares of only
+ multiples of 4. (Do not modify the range function call.)
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 3}
+\label{sec-7}
+
+\lstset{language=Python}
+\begin{lstlisting}
+for n in range(2, 10, 2):
+ if n%4:
+ continue
+ print n*n
+\end{lstlisting}
\end{frame}
-
\begin{frame}
- \frametitle{Thank you!}
+\frametitle{Summary}
+\label{sec-8}
+
+ You should now be able to --
+\begin{itemize}
+\item use the \texttt{for} loop
+\item use the \texttt{while} loop
+\item Use \texttt{break}, \texttt{continue} and \texttt{pass} statements
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-9}
+
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/lstsq/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/lstsq/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -6,11 +6,13 @@
C -
D -
+.. Plotting a least square fit line
+
.. Prerequisites
.. -------------
.. 1. Basic Plotting
- 2. Arrays
+.. 2. Arrays
.. Author : Nishanth Amuluru
Internal Reviewer :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lstsq/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,52 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Least square fit
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - Plotting a Least square fit line
+* Summary
+ You should now be able to --
+ - Plot a least square fit line.
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/lstsq/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/lstsq/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,66 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 19:02
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Least square fit}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
-\end{frame}
-
-\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
-\end{frame}
+\frametitle{Outline}
+\label{sec-1}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{itemize}
+\item Plotting a Least square fit line
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Summary}
+\label{sec-2}
-\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+ You should now be able to --
+\begin{itemize}
+\item Plot a least square fit line.
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-3}
-\begin{frame}
- \frametitle{Thank you!}
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/manipulating-strings/quickref.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/manipulating-strings/quickref.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,8 +1,14 @@
-Creating a linear array:\\
-{\ex \lstinline| x = linspace(0, 2*pi, 50)|}
+\textbf{Manipulating strings}
+
+String indexing starts from 0, like lists.
-Plotting two variables:\\
-{\ex \lstinline| plot(x, sin(x))|}
+\lstinline|s = `Hello World'|\\
+\lstinline|s[0:5]| gives \texttt{Hello}\\
+\lstinline|s[6:]| gives \textt{World}\\
+\lstinline|s[6::2]| gives \textt{Wrd}\\
-Plotting two lists of equal length x, y:\\
-{\ex \lstinline| plot(x, y)|}
+\lstinline|s.replace('e', 'a')| returns a new string with all e's
+replaced by a.
+
+\lstinline|s.lower()| and \lstinline|s.upper()| return new strings
+with all lower and upper case letters, respectively.
--- a/manipulating-strings/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/manipulating-strings/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -6,7 +6,7 @@
.. 1. Slice strings and get sub-strings out of them
.. #. Reverse strings
.. #. Replace characters in strings.
-.. #. Convert to strings to upper or lower case
+.. #. Convert strings to upper or lower case
.. #. joining a list of strings
.. Prerequisites
@@ -84,7 +84,7 @@
Following is an exercise that you must do.
%%1%% Obtain the sub-string excluding the first and last characters
-from the string.
+from the string s.
Please, pause the video here. Do the exercise(s) and then continue.
@@ -167,6 +167,8 @@
::
+ s in week
+
s.lower()[:3] in week
We just convert any input string to lower case and then check if it is
@@ -191,7 +193,7 @@
Following is an exercise that you must do.
-%%3%% Replace the ``[dot]`` with ``.``
+%%3%% Replace the ``[dot]`` with ``.`` in ``email``
Please, pause the video here. Do the exercise and then continue.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/manipulating-strings/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,94 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Manipulating strings
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - Slicing strings to get sub-strings
+ - Reversing strings
+ - Replacing characters in strings.
+ - Converting strings to upper or lower case
+ - Joining a list of strings
+* Question 1
+ Obtain the sub-string excluding the first and last characters from
+ the string ~s~.
+* Solution 1
+ #+begin_src python
+ In []: s[1:-1]
+ #+end_src
+* Question 2
+ Given a list week, week = ~week = ["sun", "mon", "tue", "wed",
+ "thu", "fri", "sat"]~. Check if ~s~ is a valid name of a day of the
+ week. Change the solution to this problem, to include forms like,
+ SAT, SATURDAY, Saturday and Sat.
+* Solution 2
+ #+begin_src python
+ In []: s in week
+ In []: s.lower()[:3] in week
+ #+end_src
+* Question 3
+ Given ~email~ -- ~info@fossee[dot]in~
+
+ Replace the ~[dot]~ with ~.~ in ~email~
+* Solution 3
+ #+begin_src python
+ email.replace('[dot], '.')
+ print email
+ #+end_src
+* Question 4
+ From the ~email_str~ that we generated, change the separator to be a
+ semicolon instead of a comma.
+* Solution 4
+ #+begin_src python
+ email_str = email_str.replace(",", ";")
+ #+end_src
+* Summary
+ You should now be able to --
+ - Slice strings and get sub-strings out of them
+ - Reverse strings
+ - Replace characters in strings.
+ - Convert strings to upper or lower case
+ - Join a list of strings
+
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/manipulating-strings/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/manipulating-strings/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,142 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-11 Mon 11:27
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Manipulating strings}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Slicing strings to get sub-strings
+\item Reversing strings
+\item Replacing characters in strings.
+\item Converting strings to upper or lower case
+\item Joining a list of strings
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+ Obtain the sub-string excluding the first and last characters from
+ the string \texttt{s}.
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 1}
+\label{sec-3}
+
+\lstset{language=Python}
+\begin{lstlisting}
+In []: s[1:-1]
+\end{lstlisting}
\end{frame}
+\begin{frame}
+\frametitle{Question 2}
+\label{sec-4}
+
+ Given a list week, week = \texttt{week = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]}. Check if \texttt{s} is a valid name of a day of the
+ week. Change the solution to this problem, to include forms like,
+ SAT, SATURDAY, Saturday and Sat.
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 2}
+\label{sec-5}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\lstset{language=Python}
+\begin{lstlisting}
+In []: s in week
+In []: s.lower()[:3] in week
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 3}
+\label{sec-6}
+ Given \texttt{email} -- \texttt{info@fossee[dot]in}
+
+ Replace the \texttt{[dot]} with \texttt{.} in \texttt{email}
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 3}
+\label{sec-7}
+
+\lstset{language=Python}
+\begin{lstlisting}
+email.replace('[dot], '.')
+print email
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 4}
+\label{sec-8}
+
+ From the \texttt{email\_str} that we generated, change the separator to be a
+ semicolon instead of a comma.
\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 4}
+\label{sec-9}
+\lstset{language=Python}
+\begin{lstlisting}
+email_str = email_str.replace(",", ";")
+\end{lstlisting}
+\end{frame}
\begin{frame}
- \frametitle{Thank you!}
+\frametitle{Summary}
+\label{sec-10}
+
+ You should now be able to --
+\begin{itemize}
+\item Slice strings and get sub-strings out of them
+\item Reverse strings
+\item Replace characters in strings.
+\item Convert strings to upper or lower case
+\item Join a list of strings
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-11}
+
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/matrices/questions.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/matrices/questions.rst Mon Oct 11 22:44:21 2010 +0530
@@ -3,6 +3,82 @@
.. A mininum of 8 questions here (along with answers)
+1. ``matrix(A) * matrix(B)`` and ``array(A) * array(B)`` are the same.
+
+ a. True
+ #. False
+
+Answer: False
+
+2. ``matrix(A) * array(B)`` does,
+
+ a. Element wise multiplication.
+ #. Matrix multiplication.
+ #. Cannot multiply a matrix object and array object.
+ #. Depends on the shape of A and B, if compatible matrix
+ multiplication will be done, otherwise element wise
+ multiplication.
+
+Answer: Matrix multiplication
+
+3. A and B are two matrix objects. Element wise multiplication in
+ matrices are done by,
+
+ a. A * B
+ #. ``multiply(A, B)``
+ #. ``dot(A, B)``
+ #. ``element_multiply(A,B)``
+
+Answer: multiply(A, B)
+
+4. ``norm(A)`` method determines the,
+
+ a. Frobenius norm
+ #. Infinity norm
+ #. Induced norm
+ #. Schatten norm
+
+Answer: Frobenius norm
+
+5. ``eig(A)[1]`` and ``eigvals(A)`` are the same.
+
+ a. True
+ #. False
+
+Answer: False
+
+6. The code snippet will work without an error,
+ ::
+
+ A = matrix([[1, 2, 3, 4], [5, 6, 7, 8]])
+ inv(A)
+
+ a. True
+ #. False
+
+Answer: False
+
+7. What is the output of the following code,
+ ::
+
+ x = matrix([[1, 2, 3], ['a', 2, 'c']])
+ identity(x.shape)
+
+ a. Will create an identity matrix of shape (2, 3).
+ #. ``identity()`` function takes an integer as argument and a tuple
+ is passed.
+ #. Will return, matrix([[1,0,1],[0,1,0]])
+ #. Will return, matrix([[0,1,0],[0,1,0]])
+
+Answer: ``identity()`` function takes an integer as argument and a
+ tuple is passed.
+
+8. ``norm(A,ord='fro')`` is the same as ``norm(A)``
+
+ a. True
+ #. False
+
+Answer: True
Larger Questions
----------------
@@ -30,3 +106,11 @@
What will be the array after 22 such operations starting with [1,
2, 3, 4, 5, 6, 7, 8, 9, 10]
+2. Find the infinity norm and the determinant of the inverse of the
+ product of matrices A and B.
+ ::
+
+ A = [[ 1, 2, 3, 4], B = [[16, 15, 14, 13],
+ [ 5, 6, 7, 8], [12, 11, 10, 9],
+ [ 9, 10, 11, 12], [ 8, 7, 6, 5],
+ [13, 14, 15, 16]] [ 4, 3, 2, 1]]
--- a/matrices/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/matrices/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -70,6 +70,8 @@
it does matrix subtraction, that is element by element
subtraction. Now let us try,
+
+{{{ Switch to next slide, Matrix multiplication }}}
::
m3 * m2
@@ -120,9 +122,9 @@
Matrix name dot capital T will give the transpose of a matrix
-{{{ switch to next slide, Euclidean norm of inverse of matrix }}}
+{{{ switch to next slide, Frobenius norm of inverse of matrix }}}
-Now let us try to find out the Euclidean norm of inverse of a 4 by 4
+Now let us try to find out the Frobenius norm of inverse of a 4 by 4
matrix, the matrix being,
::
@@ -131,17 +133,17 @@
The inverse of a matrix A, A raise to minus one is also called the
reciprocal matrix such that A multiplied by A inverse will give 1. The
-Euclidean norm or the Frobenius norm of a matrix is defined as square
-root of sum of squares of elements in the matrix. Pause here and try
-to solve the problem yourself, the inverse of a matrix can be found
-using the function ``inv(A)``.
+Frobenius norm of a matrix is defined as square root of sum of squares
+of elements in the matrix. Pause here and try to solve the problem
+yourself, the inverse of a matrix can be found using the function
+``inv(A)``.
And here is the solution, first let us find the inverse of matrix m5.
::
im5 = inv(m5)
-And the euclidean norm of the matrix ``im5`` can be found out as,
+And the Frobenius norm of the matrix ``im5`` can be found out as,
::
sum = 0
@@ -166,16 +168,18 @@
{{{ switch to slide the ``norm()`` method }}}
-Well! to find the Euclidean norm and Infinity norm we have an even easier
+Well! to find the Frobenius norm and Infinity norm we have an even easier
method, and let us see that now.
The norm of a matrix can be found out using the method
-``norm()``. Inorder to find out the Euclidean norm of the matrix im5,
+``norm()``. Inorder to find out the Frobenius norm of the matrix im5,
we do,
::
norm(im5)
+Euclidean norm is also called Frobenius norm.
+
And to find out the Infinity norm of the matrix im5, we do,
::
Binary file other-type-of-plots/bar-chart-hatch.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/other-type-of-plots/company-a-data.txt Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,2 @@
+2.000000000000000000e+03 2.001000000000000000e+03 2.002000000000000000e+03 2.003000000000000000e+03 2.004000000000000000e+03 2.005000000000000000e+03 2.006000000000000000e+03 2.007000000000000000e+03 2.008000000000000000e+03 2.009000000000000000e+03 2.010000000000000000e+03
+2.300000000000000000e+01 5.500000000000000000e+01 3.200000000000000000e+01 6.500000000000000000e+01 8.800000000000000000e+01 5.000000000000000000e+00 1.400000000000000000e+01 6.700000000000000000e+01 2.300000000000000000e+01 2.300000000000000000e+01 1.200000000000000000e+01
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/other-type-of-plots/questions.rst Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,85 @@
+Objective Questions
+-------------------
+
+.. A mininum of 8 questions here (along with answers)
+
+1. What is a log-log chart?
+
+ a. A straight line graph
+ #. A graph on the logarithmic scale
+ #. A graph on the logarithmic scale with different scales for x and
+ y axes
+ #. A graph in which x axis is represented in logarithmic scale.
+
+Answer: A graph on the logarithmic scale with different scales for x
+ and y axes
+
+2. We have two lists with us ``years`` and ``profit``, what statement
+ can be issued to plot a pie chart to plot the profit for each year,
+ and each wedge has to be labelled with the corresponding year.
+
+Answer: pie(profit, labels=years)
+
+3. We have two lists with us ``years`` and profit``, what statement
+ can be issued to plot a scatter plot of the data in blue colored
+ diamonds. ``years`` has to be plotted along x-axis.
+
+Answer: scatter(year,profit,color='blue',marker='d')
+
+4. ``scatter(x, y, color='blue', marker='d')`` and ``plot(x, y,
+ color='b', marker='d')`` does exactly the same.
+
+ a. True
+ #. False
+
+Answer: False
+
+5. ``plot(x, y, 'bd')`` creates a scattered plot in blue color and
+ diamond markers?
+
+ a. True
+ #. False
+
+Answer: True
+
+6. ``scatter(x, y, 'bd')`` creates a scatter plot in blue color with
+ diamond markers.
+
+ a. True
+ #. False
+
+Answer: False
+
+7. What statement can be issued to generate a bar chart with 135\
+ :sup:`o` hatched bar filled with white.
+
+ a. bar(x, y, color='w', hatch='/')
+ #. bar(x, y, color='w', hatch='\\')
+ #. bar(x, y, color='w', hatch='\')
+ #. bar(x, y, color='w', hatch='|')
+
+Answer: bar(x, y, color='w', hatch='\\')
+
+8. What statement can be issued to generate a bar chart with vertical
+ line hatching.
+
+ a. bar(x, y, color='w', hatch='/')
+ #. bar(x, y, fill=False, hatch='\\')
+ #. bar(x, y, fill=False, hatch='|')
+ #. bar(x, y, color='w', hatch='\')
+
+Answer: bar(x, y, fill=False, hatch='|')
+
+Larger Questions
+----------------
+
+.. A minimum of 2 questions here (along with answers)
+
+1. Plot a log-log chart of the equation y=4*x\ :sup:`2` + 3*x for x
+ from -50 to 50.
+
+2. Plot a bar chart which is filled with white color and which is
+ hatched with 135\ :sup:`o` slanting lines for the data given in the
+ `file(company A data) <company-a-data.txt>`_ which has years and
+ profit percentage for each year.
+
--- a/other-type-of-plots/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/other-type-of-plots/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -20,7 +20,6 @@
log plot. We will also see few other plots and also introduce you to
the matplotlib help.
-
Let us start with scatter plot.
{{{ switch to the next slide }}}
@@ -55,11 +54,12 @@
{{{ close the file and switch to the terminal }}}
-To product the scatter plot first we need to load the data from the
+To produce the scatter plot first we need to load the data from the
file using ``loadtxt``. We learned in one of the previous sessions,
and it can be done as ::
- year,profit = loadtxt('/home/fossee/other-plot/company-a-data.txt',dtype=type(int()))
+ year,profit =
+ loadtxt('/home/fossee/other-plot/company-a-data.txt',dtype=type(int()))
Now in-order to generate the scatter graph we will use the function
``scatter()``
@@ -100,9 +100,9 @@
pie(profit,labels=year)
-Notice that we passed two arguments to the function ``pie()``. The
-first one the values and the next one the set of labels to be used in
-the pie chart.
+Notice that we passed two arguments to the function ``pie()``. First
+one the values and the next one the set of labels to be used in the
+pie chart.
{{{ switch to the next slide which has the problem statement of
problem to be tried out }}}
@@ -195,14 +195,10 @@
Help about matplotlib can be obtained from
matplotlib.sourceforge.net/contents.html
-.. #[[Anoop: I am not so sure how to do the rest of it, so I guess we
- can just browse through the side and tell them few. What is your
- opinion??]]
-Now let us see few plots from
-matplotlib.sourceforge.net/users/screenshots.html
-
-{{{ browse through the site quickly }}}
+More plots can be seen at
+matplotlib.sourceforge.net/users/screenshots.html and also at
+matplotlib.sourceforge.net/gallery.html
{{{ switch to recap slide }}}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/parsing_data/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,84 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Parsing Data
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - What is meant by parsing data?
+ - String operations required for parsing
+ - Converting between data-types.
+* Question 1
+ Split the variable line using a space as argument. Is it same as
+ splitting without an argument ?
+* Solution 1
+ We see that when we split on space, multiple whitespaces are not
+ clubbed as one and there is an empty string everytime there are two
+ consecutive spaces.
+* Question 2
+ What happens to the white space inside the sentence when it is
+ stripped?
+* Solution 2
+ #+begin_src python
+ In []: a_str = " white space "
+ In []: a_str.strip()
+ #+end_src
+* Question 3
+ What happens if you do =int("1.25")=
+* Solution 3
+ It raises an error since converting a float string into integer
+ directly is not possible. It involves an intermediate step of
+ converting to float.
+ #+begin_src python
+ In []: dcml_str = "1.25"
+ In []: flt = float(dcml_str)
+ In []: flt
+ In []: number = int(flt)
+ In []: number
+ #+end_src
+* Summary
+ + How to tokenize a string using various delimiters
+ + How to get rid of extra white space around
+ + How to convert from one type to another
+ + How to parse input data and perform computations on it
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/parsing_data/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/parsing_data/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,124 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 18:28
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Parsing Data}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item What is meant by parsing data?
+\item String operations required for parsing
+\item Converting between data-types.
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+
+ Split the variable line using a space as argument. Is it same as
+ splitting without an argument ?
\end{frame}
+\begin{frame}
+\frametitle{Solution 1}
+\label{sec-3}
+ We see that when we split on space, multiple whitespaces are not
+ clubbed as one and there is an empty string everytime there are two
+ consecutive spaces.
+\end{frame}
+\begin{frame}
+\frametitle{Question 2}
+\label{sec-4}
+
+ What happens to the white space inside the sentence when it is
+ stripped?
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
-\end{frame}
+\frametitle{Solution 2}
+\label{sec-5}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\lstset{language=Python}
+\begin{lstlisting}
+In []: a_str = " white space "
+In []: a_str.strip()
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Question 3}
+\label{sec-6}
+ What happens if you do \texttt{int("1.25")}
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+\frametitle{Solution 3}
+\label{sec-7}
+
+ It raises an error since converting a float string into integer
+ directly is not possible. It involves an intermediate step of
+ converting to float.
+\lstset{language=Python}
+\begin{lstlisting}
+In []: dcml_str = "1.25"
+In []: flt = float(dcml_str)
+In []: flt
+In []: number = int(flt)
+In []: number
+\end{lstlisting}
\end{frame}
-
\begin{frame}
- \frametitle{Thank you!}
+\frametitle{Summary}
+\label{sec-8}
+
+\begin{itemize}
+\item How to tokenize a string using various delimiters
+\item How to get rid of extra white space around
+\item How to convert from one type to another
+\item How to parse input data and perform computations on it
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-9}
+
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- a/savefig/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/savefig/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -9,8 +9,16 @@
Savefig
=======
-Hello and welcome to the tutorial. In this tutorial you will learn how
-to save plots using Python.
+{{{ Show the first slide }}}
+
+Hello and welcome to the tutorial saving plots.
+
+{{{ switch to next slide, outline slide }}}
+
+In this tutorial you will learn how to save plots using Python. And
+saving in different formats, and locating the file in the file system.
+
+{{{ switch to next slide, a sine wave}}}
Start your IPython interpreter with the command ::
@@ -38,9 +46,11 @@
the plot for future use so that you can embed the plot in your
reports.
+{{{ switch to next slide, savefig() }}}
+
{{{ Switch the focus to IPython interpreter window }}}
-For saving the plot, we will use savefig function, and it has to be
+For saving the plot, we will use ``savefig()`` function, and it has to be
done with the plot window open. The statement is, ::
savefig('/home/fossee/sine.png')
@@ -73,6 +83,8 @@
close it and return to IPython interpreter, make sure the plot window
is still open, also don't close the file browser window }}}
+{{{ switch to next slide, More on savefig() }}}
+
So in-order to save a plot, we use ``savefig`` function. ``savefig``
can save the plot in many formats, such as pdf - portable document
format, ps - post script, eps - encapsulated post script, svg -
@@ -81,15 +93,19 @@
.. #[[slide must give the extensions for the files - Anoop]]
+{{{ switch to next slide, exercise 1 }}}
+
Let us now try to save the plot in eps format. ``eps`` stands for
encapsulated post script, and it can be embedded in your latex
-documents.
+documents. Pause here and try to figure it out yourself.
{{{ Switch focus to the already open plot window }}}
We still have the sine plot with us, and now let us save the plot as
``sine.eps``.
+{{{ switch to next slide, solution 1 }}}
+
{{{ Switch focus to IPython interpreter }}}
Now, We will save the plot using the function ``savefig`` ::
@@ -105,10 +121,17 @@
Yes! the new file ``sine.eps`` is here.
+{{{ switch to next slide, exercise 2 }}}
+
Now you may try saving the same in pdf, ps, svg formats.
-Let us review what we have learned in this session! We have learned to
-save plots in different formats using the function ``savefig()``.
+{{{ Switch to summary slide }}}
+
+This brings us to the end of this tutorial, in this tutorial we
+learned to save plots using the function ``savefig()``. Saving the
+plots in different formats and locating the files in the file system.
+
+{{{ switch to Thank you slide }}}
Thank you!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/savefig/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,99 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Savefig
+#+AUTHOR: FOSSEE
+#+EMAIL: info@fossee.in
+#+DATE: 2010-10-11 Mon
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - Saving plots.
+ - Plotting in different formats.
+ - Locating the file in the file system.
+
+* Creating a basic plot
+ Plot a sine wave from -3pi to 3pi.
+ #+begin_src python
+ In []: x = linspace(-3*pi,3*pi,100)
+
+ In []: plot(x, sin(x))
+ #+end_src
+* savefig()
+** savefig() - to save plots
+ : syntax: savefig(fname)
+** example
+*** savefig('/home/fossee/sine.png')
+ - file sine.png saved to the folder /home/fossee
+ - .png - file type
+
+* More on savefig()
+** Recall
+ - .png - file type
+** File types supported
+*** .pdf - PDF(Portable Document Format)
+*** .ps - PS(Post Script)
+*** .eps - Encapsulated Post Script
+ ~to be used with~ LaTeX ~documents~
+*** .svg - Scalable Vector Graphics
+ ~vector graphics~
+*** .png - Portable Network Graphics
+ ~supports transparency~
+* Exercise 1
+ Save the sine plot in the format EPS which can be embedded in LaTeX documents.
+* Solution 1
+ #+begin_src python
+ savefig('/home/fossee/sine.eps')
+ #+end_src
+* Exercise 2
+ Save the sine plot in PDF, PS and SVG formats.
+
+* Summary
+ You should now be able to
+ - Use ~savefig()~ function
+ - Save plots in different formats
+ - PDF
+ - PS
+ - PNG
+ - SVG
+ - EPS
+ - Locating the files in file system.
+
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/savefig/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,185 @@
+% Created 2010-10-11 Mon 17:08
+\documentclass[presentation]{beamer}
+\usepackage[latin1]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{t1enc}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
+
+\title{Savefig}
+\author{FOSSEE}
+\date{2010-10-11 Mon}
+
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+\begin{document}
+
+\maketitle
+
+
+
+
+
+
+
+
+
+\begin{frame}
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Saving plots.
+\item Plotting in different formats.
+\item Locating the file in the file system.
+\end{itemize}
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Creating a basic plot}
+\label{sec-2}
+
+ Plot a sine wave from -3pi to 3pi.
+\begin{verbatim}
+In []: x = linspace(-3*pi,3*pi,100)
+
+In []: plot(x, sin(x))
+\end{verbatim}
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{savefig()}
+\label{sec-3}
+\begin{itemize}
+
+\item savefig() - to save plots
+\label{sec-3_1}%
+\begin{verbatim}
+ syntax: savefig(fname)
+\end{verbatim}
+
+
+\item example
+\label{sec-3_2}%
+\begin{itemize}
+
+\item savefig('/home/fossee/sine.png')
+\label{sec-3_2_1}%
+\begin{itemize}
+\item file sine.png saved to the folder /home/fossee
+\item .png - file type
+\end{itemize}
+
+
+\end{itemize} % ends low level
+\end{itemize} % ends low level
+\end{frame}
+\begin{frame}
+\frametitle{More on savefig()}
+\label{sec-4}
+\begin{itemize}
+
+\item Recall
+\label{sec-4_1}%
+\begin{itemize}
+\item .png - file type
+\end{itemize}
+
+
+\item File types supported
+\label{sec-4_2}%
+\begin{itemize}
+
+\item .pdf - PDF(Portable Document Format)\\
+\label{sec-4_2_1}%
+\item .ps - PS(Post Script)\\
+\label{sec-4_2_2}%
+\item .eps - Encapsulated Post Script\\
+\label{sec-4_2_3}%
+\texttt{to be used with} \LaTeX{} \texttt{documents}
+
+\item .svg - Scalable Vector Graphics\\
+\label{sec-4_2_4}%
+\texttt{vector graphics}
+
+\item .png - Portable Network Graphics\\
+\label{sec-4_2_5}%
+\texttt{supports transparency}
+\end{itemize} % ends low level
+\end{itemize} % ends low level
+\end{frame}
+\begin{frame}
+\frametitle{Exercise 1}
+\label{sec-5}
+
+ Save the sine plot in the format EPS which can be embedded in \LaTeX{} documents.
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solution 1}
+\label{sec-6}
+
+\begin{verbatim}
+savefig('/home/fossee/sine.eps')
+\end{verbatim}
+\end{frame}
+\begin{frame}
+\frametitle{Exercise 2}
+\label{sec-7}
+
+ Save the sine plot in PDF, PS and SVG formats.
+\end{frame}
+\begin{frame}
+\frametitle{Summary}
+\label{sec-8}
+
+ You should now be able to
+\begin{itemize}
+\item Use \texttt{savefig()} function
+\item Save plots in different formats
+
+\begin{itemize}
+\item PDF
+\item PS
+\item PNG
+\item SVG
+\item EPS
+\end{itemize}
+
+\item Locating the files in file system.
+\end{itemize}
+
+
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-9}
+
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+\end{frame}
+
+\end{document}
--- a/sets/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/sets/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -153,7 +153,7 @@
* How to make sets from lists
* How to input sets
- * How to perform union, intersection and symmectric difference operations
+ * How to perform union, intersection and symmetric difference operations
* How to check if a set is a subset of other
* The various similarities with lists like length and containership
@@ -163,5 +163,5 @@
This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
Hope you have enjoyed and found it useful.
-Thankyou
+Thank you!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sets/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,71 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Sets
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - Defining Sets
+ - Operations on sets
+
+* Question 1
+ Given a list of marks, ~marks = [20, 23, 22, 23, 20, 21, 23]~ list
+ all the duplicates
+* Solution 1
+ #+begin_src python
+ marks = [20, 23, 22, 23, 20, 21, 23]
+ marks_set = set(marks)
+ for mark in marks_set:
+ marks.remove(mark)
+
+ # we are now left with only duplicates in the list marks
+ duplicates = set(marks)
+ #+end_src
+* Summary
+ You should now be able to --
+ + make sets from lists
+ + input sets directly
+ + perform operations like union, intersection, symmetric difference
+ + check if a subset of another
+ + check containership, length and other properties similar to lists
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/sets/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/sets/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,93 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 23:53
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Sets}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item Defining Sets
+\item Operations on sets
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+ Given a list of marks, \texttt{marks = [20, 23, 22, 23, 20, 21, 23]} list
+ all the duplicates
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
-\end{frame}
+\frametitle{Solution 1}
+\label{sec-3}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\lstset{language=Python}
+\begin{lstlisting}
+marks = [20, 23, 22, 23, 20, 21, 23]
+marks_set = set(marks)
+for mark in marks_set:
+ marks.remove(mark)
-\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+# we are now left with only duplicates in the list marks
+duplicates = set(marks)
+\end{lstlisting}
\end{frame}
-
\begin{frame}
- \frametitle{Thank you!}
+\frametitle{Summary}
+\label{sec-4}
+
+ You should now be able to --
+\begin{itemize}
+\item make sets from lists
+\item input sets directly
+\item perform operations like union, intersection, symmetric difference
+\item check if a subset of another
+\item check containership, length and other properties similar to lists
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-5}
+
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/template/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,123 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Accessing parts of arrays
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - Manipulating one and multi dimensional arrays
+ - Access and change individual elements
+ - Access and change rows and columns
+ - Slicing and striding on arrays to access chunks
+ - Read images into arrays and manipulations
+* Sample Arrays
+ #+begin_src python
+ In []: A = array([12, 23, 34, 45, 56])
+
+ In []: C = array([[11, 12, 13, 14, 15],
+ [21, 22, 23, 24, 25],
+ [31, 32, 33, 34, 35],
+ [41, 42, 43, 44, 45],
+ [51, 52, 53, 54, 55]])
+
+ #+end_src
+* Question 1
+ Change the last column of ~C~ to zeroes.
+* Solution 1
+ #+begin_src python
+ In []: C[:, -1] = 0
+ #+end_src
+* Question 2
+ Change ~A~ to ~[11, 12, 13, 14, 15]~.
+* Solution 2
+ #+begin_src python
+ In []: A[:] = [11, 12, 13, 14, 15]
+ #+end_src
+* squares.png
+ #+begin_latex
+ \begin{center}
+ \includegraphics[scale=0.6]{squares}
+ \end{center}
+ #+end_latex
+* Question 3
+ - obtain ~[22, 23]~ from ~C~.
+ - obtain ~[11, 21, 31, 41]~ from ~C~.
+ - obtain ~[21, 31, 41, 0]~.
+* Solution 3
+ #+begin_src python
+ In []: C[1, 1:3]
+ In []: C[0:4, 0]
+ In []: C[1:5, 0]
+ #+end_src
+* Question 4
+ Obtain ~[[23, 24], [33, -34]]~ from ~C~
+* Solution 4
+ #+begin_src python
+ In []: C[1:3, 2:4]
+ #+end_src
+* Question 5
+ Obtain the square in the center of the image
+* Solution 5
+ #+begin_src python
+ In []: imshow(I[75:225, 75:225])
+ #+end_src
+* Question 6
+ Obtain the following
+ #+begin_src python
+ [[12, 0], [42, 0]]
+ [[12, 13, 14], [0, 0, 0]]
+ #+end_src
+
+* Solution 6
+ #+begin_src python
+ In []: C[::3, 1::3]
+ In []: C[::4, 1:4]
+ #+end_src
+* Summary
+ You should now be able to --
+ - Manipulate 1D \& Multi dimensional arrays
+ - Access and change individual elements
+ - Access and change rows and columns
+ - Slice and stride on arrays
+ - Read images into arrays and manipulate them.
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/tuples/script.rst Sun Oct 10 16:00:59 2010 +0530
+++ b/tuples/script.rst Mon Oct 11 22:44:21 2010 +0530
@@ -7,6 +7,11 @@
C -
D -
+.. #. what are tuples
+.. #. comparison with lists
+.. #. why are they needed
+
+
.. Prerequisites
.. -------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tuples/slides.org Mon Oct 11 22:44:21 2010 +0530
@@ -0,0 +1,69 @@
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+#+BEAMER_FRAME_LEVEL: 1
+
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
+#+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
+#+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER: commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER: showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+
+#+TITLE: Getting started -- Tuples
+#+AUTHOR: FOSSEE
+#+EMAIL:
+#+DATE:
+
+#+DESCRIPTION:
+#+KEYWORDS:
+#+LANGUAGE: en
+#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
+
+* Outline
+ - what are tuples
+ - comparison with lists
+ - why are they needed
+* Question 1
+ ~a = 5~ and ~b = 7~. swap the values of ~a~ and ~b~
+* Solution 1
+ #+begin_src python
+ temp = a
+ a = b
+ b = temp
+
+ a
+ b
+ #+end_src
+* Summary
+ You should now --
+ + Be able to define tuples
+ + Know the similarities with lists, like -- indexing and iterability
+ + Know about the immutability of tuples
+ + Be able to swap variables in the Pythonic way
+ + Know about packing and unpacking of tuples
+* Thank you!
+#+begin_latex
+ \begin{block}{}
+ \begin{center}
+ This spoken tutorial has been produced by the
+ \textcolor{blue}{FOSSEE} team, which is funded by the
+ \end{center}
+ \begin{center}
+ \textcolor{blue}{National Mission on Education through \\
+ Information \& Communication Technology \\
+ MHRD, Govt. of India}.
+ \end{center}
+ \end{block}
+#+end_latex
+
+
--- a/tuples/slides.tex Sun Oct 10 16:00:59 2010 +0530
+++ b/tuples/slides.tex Mon Oct 11 22:44:21 2010 +0530
@@ -1,95 +1,92 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%Tutorial slides on Python.
-%
-% Author: FOSSEE
-% Copyright (c) 2009, FOSSEE, IIT Bombay
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\documentclass[14pt,compress]{beamer}
-%\documentclass[draft]{beamer}
-%\documentclass[compress,handout]{beamer}
-%\usepackage{pgfpages}
-%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]
-
-% Modified from: generic-ornate-15min-45min.de.tex
-\mode<presentation>
-{
- \usetheme{Warsaw}
- \useoutertheme{infolines}
- \setbeamercovered{transparent}
-}
-
-\usepackage[english]{babel}
+% Created 2010-10-10 Sun 23:03
+\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
-%\usepackage{times}
\usepackage[T1]{fontenc}
-
-\usepackage{ae,aecompl}
-\usepackage{mathpazo,courier,euler}
-\usepackage[scaled=.95]{helvet}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
+\providecommand{\alert}[1]{\textbf{#1}}
-\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}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Macros
-\setbeamercolor{emphbar}{bg=blue!20, fg=black}
-\newcommand{\emphbar}[1]
-{\begin{beamercolorbox}[rounded=true]{emphbar}
- {#1}
- \end{beamercolorbox}
-}
-\newcounter{time}
-\setcounter{time}{0}
-\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}}
-
-\newcommand{\typ}[1]{\lstinline{#1}}
-
-\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} }
-
-% Title page
-\title{Your Title Here}
-
-\author[FOSSEE] {FOSSEE}
-
-\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
+\title{Getting started -- Tuples}
+\author{FOSSEE}
\date{}
-% DOCUMENT STARTS
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}
+\maketitle
+
+
+
+
+
+
+
+
+
\begin{frame}
- \maketitle
+\frametitle{Outline}
+\label{sec-1}
+
+\begin{itemize}
+\item what are tuples
+\item comparison with lists
+\item why are they needed
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+ \texttt{a = 5} and \texttt{b = 7}. swap the values of \texttt{a} and \texttt{b}
+\end{frame}
\begin{frame}[fragile]
- \frametitle{Outline}
- \begin{itemize}
- \item
- \end{itemize}
-\end{frame}
+\frametitle{Solution 1}
+\label{sec-3}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% All other slides here. %%
-%% The same slides will be used in a classroom setting. %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\lstset{language=Python}
+\begin{lstlisting}
+temp = a
+a = b
+b = temp
+
+a
+b
+\end{lstlisting}
+\end{frame}
+\begin{frame}
+\frametitle{Summary}
+\label{sec-4}
-\begin{frame}[fragile]
- \frametitle{Summary}
- \begin{itemize}
- \item
- \end{itemize}
+ You should now --
+\begin{itemize}
+\item Be able to define tuples
+\item Know the similarities with lists, like -- indexing and iterability
+\item Know about the immutability of tuples
+\item Be able to swap variables in the Pythonic way
+\item Know about packing and unpacking of tuples
+\end{itemize}
\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-5}
-\begin{frame}
- \frametitle{Thank you!}
\begin{block}{}
\begin{center}
This spoken tutorial has been produced by the