summaryrefslogtreecommitdiff
path: root/day1/day1quiz2.tex
blob: b21afccf33343943cf4af1514ae9bccabceb18bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Tutorial slides on Python.
%
% Author: FOSSEE <info at fossee  dot in>
% Copyright (c) 2005-2009, FOSSEE Team
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\documentclass[14pt,compress]{beamer}

\mode<presentation>
{
  \useoutertheme{split}
  \setbeamercovered{transparent}
}

\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}

\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Macros

\newcounter{qno}
\setcounter{qno}{0}
\newcommand{\incqno}{\addtocounter{qno}{1}{Question \theqno}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title page
\title[Basic Python]{Python for science and engineering: Day 2, Quiz 1}

\author[FOSSEE Team] {FOSSEE}

\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
\date[] {\today \\
Day 1, quiz 2}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\begin{document}

\begin{frame}
  \titlepage
\end{frame}

\begin{frame}
  \frametitle{Write your details...}
On the top right hand corner please write down the following:
  \begin{itemize}
    \item Name:
    \item University/College/Company:
    \item Student/Teacher/Professional:
    \item Field of interest/study:
  \end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
In []: a = array([[1, 2],
                  [3, 4]])
In []: a[1,0] = 0
\end{lstlisting}
What is the resulting array?
\end{frame}

\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
  In []: x = array(([1,2,3,4],
                    [2,3,4,5]))
  In []: x[-2][-3] = 4
  In []: print x
\end{lstlisting}
What will be printed?
\end{frame}

\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
  In []: x = array([[1,2,3,4],
                    [3,4,2,5]])
\end{lstlisting}
What is the \lstinline+shape+ of this array?
\end{frame}

\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
  In []: x = array([[1,2,3,4]])
\end{lstlisting}
How to change \lstinline+x+ to \lstinline+array([[1,2,0,4]])+?
\end{frame}

\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
  In []: x = array([[1,2,3,4],
                    [3,4,2,5]])
\end{lstlisting}
How do you get the following slice of \lstinline+x+?
\begin{lstlisting}
array([[2,3],
       [4,2]])
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
  In []: x = array([[9,18,27],
                    [30,60,90],
                    [14,7,1]])
\end{lstlisting}
What is the output of \lstinline+x[::3,::3]+
\end{frame}


\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
In []: a = array([[1, 2],
                  [3, 4]])
\end{lstlisting}
How do you get the transpose of this array?
\end{frame}

\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
In []: a = array([[1, 2],
                  [3, 4]])
In []: b = array([[1, 1],
                  [2, 2]])
In []: a*b
\end{lstlisting}
What does this produce?
\end{frame}

\begin{frame}
\frametitle{\incqno }
What command do you use to find the inverse of a matrix and its
eigenvalues?
\end{frame}

%% \begin{frame}
%% \frametitle{\incqno }
%% The file \lstinline+datafile.txt+ contains 3 columns of data.  What
%% command will you use to read the entire data file into an array?
%% \end{frame}

%% \begin{frame}
%% \frametitle{\incqno }
%% If the contents of the file \lstinline+datafile.txt+ is read into an
%% $N\times3$ array called \lstinline+data+, how would you obtain the third
%% column of this data?
%% \end{frame}

\begin{frame}
\frametitle{\incqno }
Given a 4x4 matrix \texttt{A} and a 4-vector \texttt{b}, what command do
you use to solve for the equation \\
\texttt{Ax = b}?
\end{frame}

%% \begin{frame}
%% \frametitle{\incqno }
%% What command will you use if you wish to integrate a system of ODEs?
%% \end{frame}

\begin{frame}
\frametitle{\incqno }
How do you calculate the roots of the polynomial, $y = 1 + 6x + 8x^2 +
x^3$?
\end{frame}

\begin{frame}
\frametitle{\incqno }
Two arrays \lstinline+a+ and \lstinline+b+ are numerically almost equal, what command
do you use to check if this is true?
\end{frame}

%% \begin{frame}[fragile]
%% \frametitle{\incqno }
%% \begin{lstlisting}
%%   In []: x = arange(0, 1, 0.25)
%%   In []: print x
%% \end{lstlisting}
%% What will be printed?
%% \end{frame}


%% \begin{frame}[fragile]
%% \frametitle{\incqno }
%% \begin{lstlisting}
%% from scipy.integrate import quad
%% def f(x):
%%     res = x*cos(x)
%% quad(f, 0, 1)
%% \end{lstlisting}
%% What changes will you make to the above code to make it work?
%% \end{frame}

%% \begin{frame}
%% \frametitle{\incqno }
%% What two commands will you use to create and evaluate a spline given
%% some data?
%% \end{frame}

%% \begin{frame}[fragile]
%% \frametitle{\incqno }
%% What would be the result?
%% \begin{lstlisting}
%%   In []: x
%%   array([[0, 1, 2],
%%          [3, 4, 5],
%%          [6, 7, 8]])
%%   In []: x[::-1,:]
%% \end{lstlisting}
%% Hint:
%% \begin{lstlisting}
%%   In []: x = arange(9)
%%   In []: x[::-1]
%%   array([8, 7, 6, 5, 4, 3, 2, 1, 0])
%% \end{lstlisting}
%% \end{frame}

%% \begin{frame}[fragile]
%% \frametitle{\incqno }
%% What would be the result?
%% \begin{lstlisting}
%%   In []: y = arange(3)
%%   In []: x = linspace(0,3,3)
%%   In []: x-y
%% \end{lstlisting}
%% \end{frame}

%% \begin{frame}[fragile]
%% \frametitle{\incqno }
%% \begin{lstlisting}
%%   In []: x
%%   array([[ 0, 1, 2, 3],
%%          [ 4, 5, 6, 7],
%%          [ 8, 9, 10, 11],
%%          [12, 13, 14, 15]])
%% \end{lstlisting}
%% How will you get the following \lstinline+x+?
%% \begin{lstlisting}
%%   array([[ 5, 7],
%%          [ 9, 11]])
%% \end{lstlisting}
%% \end{frame}

%% \begin{frame}[fragile]
%% \frametitle{\incqno }
%% What would be the output?
%% \begin{lstlisting}
%%   In []: y = arange(4)
%%   In []: x = array(([1,2,3,2],[1,3,6,0]))
%%   In []: x + y
%% \end{lstlisting}
%% \end{frame}

%% \begin{frame}[fragile]
%% \frametitle{\incqno }
%% \begin{lstlisting}
%%   In []: line = plot(x, sin(x))
%% \end{lstlisting}
%% Use the \lstinline+set_linewidth+ method to set width of \lstinline+line+ to 2.
%% \end{frame}

%% \begin{frame}[fragile]
%% \frametitle{\incqno }
%% What would be the output?
%% \begin{lstlisting}
%%   In []: x = arange(9)
%%   In []: y = arange(9.)
%%   In []: x == y
%% \end{lstlisting}
%% \end{frame}


\end{document}