diff options
Diffstat (limited to 'day1/session3.tex')
-rw-r--r-- | day1/session3.tex | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/day1/session3.tex b/day1/session3.tex index 2de2634..135bfc1 100644 --- a/day1/session3.tex +++ b/day1/session3.tex @@ -142,13 +142,13 @@ \begin{frame}[fragile] \frametitle{Acceleration due to gravity - ``g''\ldots} \begin{lstlisting} -In []: G = [] +In []: g_list = [] In []: for line in open('pendulum.txt'): .... point = line.split() .... l = float(point[0]) .... t = float(point[1]) .... g = 4 * pi * pi * l / (t * t) - .... G.append(g) + .... g_list.append(g) \end{lstlisting} \end{frame} @@ -162,28 +162,29 @@ In []: for line in open('pendulum.txt'): \begin{frame}[fragile] \frametitle{Mean ``g''} \begin{lstlisting} -total = 0 -for g in G: - total += g +In []: total = 0 +In []: for g in g_list: + ....: total += g + ....: -g_mean = total / len(G) -print 'Mean: ', g_mean +In []: g_mean = total / len(g_list) +In []: print 'Mean: ', g_mean \end{lstlisting} \end{frame} \begin{frame}[fragile] \frametitle{Mean ``g''} \begin{lstlisting} -g_mean = sum(G) / len(G) -print 'Mean: ', g_mean +In []: g_mean = sum(g_list) / len(g_list) +In []: print 'Mean: ', g_mean \end{lstlisting} \end{frame} \begin{frame}[fragile] \frametitle{Mean ``g''} \begin{lstlisting} -g_mean = mean(G) -print 'Mean: ', g_mean +In []: g_mean = mean(g_list) +In []: print 'Mean: ', g_mean \end{lstlisting} \inctime{10} \end{frame} @@ -332,7 +333,6 @@ science = {} science = {} for record in open('sslc1.txt'): - record = record.strip() fields = record.split(';') region_code = fields[0].strip() @@ -395,7 +395,6 @@ savefig('science.png') math_scores = [] for record in open('sslc1.txt'): - record = record.strip() fields = record.split(';') score_str = fields[5].strip() |