177 \end{frame} |
177 \end{frame} |
178 |
178 |
179 \begin{frame}[fragile] |
179 \begin{frame}[fragile] |
180 \frametitle{Additional Plotting Attributes} |
180 \frametitle{Additional Plotting Attributes} |
181 \begin{itemize} |
181 \begin{itemize} |
182 \item \kwrd{'o'} - Filled circles |
182 \item \typ{'o'} - Filled circles |
183 \item \kwrd{'.'} - Small Dots |
183 \item \typ{'.'} - Small Dots |
184 \item \kwrd{'-'} - Lines |
184 \item \typ{'-'} - Lines |
185 \item \kwrd{'- -'} - Dashed lines |
185 \item \typ{'--'} - Dashed lines |
186 \end{itemize} |
186 \end{itemize} |
187 \end{frame} |
187 \end{frame} |
188 |
188 |
189 \section{Lists} |
189 \section{Lists} |
190 \begin{frame}[fragile] |
190 \begin{frame}[fragile] |
191 \frametitle{Lists: Introduction} |
191 \frametitle{Lists: Introduction} |
192 \begin{lstlisting} |
192 \begin{lstlisting} |
193 In []: x = [0, 1, 2, 3] |
193 In []: x = [4, 2, 1, 3] |
194 |
194 |
195 In []: y = [7, 11, 15, 19] |
195 In []: y = [7, 11, 15, 19] |
196 |
196 |
197 \end{lstlisting} |
197 \end{lstlisting} |
198 What are \typ{x} and \typ{y}?\\ |
198 What are \typ{x} and \typ{y}?\\ |
206 \begin{lstlisting} |
206 \begin{lstlisting} |
207 In []: mtlist = [] |
207 In []: mtlist = [] |
208 \end{lstlisting} |
208 \end{lstlisting} |
209 \emphbar{Empty List} |
209 \emphbar{Empty List} |
210 \begin{lstlisting} |
210 \begin{lstlisting} |
211 In []: a = [ 1, 2, 3, 4, 5] |
211 In []: a = [ 5, 2, 3, 1, 4] |
212 |
212 |
213 In []: a[0]+a[1]+a[-1] |
213 In []: a[0]+a[1]+a[-1] |
214 Out[]: 8 |
214 Out[]: 11 |
215 \end{lstlisting} |
215 \end{lstlisting} |
216 \end{frame} |
216 \end{frame} |
217 |
217 |
218 \begin{frame}[fragile] |
218 \begin{frame}[fragile] |
219 \frametitle{List: Slicing} |
219 \frametitle{List: Slicing} |
220 \begin{block}{Remember\ldots} |
220 \begin{block}{Remember\ldots} |
221 \kwrd{In []: a = [ 1, 2, 3, 4, 5]} |
221 \kwrd{In []: a = [ 5, 2, 3, 1, 4]} |
222 \end{block} |
222 \end{block} |
223 \begin{lstlisting} |
223 \begin{lstlisting} |
224 In []: a[1:3] |
224 In []: a[1:3] |
225 Out[]: [2, 3] |
225 Out[]: [2, 3] |
226 \end{lstlisting} |
226 \end{lstlisting} |
227 \emphbar{A slice} |
227 \emphbar{A slice} |
228 \begin{lstlisting} |
228 \begin{lstlisting} |
229 In []: a[1:-1] |
229 In []: a[1:-1] |
230 Out[]: [2, 3, 4] |
230 Out[]: [2, 3, 1] |
231 \end{lstlisting} |
231 \end{lstlisting} |
232 \alert{\typ{list[initial:final]}} |
232 \alert{\typ{list[initial:final]}} |
233 \end{frame} |
233 \end{frame} |
234 |
234 |
235 %% more on list slicing |
235 %% more on list slicing |
236 \begin{frame}[fragile] |
236 \begin{frame}[fragile] |
237 \frametitle{List operations} |
237 \frametitle{List operations} |
238 \begin{lstlisting} |
238 \begin{lstlisting} |
239 In []: b = [ 6, 7, 8, 9] |
239 In []: b = [ 8, 6, 9, 9] |
240 In []: c = a + b |
240 In []: c = a + b |
241 |
241 |
242 In []: c |
242 In []: c |
243 Out[]: [1, 2, 3, 4, 5, 6, 7, 8, 9] |
243 Out[]: [5, 2, 3, 1, 4, 8, 6, 9, 9] |
244 |
244 |
245 In []: a.append(6) |
245 In []: a.append(6) |
246 In []: a |
246 In []: a |
247 Out[]: [ 1, 2, 3, 4, 5, 6] |
247 Out[]: [5, 2, 3, 1, 4, 6] |
248 \end{lstlisting} |
248 \end{lstlisting} |
249 %\inctime{10} |
249 %\inctime{10} |
250 \end{frame} |
250 \end{frame} |
251 |
251 |
252 \section{Simple Pendulum} |
252 \section{Simple Pendulum} |
301 |
301 |
302 In []: for time in t: |
302 In []: for time in t: |
303 ....: tsq.append(time*time) |
303 ....: tsq.append(time*time) |
304 ....: |
304 ....: |
305 ....: |
305 ....: |
306 |
306 \end{lstlisting} |
|
307 Hit the ``ENTER'' key twice to come to the previous indentation level |
|
308 \begin{lstlisting} |
|
309 In []: print tsq |
|
310 \end{lstlisting} |
|
311 \kwrd{tsq} is the list of squares of \typ{t} values. |
|
312 \end{frame} |
|
313 |
|
314 \begin{frame}[fragile] |
|
315 \frametitle{Plotting $L$ vs $T^2$ \ldots} |
|
316 \begin{lstlisting} |
307 In []: plot(l, tsq) |
317 In []: plot(l, tsq) |
308 Out[]: [<matplotlib.lines.Line2D object at 0xa5b05ac>] |
318 Out[]: [<matplotlib.lines.Line2D object at 0xa5b05ac>] |
309 \end{lstlisting} |
319 \end{lstlisting} |
310 This gives \kwrd{tsq} which is the list of squares of \typ{t} values. |
320 This gives the required plot. |
311 \end{frame} |
|
312 |
|
313 \begin{frame}[fragile] |
|
314 \frametitle{How to come out of the \texttt{for} loop?} |
|
315 Hit the ``ENTER'' key twice to come to the previous indentation level |
|
316 \begin{lstlisting} |
|
317 In []: for time in t: |
|
318 ....: tsq.append(time*time) |
|
319 ....: |
|
320 ....: |
|
321 |
|
322 In []: print tsq |
|
323 \end{lstlisting} |
|
324 \end{frame} |
|
325 |
|
326 \begin{frame}[fragile] |
|
327 \begin{figure} |
321 \begin{figure} |
328 \includegraphics[width=3.5in]{data/L-TSq-limited.png} |
322 \includegraphics[width=2.2in]{data/L-TSq-limited.png} |
329 \end{figure} |
323 \end{figure} |
330 \end{frame} |
324 \end{frame} |
331 |
325 |
332 \begin{frame}[fragile] |
326 \begin{frame}[fragile] |
333 \frametitle{What about larger data sets?} |
327 \frametitle{What about larger data sets?} |