33 \setcounter{qno}{0} |
33 \setcounter{qno}{0} |
34 \newcommand{\incqno}{\addtocounter{qno}{1}{Question \theqno}} |
34 \newcommand{\incqno}{\addtocounter{qno}{1}{Question \theqno}} |
35 |
35 |
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
37 % Title page |
37 % Title page |
38 \title[Basic Python]{Python: Quiz} |
38 \title[Basic Python]{Python for science and engineering: Day 1, Quiz 1} |
39 |
39 |
40 \author[FOSSEE Team] {FOSSEE} |
40 \author[FOSSEE Team] {FOSSEE} |
41 |
41 |
42 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
42 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay} |
43 \date[] {31, October 2009\\Day 1, Quiz 1} |
43 \date[] {\today \\Day 1, Quiz 1} |
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
45 |
45 |
46 |
46 |
47 \begin{document} |
47 \begin{document} |
48 |
48 |
52 |
52 |
53 \begin{frame} |
53 \begin{frame} |
54 \frametitle{Write your details...} |
54 \frametitle{Write your details...} |
55 On the top right hand corner please write down the following: |
55 On the top right hand corner please write down the following: |
56 \begin{itemize} |
56 \begin{itemize} |
57 \item Name: |
57 \item Name: |
58 \item Affliation: |
58 \item University/College/Company: |
59 \item Occupation: |
59 \item Student/Teacher/Professional: |
60 \end{itemize} |
60 \end{itemize} |
|
61 \end{frame} |
|
62 |
|
63 \begin{frame}[fragile] |
|
64 \frametitle{\incqno } |
|
65 Describe the plot produced by the following: |
|
66 |
|
67 \begin{lstlisting} |
|
68 In []: x = linspace(0, 2*pi) |
|
69 In []: plot(x, cos(x), 'go') |
|
70 \end{lstlisting} |
|
71 \end{frame} |
|
72 |
|
73 \begin{frame} |
|
74 \frametitle{\incqno } |
|
75 How will you plot the previous graph with line width set to 3? How will |
|
76 you set the $x$ and $y$ labels of the plot? |
|
77 \end{frame} |
|
78 |
|
79 \begin{frame} |
|
80 \frametitle{\incqno } |
|
81 How will you set the x and y axis limits so that the region of interest |
|
82 is in the rectangle $(0, -1.5)$ (left bottom coordinate) and $(2\pi, |
|
83 1.5)$ (right top coordinate)? |
61 \end{frame} |
84 \end{frame} |
62 |
85 |
63 \begin{frame} |
86 \begin{frame} |
64 \frametitle{\incqno } |
87 \frametitle{\incqno } |
65 A sample line from a Comma Separated Values (CSV) file:\\ |
88 A sample line from a Comma Separated Values (CSV) file:\\ |
66 \vspace*{0.2in} |
89 \vspace*{0.2in} |
67 \emph{Rossum, Guido, 42, 56, 34, 54}\\ |
90 \emph{Rossum, Guido, 42, 56, 34, 54}\\ |
68 \vspace*{0.2in} |
91 \vspace*{0.2in} |
69 What method would you use to separate the line into fields? |
92 What code would you use to separate the line into fields? |
70 \end{frame} |
93 \end{frame} |
71 |
94 |
72 \begin{frame}[fragile] |
95 \begin{frame}[fragile] |
73 \frametitle{\incqno } |
96 \frametitle{\incqno } |
74 \begin{lstlisting} |
97 \begin{lstlisting} |
75 In [1]: a = [1, 2, 5, 9] |
98 In []: a = [1, 2, 5, 9] |
76 In [2]: a[:-1] |
99 In []: a[0:-1] |
77 \end{lstlisting} |
100 \end{lstlisting} |
78 What is the output? |
101 What is the output? |
79 \end{frame} |
102 \end{frame} |
80 |
103 |
81 \begin{frame} |
104 \begin{frame} |
82 \frametitle{\incqno } |
105 \frametitle{\incqno } |
83 How do you combine the two lists \emph{a} and \emph{b}? |
106 How do you combine two lists \emph{a} and \emph{b} to produce one list? |
|
107 \end{frame} |
|
108 |
|
109 \begin{frame}[fragile] |
|
110 \frametitle{\incqno } |
|
111 \begin{lstlisting} |
|
112 In []: a = [1, 2, 5, 9] |
|
113 \end{lstlisting} |
|
114 How do you add the value 10 to the end of this list? |
|
115 \end{frame} |
|
116 |
|
117 \begin{frame}[fragile] |
|
118 \frametitle{\incqno } |
|
119 \begin{lstlisting} |
|
120 In []: a = [1, 2, 5, 9] |
|
121 \end{lstlisting} |
|
122 How do you find the length of this list? |
84 \end{frame} |
123 \end{frame} |
85 |
124 |
86 \begin{frame}[fragile] |
125 \begin{frame}[fragile] |
87 \frametitle{\incqno } |
126 \frametitle{\incqno } |
88 \begin{lstlisting} |
127 \begin{lstlisting} |
93 In [2]: print d['c'] |
132 In [2]: print d['c'] |
94 \end{lstlisting} |
133 \end{lstlisting} |
95 What is the output? |
134 What is the output? |
96 \end{frame} |
135 \end{frame} |
97 |
136 |
98 \begin{frame}[fragile] |
137 %% \begin{frame}[fragile] |
99 \frametitle{\incqno } |
138 %% \frametitle{\incqno } |
100 \begin{lstlisting} |
139 %% \begin{lstlisting} |
101 for x in "abcd": |
140 %% for x in "abcd": |
102 print x |
141 %% print x |
103 |
142 |
104 a |
143 %% a |
105 b |
144 %% b |
106 c |
145 %% c |
107 d |
146 %% d |
108 \end{lstlisting} |
147 %% \end{lstlisting} |
109 How do you get the following output? |
148 %% How do you get the following output? |
110 \begin{lstlisting} |
149 %% \begin{lstlisting} |
111 0 a |
150 %% 0 a |
112 1 b |
151 %% 1 b |
113 2 c |
152 %% 2 c |
114 3 d |
153 %% 3 d |
115 \end{lstlisting} |
154 %% \end{lstlisting} |
116 \end{frame} |
155 %% \end{frame} |
117 |
156 |
118 \begin{frame}[fragile] |
157 \begin{frame}[fragile] |
119 \frametitle{\incqno } |
158 \frametitle{\incqno } |
120 What would be the result? |
|
121 \begin{lstlisting} |
159 \begin{lstlisting} |
122 In [1]: x |
160 In []: sc = {'A': 10, 'B': 20, |
123 array([[0, 1, 2], |
161 'C': 70} |
124 [3, 4, 5], |
|
125 [6, 7, 8]]) |
|
126 In [2]: x[::-1,:] |
|
127 \end{lstlisting} |
162 \end{lstlisting} |
128 \end{frame} |
163 Given the above dictionary, what command will you give to plot a |
129 |
164 pie-chart? |
130 \begin{frame} |
165 \end{frame} |
131 \frametitle{\incqno } |
166 |
132 How to read and print each line of a file. |
167 |
133 \end{frame} |
168 \begin{frame}[fragile] |
134 |
169 \frametitle{\incqno } |
135 \begin{frame} |
|
136 \frametitle{\incqno } |
|
137 How to get list of third column of a data file. |
|
138 \end{frame} |
|
139 |
|
140 \begin{frame}[fragile] |
|
141 \frametitle{\incqno } |
|
142 What is the output of: |
|
143 \begin{lstlisting} |
170 \begin{lstlisting} |
144 In []: x=linspace(0 , 2 * pi) |
171 In []: marks = [10, 20, 30, 50, 55, |
145 In []: plot(x, cos(x),'go') |
172 75, 83] |
146 \end{lstlisting} |
173 \end{lstlisting} |
147 \end{frame} |
174 |
148 |
175 Given the above marks, how will you calculate the \alert{mean} and |
149 \begin{frame} |
176 \alert{standard deviation}? |
150 \frametitle{\incqno } |
177 \end{frame} |
151 Draw a plot with line width 3. |
178 |
152 \end{frame} |
179 %\begin{frame}[fragile] |
153 |
180 %\frametitle{\incqno } |
154 \begin{frame} |
181 %\begin{lstlisting} |
155 \frametitle{\incqno } |
182 %In []: marks = [10, 20, 30, 50, 55, |
156 Setting x and y axis limits. |
183 % 75, 83] |
157 \end{frame} |
184 %\end{lstlisting} |
|
185 %How will you convert the list \texttt{marks} to an \alert{array}? |
|
186 %\end{frame} |
|
187 |
|
188 %% \begin{frame}[fragile] |
|
189 %% \frametitle{\incqno } |
|
190 %% \begin{lstlisting} |
|
191 %% In []: a = array([[1, 2], |
|
192 %% [3, 4]]) |
|
193 %% In []: a[1,0] = 0 |
|
194 %% \end{lstlisting} |
|
195 %% What is the resulting matrix? |
|
196 %% \end{frame} |
|
197 |
|
198 %% \begin{frame}[fragile] |
|
199 %% \frametitle{\incqno } |
|
200 %% \begin{lstlisting} |
|
201 %% In []: a = array([[1, 2], |
|
202 %% [3, 4]]) |
|
203 %% \end{lstlisting} |
|
204 %% How do you get the transpose of this array? |
|
205 %% \end{frame} |
|
206 |
|
207 %% \begin{frame}[fragile] |
|
208 %% \frametitle{\incqno } |
|
209 %% \begin{lstlisting} |
|
210 %% In []: a = array([[1, 2], |
|
211 %% [3, 4]]) |
|
212 %% In []: b = array([[1, 1], |
|
213 %% [2, 2]]) |
|
214 %% In []: a*b |
|
215 %% \end{lstlisting} |
|
216 %% What does this produce? |
|
217 %% \end{frame} |
|
218 |
|
219 %% \begin{frame} |
|
220 %% \frametitle{\incqno } |
|
221 %% What command do you use to find the inverse of a matrix and its |
|
222 %% eigenvalues? |
|
223 %% \end{frame} |
|
224 |
|
225 %% \begin{frame} |
|
226 %% \frametitle{\incqno } |
|
227 %% Given a 4x4 matrix \texttt{A} and a 4-vector \texttt{b}, what command do |
|
228 %% you use to solve for the equation \\ |
|
229 %% \texttt{Ax = b}? |
|
230 %% \end{frame} |
|
231 |
|
232 \begin{frame} |
|
233 \frametitle{\incqno } |
|
234 Write the code to read a file \texttt{data.txt} and print each line of it? |
|
235 \end{frame} |
|
236 |
158 |
237 |
159 \end{document} |
238 \end{document} |
160 |
239 |