author | Santosh G. Vattam <vattam.santosh@gmail.com> |
Fri, 23 Oct 2009 17:12:25 +0530 | |
changeset 159 | 01f57cda252f |
parent 158 | 978108b0c02c |
parent 156 | 6a1388c456f4 |
child 160 | 058fad7c7d1d |
permissions | -rw-r--r-- |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
2 |
%Tutorial slides on Python. |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
3 |
% |
153
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
4 |
% Author: FOSSEE |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
5 |
% Copyright (c) 2009, FOSSEE, IIT Bombay |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
6 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
7 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
8 |
\documentclass[14pt,compress]{beamer} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
9 |
%\documentclass[draft]{beamer} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
10 |
%\documentclass[compress,handout]{beamer} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
11 |
%\usepackage{pgfpages} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
12 |
%\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm] |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
13 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
14 |
% Modified from: generic-ornate-15min-45min.de.tex |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
15 |
\mode<presentation> |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
16 |
{ |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
17 |
\usetheme{Warsaw} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
18 |
\useoutertheme{split} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
19 |
\setbeamercovered{transparent} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
20 |
} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
21 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
22 |
\usepackage[english]{babel} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
23 |
\usepackage[latin1]{inputenc} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
24 |
%\usepackage{times} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
25 |
\usepackage[T1]{fontenc} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
26 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
27 |
% Taken from Fernando's slides. |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
28 |
\usepackage{ae,aecompl} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
29 |
\usepackage{mathpazo,courier,euler} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
30 |
\usepackage[scaled=.95]{helvet} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
31 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
32 |
\definecolor{darkgreen}{rgb}{0,0.5,0} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
33 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
34 |
\usepackage{listings} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
35 |
\lstset{language=Python, |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
36 |
basicstyle=\ttfamily\bfseries, |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
37 |
commentstyle=\color{red}\itshape, |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
38 |
stringstyle=\color{darkgreen}, |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
39 |
showstringspaces=false, |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
40 |
keywordstyle=\color{blue}\bfseries} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
41 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
42 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
43 |
% Macros |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
44 |
\setbeamercolor{emphbar}{bg=blue!20, fg=black} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
45 |
\newcommand{\emphbar}[1] |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
46 |
{\begin{beamercolorbox}[rounded=true]{emphbar} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
47 |
{#1} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
48 |
\end{beamercolorbox} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
49 |
} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
50 |
\newcounter{time} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
51 |
\setcounter{time}{0} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
52 |
\newcommand{\inctime}[1]{\addtocounter{time}{#1}{\tiny \thetime\ m}} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
53 |
|
130
8905a5badd7e
Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
54 |
\newcommand{\typ}[1]{\lstinline{#1}} |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
55 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
56 |
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}} } |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
57 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
58 |
%%% This is from Fernando's setup. |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
59 |
% \usepackage{color} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
60 |
% \definecolor{orange}{cmyk}{0,0.4,0.8,0.2} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
61 |
% % Use and configure listings package for nicely formatted code |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
62 |
% \usepackage{listings} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
63 |
% \lstset{ |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
64 |
% language=Python, |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
65 |
% basicstyle=\small\ttfamily, |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
66 |
% commentstyle=\ttfamily\color{blue}, |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
67 |
% stringstyle=\ttfamily\color{orange}, |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
68 |
% showstringspaces=false, |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
69 |
% breaklines=true, |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
70 |
% postbreak = \space\dots |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
71 |
% } |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
72 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
73 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
74 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
75 |
% Title page |
144
0407ddc37038
Updated session 2, day 1 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
134
diff
changeset
|
76 |
\title[Plotting using Python]{Plotting experimental data\\} |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
77 |
|
153
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
78 |
\author[FOSSEE] {FOSSEE} |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
79 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
80 |
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
81 |
\date[] {31, October 2009\\Day 1, Session 2} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
82 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
83 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
84 |
%\pgfdeclareimage[height=0.75cm]{iitmlogo}{iitmlogo} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
85 |
%\logo{\pgfuseimage{iitmlogo}} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
86 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
87 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
88 |
%% Delete this, if you do not want the table of contents to pop up at |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
89 |
%% the beginning of each subsection: |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
90 |
\AtBeginSubsection[] |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
91 |
{ |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
92 |
\begin{frame}<beamer> |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
93 |
\frametitle{Outline} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
94 |
\tableofcontents[currentsection,currentsubsection] |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
95 |
\end{frame} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
96 |
} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
97 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
98 |
\AtBeginSection[] |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
99 |
{ |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
100 |
\begin{frame}<beamer> |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
101 |
\frametitle{Outline} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
102 |
\tableofcontents[currentsection,currentsubsection] |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
103 |
\end{frame} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
104 |
} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
105 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
106 |
% If you wish to uncover everything in a step-wise fashion, uncomment |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
107 |
% the following command: |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
108 |
%\beamerdefaultoverlayspecification{<+->} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
109 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
110 |
%\includeonlyframes{current,current1,current2,current3,current4,current5,current6} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
111 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
112 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
113 |
% DOCUMENT STARTS |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
114 |
\begin{document} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
115 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
116 |
\begin{frame} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
117 |
\titlepage |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
118 |
\end{frame} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
119 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
120 |
\begin{frame} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
121 |
\frametitle{Outline} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
122 |
\tableofcontents |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
123 |
% You might wish to add the option [pausesections] |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
124 |
\end{frame} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
125 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
126 |
\section{Creating and running scripts} |
151
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
127 |
\begin{frame}[fragile] |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
128 |
\frametitle{Python Scripts} |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
129 |
\begin{itemize} |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
130 |
\item Let us now put all the commands used in the review problem into a file. |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
131 |
\item The following commands of IPython help us do this. |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
132 |
\end{itemize} |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
133 |
\begin{lstlisting} |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
134 |
In []: %hist |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
135 |
In []: %hist -n |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
136 |
\end{lstlisting} |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
137 |
\end{frame} |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
138 |
|
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
139 |
\begin{frame} |
151
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
140 |
\frametitle{Python Scripts\ldots} |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
141 |
\begin{itemize} |
151
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
142 |
\item Open a new file in an \alert{editor} |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
143 |
\item Copy and paste required lines from the output of \typ{\%hist -n} |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
144 |
\item Save the file as \typ{first_plot.py} |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
145 |
\end{itemize} |
151
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
146 |
\begin{itemize} |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
147 |
\item run the file in IPython using \typ{\%run first_plot.py}\\ |
55c22520ff5e
Added IPython history to Day1 Session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
146
diff
changeset
|
148 |
\end{itemize} |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
149 |
\end{frame} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
150 |
|
153
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
151 |
\section{Plotting Points} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
152 |
\begin{frame}[fragile] |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
153 |
\frametitle{Simple Pendulum - L and T} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
154 |
\begin{itemize} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
155 |
\item Given data of Length and Time-period of a Simple pendulum |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
156 |
\item We wish to plot L vs. \alert{$T^2$} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
157 |
\end{itemize} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
158 |
\begin{lstlisting} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
159 |
In []: L = [0.1, 0.2, 0.3, |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
160 |
0.4, 0.5, 0.6, |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
161 |
0.7, 0.8, 0.9] |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
162 |
In []: T = [0.6529, 0.8485, 1.0590, |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
163 |
1.2390, 1.4124, 1.5061, |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
164 |
1.6441, 1.7949, 1.8758] |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
165 |
\end{lstlisting} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
166 |
\end{frame} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
167 |
|
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
168 |
\begin{frame}[fragile] |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
169 |
\frametitle{Simple Pendulum \ldots} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
170 |
\begin{itemize} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
171 |
\item Let us begin with $L$ vs. \alert{$T$} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
172 |
\end{itemize} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
173 |
\begin{lstlisting} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
174 |
In []: plot(L, T) |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
175 |
\end{lstlisting} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
176 |
\begin{itemize} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
177 |
\item But we wish to plot points! |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
178 |
\end{itemize} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
179 |
\end{frame} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
180 |
|
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
181 |
\begin{frame}[fragile] |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
182 |
\frametitle{Plotting points} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
183 |
\begin{lstlisting} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
184 |
In []: clf() |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
185 |
|
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
186 |
In []: plot(L, T, 'o') |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
187 |
Out[]: [<matplotlib.lines.Line2D object at 0xac17e0c>] |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
188 |
|
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
189 |
In []: clf() |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
190 |
In []: plot(L, T, '.') |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
191 |
Out[]: [<matplotlib.lines.Line2D object at 0xac17e0c>] |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
192 |
\end{lstlisting} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
193 |
\end{frame} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
194 |
|
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
195 |
\begin{frame}[fragile] |
156
6a1388c456f4
Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
153
diff
changeset
|
196 |
\frametitle{Additional Plotting Attributes} |
153
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
197 |
\begin{itemize} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
198 |
\item \kwrd{'o'} - Dots |
156
6a1388c456f4
Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
153
diff
changeset
|
199 |
\item \kwrd{'.'} - Smaller Dots |
153
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
200 |
\item \kwrd{'-'} - Lines |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
201 |
\item \kwrd{'- -'} - Dashed lines |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
202 |
\end{itemize} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
203 |
\end{frame} |
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
204 |
|
156
6a1388c456f4
Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
153
diff
changeset
|
205 |
\begin{frame}[fragile] |
6a1388c456f4
Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
153
diff
changeset
|
206 |
\frametitle{Plotting $L$ vs. $T^2$} |
6a1388c456f4
Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
153
diff
changeset
|
207 |
\begin{itemize} |
6a1388c456f4
Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
153
diff
changeset
|
208 |
\item We must square each of the values in T |
6a1388c456f4
Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
153
diff
changeset
|
209 |
\item How to do it? |
6a1388c456f4
Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
153
diff
changeset
|
210 |
\item T is a \kwrd{list} and we use a \kwrd{for} loop to iterate over it |
6a1388c456f4
Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
153
diff
changeset
|
211 |
\end{itemize} |
6a1388c456f4
Added plotting of points, additional attributes of plots.
Puneeth Chaganti <punchagan@fossee.in>
parents:
153
diff
changeset
|
212 |
\end{frame} |
153
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
213 |
|
159
01f57cda252f
Manual merge of conflicting branches.
Santosh G. Vattam <vattam.santosh@gmail.com>
diff
changeset
|
214 |
\begin{frame}[fragile] |
01f57cda252f
Manual merge of conflicting branches.
Santosh G. Vattam <vattam.santosh@gmail.com>
diff
changeset
|
215 |
\frametitle{Plotting $L$ vs $T^2$} |
158
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
216 |
\begin{lstlisting} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
217 |
In []: TSq = [] |
153
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
218 |
|
158
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
219 |
In []: for t in T: |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
220 |
....: TSq.append(t*t) |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
221 |
|
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
222 |
In []: plot(L, TSq, '.') |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
223 |
Out[]: [<matplotlib.lines.Line2D object at 0xa5b05ac>] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
224 |
\end{lstlisting} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
225 |
\end{frame} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
226 |
|
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
227 |
\begin{frame}{So what did we learn here??} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
228 |
\begin{itemize} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
229 |
\item lists |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
230 |
\item \alert{\kwrd{for}} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
231 |
\end{itemize} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
232 |
\end{frame} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
233 |
|
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
234 |
\section{Lists} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
235 |
\begin{frame}[fragile] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
236 |
\frametitle{How to create and use lists?} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
237 |
\begin{lstlisting} |
159
01f57cda252f
Manual merge of conflicting branches.
Santosh G. Vattam <vattam.santosh@gmail.com>
diff
changeset
|
238 |
In []: mtlist = [] #Empty List |
01f57cda252f
Manual merge of conflicting branches.
Santosh G. Vattam <vattam.santosh@gmail.com>
diff
changeset
|
239 |
|
158
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
240 |
In []: lst = [1,2,3,4] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
241 |
|
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
242 |
In []: lst[0]+lst[1]+lst[-1] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
243 |
Out[]: 7 |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
244 |
\end{lstlisting} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
245 |
\end{frame} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
246 |
|
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
247 |
\begin{frame}[fragile] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
248 |
\frametitle{List: Slicing} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
249 |
\typ{list[initial:final:step]} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
250 |
\begin{lstlisting} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
251 |
In []: lst[1:3] # A slice. |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
252 |
Out[]: [2, 3] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
253 |
|
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
254 |
In []: lst[1:-1] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
255 |
Out[]: [2, 3] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
256 |
\end{lstlisting} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
257 |
\end{frame} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
258 |
|
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
259 |
\begin{frame}[fragile] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
260 |
\frametitle{List methods} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
261 |
\begin{lstlisting} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
262 |
In []: lst.append([6,7]) |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
263 |
In []: lst |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
264 |
Out[]: [1, 2, 3, 4, 5, [6, 7]] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
265 |
\end{lstlisting} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
266 |
%\inctime{10} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
267 |
\end{frame} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
268 |
|
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
269 |
\begin{frame}[fragile] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
270 |
\frametitle{\typ{for}} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
271 |
Used to iterate over lists\\ Let us look at another example. |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
272 |
\begin{lstlisting} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
273 |
In []: lst = [1,2,3,4,5,6] |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
274 |
In []: for num in lst: |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
275 |
....: print num, num*num |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
276 |
....: |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
277 |
1 1 |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
278 |
2 4 |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
279 |
3 9 |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
280 |
4 16 |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
281 |
5 25 |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
282 |
6 36 |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
283 |
\end{lstlisting} |
978108b0c02c
Added lists and for slides to session 2, day 1.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
153
diff
changeset
|
284 |
\end{frame} |
153
dc0da25b788b
Minor edits to day2 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
151
diff
changeset
|
285 |
|
134
31b3e5051b06
Updated Session 1, day 2 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
132
diff
changeset
|
286 |
\section{File Handling} |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
287 |
\begin{frame}[fragile] |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
288 |
\frametitle{File and \kwrd{for}} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
289 |
\begin{lstlisting} |
130
8905a5badd7e
Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
290 |
In []: f = open('dummyfile') |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
291 |
|
130
8905a5badd7e
Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
292 |
In []: for line in f: |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
293 |
...: print line |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
294 |
...: |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
295 |
\end{lstlisting} |
132
c10d8cb8d690
Updated session 2 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
130
diff
changeset
|
296 |
\inctime{5} |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
297 |
\end{frame} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
298 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
299 |
\section{Strings} |
132
c10d8cb8d690
Updated session 2 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
130
diff
changeset
|
300 |
\begin{frame}{Strings} |
c10d8cb8d690
Updated session 2 slides.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
130
diff
changeset
|
301 |
Anything within ``quotes'' is a string! |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
302 |
\end{frame} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
303 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
304 |
\begin{frame}[fragile]\frametitle{Strings and \typ{split()}} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
305 |
\begin{lstlisting} |
130
8905a5badd7e
Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
306 |
In []: a = 'hello world' |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
307 |
|
130
8905a5badd7e
Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
308 |
In []: a.split() |
8905a5badd7e
Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
309 |
Out[]: ['hello', 'world'] |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
310 |
\end{lstlisting} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
311 |
Now try this: |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
312 |
\begin{lstlisting} |
130
8905a5badd7e
Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
313 |
In []: b = 'KD, MCS, PC, SC, SV' |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
314 |
|
130
8905a5badd7e
Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
315 |
In []: b.split(',') |
8905a5badd7e
Minor edits to day1 session2.
Puneeth Chaganti <punchagan@fossee.in>
parents:
118
diff
changeset
|
316 |
Out[]: ['KD', 'MCS', 'PC', 'SC', 'SV'] |
109
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
317 |
\end{lstlisting} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
318 |
\inctime{5} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
319 |
\end{frame} |
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
320 |
|
16e04782baac
Added session2.tex.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
diff
changeset
|
321 |
\end{document} |