quiz.tex
author Santosh G. Vattam <vattam.santosh@gmail.com>
Fri, 09 Oct 2009 17:04:07 +0530
changeset 92 d9c31aacd835
parent 89 98ebba820e91
child 94 8c92864c184b
permissions -rw-r--r--
Made little changes to handout.tex.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
     1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
     2
% Tutorial slides on Python.
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
     3
%
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
     4
% Author: FOSSEE <info at fossee  dot in>
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
     5
% Copyright (c) 2005-2009, FOSSEE Team
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
     6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
     7
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
     8
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
     9
\documentclass[14pt,compress]{beamer}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    10
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    11
\mode<presentation>
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    12
{
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    13
  \useoutertheme{split}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    14
  \setbeamercovered{transparent}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    15
}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    16
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    17
\definecolor{darkgreen}{rgb}{0,0.5,0}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    18
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    19
\usepackage{listings}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    20
\lstset{language=Python,
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    21
    basicstyle=\ttfamily\bfseries,
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    22
    commentstyle=\color{red}\itshape,
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    23
  stringstyle=\color{darkgreen},
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    24
  showstringspaces=false,
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    25
  keywordstyle=\color{blue}\bfseries}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    26
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    27
\newcommand{\kwrd}[1]{ \texttt{\textbf{\color{blue}{#1}}}  }
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    28
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    29
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    30
% Title page
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    31
\title[Basic Python]{Python: Quiz}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    32
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    33
\author[FOSSEE Team] {FOSSEE}
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    34
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    35
\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    36
\date[] {11, October 2009\\Day 2, Session 0}
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    37
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    38
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    39
333092b68926 Added quiz tex file and all exercise problems Madhu worked out.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
\begin{document}
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    41
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    42
\begin{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    43
  \titlepage
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    44
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    45
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    46
\begin{frame}{}
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    47
  What is the largest integer value that can be represented by Python?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    48
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    49
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    50
\begin{frame}{}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    51
  What is the result of 17.0 / 2?
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    52
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    53
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    54
\begin{frame}{}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    55
  What does '*' * 40 produce?
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    56
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    57
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    58
\begin{frame}{}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    59
  Which of the following is not a type in Python?
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    60
  \begin{enumerate}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    61
    \item int
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    62
    \item float
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    63
    \item char
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    64
    \item string
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    65
  \end{enumerate}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    66
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    67
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    68
\begin{frame}[fragile]{}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    69
  What happens when we run this code?
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    70
  \begin{lstlisting}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    71
a = False
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    72
b = True
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    73
c = True
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    74
if a and b or c:
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    75
    print "You are correct!"
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    76
  \end{lstlisting}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    77
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    78
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    79
\begin{frame}{}
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    80
  What is the difference between \kwrd{print} \emph{x} and \kwrd{print} \emph{x,} ?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    81
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    82
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    83
\begin{frame}{}
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    84
  A sample line from a Comma Separated Values (CSV) file:\\
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    85
  \vspace*{0.2in}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    86
  \emph{Rossum, Guido, 42, 56, 34, 54}\\
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    87
  \vspace*{0.2in}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    88
  What method would you use to separate the line into fields?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    89
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    90
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    91
\begin{frame}{}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    92
  How many items can a function return?
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    93
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
    94
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    95
\begin{frame}[fragile]{}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    96
  \begin{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    97
  >>> a = [1, 2, 5, 9]
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    98
  >>> a[:-1]
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
    99
  \end{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   100
  What is the output?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   101
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   102
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   103
\begin{frame}{}
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   104
  How do you get the alternate elements of a list?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   105
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   106
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   107
\begin{frame}{}
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   108
  How do you combine the two lists \emph{a} and \emph{b}?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   109
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   110
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   111
\begin{frame}{}
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   112
  How do you find the presence of an element \emph{x} in the list \emph{a}?
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   113
\end{frame}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   114
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   115
\begin{frame}[fragile]{}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   116
  \begin{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   117
  >>> a = (1, 2, 5, 7)
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   118
  >>> a[1]
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   119
  \end{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   120
  What is the output?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   121
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   122
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   123
\begin{frame}[fragile]{}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   124
  \begin{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   125
  for x in "abcd":
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   126
      print x
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   127
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   128
  a
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   129
  b
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   130
  c
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   131
  d
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   132
  \end{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   133
  How do you get the following output? 
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   134
  \begin{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   135
    0 a
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   136
    1 b
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   137
    2 c
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   138
    3 d
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   139
  \end{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   140
  by doing a small modification in the same two lines of code above?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   141
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   142
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   143
\begin{frame}{}
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   144
  What can you use as the keys of a dictionary?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   145
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   146
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   147
\begin{frame}[fragile]{}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   148
  \begin{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   149
  >>> d = {
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   150
      'a': 1,
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   151
      'b': 2
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   152
      }
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   153
  >>> print d['c']
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   154
  \end{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   155
  What is the output?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   156
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   157
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   158
\begin{frame}{}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   159
  How do you obtain all the keys of the dictionary?
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   160
  \pause
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   161
  \\all the values?
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   162
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   163
89
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   164
\begin{frame}[fragile]{}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   165
  \begin{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   166
  >>> set([1, 2, 8, 2, 13, 8, 9])
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   167
  \end{lstlisting}
98ebba820e91 Edited quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 86
diff changeset
   168
  What is the output?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   169
\end{frame}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   170
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   171
\end{document}
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   172
85
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   173
\begin{enumerate}
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   174
  \item Which version of Python were you using?
85
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   175
  \item List some key differences between IPython and Vanilla Python
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   176
  \item What is the biggest integer number that can be represented by Python?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   177
  \item What is the result of 17.0 / 2?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   178
  \item What does '*' * 40 produce?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   179
  \item List all the basic types available in Python.
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   180
  \item What happens when we run this code?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   181
  a = False
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   182
  b = True
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   183
  c = True
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   184
  if a and b or c:
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   185
      print ``You are correct!''
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   186
  \item Select last 3 alternative elements in any given list.
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   187
  \item Give the difference between print x and print x,
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   188
  \item A single line of CSV file should be separated into fields. What method would you use to achieve this?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   189
  \item How many items can a function return?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   190
  \item If function returns more than one item/object what is the return type of the function?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   191
  \item How do you document a function?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   192
  \item Given a list l, what will its slice l[:-1] evaluate to?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   193
  \item How do you get a slice of the list where the slice has only alternate elements?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   194
  \item How do you add another list at the end of a given list?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   195
  \item How do you find if a given element is present in the list or not?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   196
  \item You are given a tuple a = (1, 2, 5, 7). What happens when you do a[1] = 3?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   197
  \item We use for to loop through the list elements. What do we have to do if we want to iterate through the elements of the list as well as get the index of the elements of the list as we iterate through?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   198
  \item What is the difference between import math and from math import *?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   199
  \item List at least 5 Standard Library Modules.
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   200
  \item How do you create a Python module of your own?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   201
  \item What can be the keys of a dictionary?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   202
  \item What happens when you try to access a key in the dictionary that does not exist?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   203
  \item How do you avoid such an exception?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   204
  \item How do you obtain all the keys of the dictionary?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   205
  \item How do you obtain all the values of the dictionary?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   206
  \item What will the set contain when you create a set from a list containing duplicate elements?
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   207
  \item Name any 2 types of Exception.
8ca53181bee6 Added quiz questions.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 64
diff changeset
   208
  \item Whats are the 2 IPython command you use for debugging?
86
f657495cf8b2 Final set of changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 85
diff changeset
   209
\end{enumerate}