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
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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: Quiz}
\author[FOSSEE Team] {FOSSEE}
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
\date[] {31, October 2009\\Day 1, Quiz 1}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\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 Affliation:
\item Occupation:
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{\incqno }
A sample line from a Comma Separated Values (CSV) file:\\
\vspace*{0.2in}
\emph{Rossum, Guido, 42, 56, 34, 54}\\
\vspace*{0.2in}
What method would you use to separate the line into fields?
\end{frame}
\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
In [1]: a = [1, 2, 5, 9]
In [2]: a[:-1]
\end{lstlisting}
What is the output?
\end{frame}
\begin{frame}
\frametitle{\incqno }
How do you combine the two lists \emph{a} and \emph{b}?
\end{frame}
\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
In [1]: d = {
'a': 1,
'b': 2
}
In [2]: print d['c']
\end{lstlisting}
What is the output?
\end{frame}
\begin{frame}[fragile]
\frametitle{\incqno }
\begin{lstlisting}
for x in "abcd":
print x
a
b
c
d
\end{lstlisting}
How do you get the following output?
\begin{lstlisting}
0 a
1 b
2 c
3 d
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{\incqno }
What would be the result?
\begin{lstlisting}
In [1]: x
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
In [2]: x[::-1,:]
\end{lstlisting}
\end{frame}
\begin{frame}
\frametitle{\incqno }
How to read and print each line of a file.
\end{frame}
\begin{frame}
\frametitle{\incqno }
How to get list of third column of a data file.
\end{frame}
\begin{frame}[fragile]
\frametitle{\incqno }
What is the output of:
\begin{lstlisting}
In []: x=linspace(0 , 2 * pi)
In []: plot(x, cos(x),'go')
\end{lstlisting}
\end{frame}
\begin{frame}
\frametitle{\incqno }
Draw a plot with line width 3.
\end{frame}
\begin{frame}
\frametitle{\incqno }
Setting x and y axis limits.
\end{frame}
\end{document}
|