summaryrefslogtreecommitdiff
path: root/day2/session2.tex
diff options
context:
space:
mode:
Diffstat (limited to 'day2/session2.tex')
-rw-r--r--day2/session2.tex37
1 files changed, 17 insertions, 20 deletions
diff --git a/day2/session2.tex b/day2/session2.tex
index 2b163b9..5b1c291 100644
--- a/day2/session2.tex
+++ b/day2/session2.tex
@@ -153,9 +153,7 @@ In []: while b < 10:
\begin{block}{Documentation convention}
\begin{itemize}
\item \alert{Anything within \typ{[]} is optional}
- \begin{itemize}
- \item Nothing to do with Python.
- \end{itemize}
+ \item Nothing to do with Python.
\end{itemize}
\end{block}
\end{frame}
@@ -219,37 +217,37 @@ In []: for i in range(3, 10, 2):
\begin{lstlisting}
num = [1, 2, 3, 4]
\end{lstlisting}
-\centerline{is a list}
+is a list
\end{block}
\end{frame}
\begin{frame}[fragile]
\frametitle{Lists: methods}
\begin{lstlisting}
-In []: num = [1, 2, 3, 4]
+In []: num = [9, 8, 2, 3, 7]
-In []: num + [9, 10, 11]
-Out[]: [1, 2, 3, 4, 9, 10, 11]
+In []: num + [4, 5, 6]
+Out[]: [9, 8, 2, 3, 7, 4, 5, 6]
-In []: num.append([9, 10, 11])
+In []: num.append([4, 5, 6])
In []: num
-Out[]: [1, 2, 3, 4, [9, 10, 11]]
+Out[]: [9, 8, 2, 3, 7, [4, 5, 6]]
\end{lstlisting}
\end{frame}
\begin{frame}[fragile]
\frametitle{Lists: methods}
\begin{lstlisting}
-In []: num = [1, 2, 3, 4]
+In []: num = [9, 8, 2, 3, 7]
-In []: num.extend([5, 6, 7])
+In []: num.extend([4, 5, 6])
In []: num
-Out[]: [1, 2, 3, 4, 5, 6, 7]
+Out[]: [9, 8, 2, 3, 7, 4, 5, 6]
In []: num.reverse()
In []: num
-Out[]: [7, 6, 5, 4, 3, 2, 1]
+Out[]: [6, 5, 4, 7, 3, 2, 8, 9]
In []: num.remove(6)
In []: num
@@ -294,17 +292,17 @@ Out[]: [5, 4, 3, 2, 1]
\begin{frame}[fragile]
\frametitle{List containership}
-\emphbar{Recall \typ{num} is \typ{[1, 2, 3, 4]}}
+\emphbar{Recall \typ{num} is \typ{[9, 8, 2, 3, 7]}}
\begin{lstlisting}
In []: 4 in num
-Out[]: True
+Out[]: False
-In []: b = 15
+In []: b = 8
In []: b in num
-Out[]: False
+Out[]: True
In []: b not in num
-Out[]: True
+Out[]: False
\end{lstlisting}
\end{frame}
@@ -387,7 +385,7 @@ Out[]: [10823, 233,
\end{frame}
\begin{frame} {Problem Set 2.1: Problem 2.1.1}
-You are given date strings of the form ``29 Jul, 2009'', or ``4 January 2008''. In other words a number, a string and another number, with a comma sometimes separating the items.\\Write a function that takes such a string and returns a tuple (yyyy, mm, dd) where all three elements are ints.
+You are given date strings of the form ``29 Jul, 2009'', or ``4 January 2008''. In other words a number, a string and another number, with a comma sometimes separating the items.\\Write a program that takes such a string as input and prints a tuple (yyyy, mm, dd) where all three elements are ints.
\end{frame}
\subsection{Sets}
@@ -453,7 +451,6 @@ Given a dictionary of the names of students and their marks, identify how many d
\frametitle{Problem 2.2.2}
Given a list of words, find all the anagrams in the list.
-\inctime{15}
\end{frame}
\section{Functions}