summaryrefslogtreecommitdiff
path: root/day1/session2.tex
diff options
context:
space:
mode:
Diffstat (limited to 'day1/session2.tex')
-rw-r--r--day1/session2.tex89
1 files changed, 51 insertions, 38 deletions
diff --git a/day1/session2.tex b/day1/session2.tex
index 13efd55..2e493e4 100644
--- a/day1/session2.tex
+++ b/day1/session2.tex
@@ -78,7 +78,7 @@
\author[FOSSEE] {FOSSEE}
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-\date[] {11 January, 2010\\Day 1, Session 2}
+\date[] {12 February, 2010\\Day 1, Session 2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo}
@@ -179,10 +179,10 @@ Out[]: <matplotlib.text.Text object at 0x98746ec>
\begin{frame}[fragile]
\frametitle{Additional Plotting Attributes}
\begin{itemize}
- \item \typ{'o'} - Filled circles
- \item \typ{'.'} - Small Dots
- \item \typ{'-'} - Lines
- \item \typ{'--'} - Dashed lines
+ \item \kwrd{'o'} - Filled circles
+ \item \kwrd{'.'} - Small Dots
+ \item \kwrd{'-'} - Lines
+ \item \kwrd{'- -'} - Dashed lines
\end{itemize}
\end{frame}
@@ -190,7 +190,7 @@ Out[]: <matplotlib.text.Text object at 0x98746ec>
\begin{frame}[fragile]
\frametitle{Lists: Introduction}
\begin{lstlisting}
- In []: x = [4, 2, 1, 3]
+ In []: x = [0, 1, 2, 3]
In []: y = [7, 11, 15, 19]
@@ -208,43 +208,45 @@ In []: mtlist = []
\end{lstlisting}
\emphbar{Empty List}
\begin{lstlisting}
-In []: a = [ 5, 2, 3, 1, 4]
+In []: p = [ 2, 3, 5, 7]
-In []: a[0]+a[1]+a[-1]
-Out[]: 11
+In []: p[0]+p[1]+p[-1]
+Out[]: 12
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{List: Slicing}
\begin{block}{Remember\ldots}
- \kwrd{In []: a = [ 5, 2, 3, 1, 4]}
+ \kwrd{In []: p = [ 2, 3, 5, 7]}
\end{block}
\begin{lstlisting}
-In []: a[1:3]
-Out[]: [2, 3]
+In []: p[1:3]
+Out[]: [3, 5]
\end{lstlisting}
\emphbar{A slice}
\begin{lstlisting}
-In []: a[1:-1]
-Out[]: [2, 3, 1]
+In []: p[0:-1]
+Out[]: [2, 3, 5]
+In []: p[::2]
+Out[]: [2, 5]
\end{lstlisting}
-\alert{\typ{list[initial:final]}}
+\alert{\typ{list[initial:final:step]}}
\end{frame}
%% more on list slicing
\begin{frame}[fragile]
\frametitle{List operations}
\begin{lstlisting}
-In []: b = [ 8, 6, 9, 9]
-In []: c = a + b
+In []: b = [ 11, 13, 17]
+In []: c = p + b
In []: c
-Out[]: [5, 2, 3, 1, 4, 8, 6, 9, 9]
+Out[]: [2, 3, 5, 7, 11, 13, 17]
-In []: a.append(6)
-In []: a
-Out[]: [5, 2, 3, 1, 4, 6]
+In []: p.append(11)
+In []: p
+Out[]: [ 2, 3, 5, 7, 11]
\end{lstlisting}
%\inctime{10}
\end{frame}
@@ -299,27 +301,40 @@ In []: t = [0.69, 0.90, 1.19,
\begin{lstlisting}
In []: tsq = []
+In []: len(l)
+Out[]: 9
+
+In []: len(t)
+Out[]: 9
+
In []: for time in t:
....: tsq.append(time*time)
....:
....:
-\end{lstlisting}
-Hit the ``ENTER'' key twice to come to the previous indentation level
-\begin{lstlisting}
-In []: print tsq
-\end{lstlisting}
-\kwrd{tsq} is the list of squares of \typ{t} values.
-\end{frame}
-\begin{frame}[fragile]
-\frametitle{Plotting $L$ vs $T^2$ \ldots}
-\begin{lstlisting}
In []: plot(l, tsq)
Out[]: [<matplotlib.lines.Line2D object at 0xa5b05ac>]
\end{lstlisting}
-This gives the required plot.
+This gives \kwrd{tsq} which is the list of squares of \typ{t} values.
+\end{frame}
+
+\begin{frame}[fragile]
+ \frametitle{How to come out of the \texttt{for} loop?}
+ Hitting the ``ENTER'' key twice returns the cursor to the previous indentation level
+ \begin{lstlisting}
+ In []: for time in t:
+ ....: tsq.append(time*time)
+ ....:
+ ....:
+
+ In []: print tsq, len(tsq)
+ In []: plot(l, tsq)
+ \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
\begin{figure}
-\includegraphics[width=2.2in]{data/L-TSq-limited.png}
+\includegraphics[width=3.5in]{data/L-TSq-limited.png}
\end{figure}
\end{frame}
@@ -353,7 +368,7 @@ $ cat pendulum.txt
\begin{frame}[fragile]
\frametitle{Plotting from \typ{pendulum.txt}}
-Type the following in an editor. Save as \typ{pend\_pl.py}
+Open a new script and type the following:
\begin{lstlisting}
l = []
t = []
@@ -365,15 +380,14 @@ tsq = []
for time in t:
tsq.append(time*time)
plot(l, tsq, '.')
-show()
\end{lstlisting}
\end{frame}
\begin{frame}
\frametitle{Save and run}
\begin{itemize}
- \item Save as \typ{pend\_pl.py}
- \item Run using \kwrd{\%run -i pend\_pl.py}
+ \item Save as pendulum\_plot.py.
+ \item Run using \kwrd{\%run -i pendulum\_plot.py}
\end{itemize}
\end{frame}
@@ -452,7 +466,6 @@ tsq = []
for time in t:
tsq.append(time*time)
plot(l, tsq, '.')
-show()
\end{lstlisting}
\end{frame}