Exercises for getting started with lists and some changes based on review
authorAmit Sethi
Wed, 10 Nov 2010 12:23:40 +0530
changeset 441 430035b678f7
parent 434 c8ffd52305ff
child 442 a9b71932cbfa
Exercises for getting started with lists and some changes based on review
getting-started-with-lists/script.rst
getting-started-with-lists/slides.org
getting-started-with-lists/slides.tex
--- a/getting-started-with-lists/script.rst	Wed Nov 10 02:12:09 2010 +0530
+++ b/getting-started-with-lists/script.rst	Wed Nov 10 12:23:40 2010 +0530
@@ -46,7 +46,7 @@
 
 List is a compound data type, it can contain data of other data
 types. List is also a sequence data type, all the elements are in
-order and there order has a meaning.
+order and the order has a meaning.
 
 .. #[[Anoop: "all the elements are in order and **there** order has a
    meaning." - I guess something is wrong here, I am not able to
@@ -75,15 +75,14 @@
 As we can see lists can contain different kinds of data. In the
 previous example 'spam' and 'eggs' are strings and 100 and 1.234 are
 integer and float. Thus we can put elements of heterogenous types in
-lists. Thus list themselves can be one of the element types possible
-in lists. Thus lists can also contain other lists.  
+lists including list itself.
 
 .. #[[Anoop: the sentence "Thus list themselves can be one of the
    element types possible in lists" is not clear, rephrase it.]]
 
 Example ::
 
-      list_in_list=[[4,2,3,4],'and', 1, 2, 3, 4]
+      listinlist=[[4,2,3,4],'and', 1, 2, 3, 4]
 
 We access list elements using the index. The index begins from 0. So
 for list nonempty, nonempty[0] gives the first element, nonempty[1]
@@ -93,11 +92,20 @@
 	    nonempty[1] 
 	    nonempty[3]
 
+Following is an exercise that you must do. 
+
+%% %% What happens when you do nonempty[-1]. 
+
+Please, pause the video here. Do the exercise and then continue.  
+
 .. #[[Anoop: was negative indices introduced earlier, if not may be we
    can ask them to try out nonempty[-1] and see what happens and then
    tell that it gives the last element in the list.]]
 
-We can also access the elememts from the end using negative indices ::
+As you can see you get the last element which is 1.234.
+
+
+In python negative indices are used to access elements from the end::
    
    nonempty[-1] 
    nonempty[-2] 
@@ -113,6 +121,19 @@
    nonempty.append(6) 
    nonempty
    
+Following are  exercises that you must do. 
+
+%% %% What is the syntax to get the element 'and' 
+in the list,listinlist ?
+
+
+%% %% How would you get 'and' using negative indices?
+
+Please, pause the video here. Do the exercise and then continue.  
+
+The solution is on your screen
+
+
 As we can see non empty appends 'onemore' and 6 at the end.
 
 Using len function we can check the number of elements in the list
@@ -148,20 +169,34 @@
 but what if there were two 100's. To check that lets do a small
 experiment. ::
 
-	   nonempty.append('python') 
+	   nonempty.append('spam') 
 	   nonempty
-	   nonempty.remove('python') 
+	   nonempty.remove('spam') 
 	   nonempty
 
 If we check now we will see that the first occurence 'spam' is removed
 thus remove removes the first occurence of the element in the sequence
 and leaves others untouched.
 
+
+
+
+
 .. #[[Anoop: does it have two spams or two pythons?]]
 
 .. #[[Anoop: there are no exercises/solved problems in this script,
    add them]]
 
+Following are  exercises that you must do. 
+
+%% %% Remove the third element from the list, listinlist.   
+
+%% %% Remove 'and' from the list, listinlist.
+
+Please, pause the video here. Do the exercise and then continue.  
+
+
+
 {{{Slide for Summary }}}
 
 
--- a/getting-started-with-lists/slides.org	Wed Nov 10 02:12:09 2010 +0530
+++ b/getting-started-with-lists/slides.org	Wed Nov 10 12:23:40 2010 +0530
@@ -2,34 +2,99 @@
 #+LaTeX_CLASS_OPTIONS: [presentation]
 #+BEAMER_FRAME_LEVEL: 1
 
-#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\useoutertheme{infolines}\usecolortheme{default}\setbeamercovered{transparent}
+#+BEAMER_HEADER_EXTRA: \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
 #+COLUMNS: %45ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Env Args) %4BEAMER_col(Col) %8BEAMER_extra(Extra)
 #+PROPERTY: BEAMER_col_ALL 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 :ETC
-#+OPTIONS:   H:5 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+
+#+LaTeX_CLASS: beamer
+#+LaTeX_CLASS_OPTIONS: [presentation]
+
+#+LaTeX_HEADER: \usepackage[english]{babel} \usepackage{ae,aecompl}
+#+LaTeX_HEADER: \usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+
+#+LaTeX_HEADER: \usepackage{listings}
+
+#+LaTeX_HEADER:\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+#+LaTeX_HEADER:  commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+#+LaTeX_HEADER:  showstringspaces=false, keywordstyle=\color{blue}\bfseries}
 
 #+TITLE: Getting started with Lists
 #+AUTHOR: FOSSEE
 #+DATE: 2010-09-14 Tue
 #+EMAIL:     info@fossee.in
 
-# \author[FOSSEE] {FOSSEE}
+#+DESCRIPTION: 
+#+KEYWORDS: 
+#+LANGUAGE:  en
+#+OPTIONS:   H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
+#+OPTIONS:   TeX:t LaTeX:nil skip:nil d:nil todo:nil pri:nil tags:not-in-toc
 
-# \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
-# \date{}
 
-* Tutorial Plan 
-** How to create lists
-** Structure of lists  
-** Access list elements
-** Append elements to lists
-** Deleting elements from lists
+* Outline 
+ - How to create lists
+ - Structure of lists  
+ - Access list elements
+ - Append elements to lists
+ - Deleting elements from lists
+
+
+* Question 1 
+  - What happens when you do nonempty[-1].
+
+* Solution 1
+  - It gives the last element , 1.234
+
+* Questions
+  - What is the syntax to get the element 'and' 
+in the list,listinlist ?
 
 
+  - How would you get 'and' using negative indices?
+
+* Solutions
+#+begin_src python
+  
+  listinlist[1]
+  listinlist[-5]
+
+#+end_src python
+* Questions
+
+  - Remove the third element from the list, listinlist.   
+
+  - Remove 'and' from the list, listinlist.
+
+* Solutions
+#+begin_src python
+  
+  del(listinlist[2])
+  listinlist.remove('and')
+
+#+end_src python
 * Summary
-
+#+begin_src python
+  
   l=[1,2,3,4]
   l[-1]
   l.append(5)
   del(l[2])
+  l.remove(2)
   len(l)
 
+#+end_src python
+* Thank you!
+#+begin_latex
+  \begin{block}{}
+  \begin{center}
+  This spoken tutorial has been produced by the
+  \textcolor{blue}{FOSSEE} team, which is funded by the 
+  \end{center}
+  \begin{center}
+    \textcolor{blue}{National Mission on Education through \\
+      Information \& Communication Technology \\ 
+      MHRD, Govt. of India}.
+  \end{center}  
+  \end{block}
+#+end_latex
+
+
--- a/getting-started-with-lists/slides.tex	Wed Nov 10 02:12:09 2010 +0530
+++ b/getting-started-with-lists/slides.tex	Wed Nov 10 12:23:40 2010 +0530
@@ -1,4 +1,4 @@
-% Created 2010-11-09 Tue 17:41
+% Created 2010-11-10 Wed 12:22
 \documentclass[presentation]{beamer}
 \usepackage[latin1]{inputenc}
 \usepackage[T1]{fontenc}
@@ -16,13 +16,19 @@
 \usepackage{amssymb}
 \usepackage{hyperref}
 \tolerance=1000
+\usepackage[english]{babel} \usepackage{ae,aecompl}
+\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
+\usepackage{listings}
+\lstset{language=Python, basicstyle=\ttfamily\bfseries,
+commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+showstringspaces=false, keywordstyle=\color{blue}\bfseries}
 \providecommand{\alert}[1]{\textbf{#1}}
 
 \title{Getting started with Lists}
 \author{FOSSEE}
 \date{2010-09-14 Tue}
 
-\usetheme{Warsaw}\useoutertheme{infolines}\usecolortheme{default}\setbeamercovered{transparent}
+\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
 \begin{document}
 
 \maketitle
@@ -32,33 +38,112 @@
 
 
 
+
+
+
+
 \begin{frame}
-\frametitle{Tutorial Plan}
+\frametitle{Outline}
 \label{sec-1}
-\begin{itemize}
 
-\item How to create lists\\
-\label{sec-1_1}%
-\item Structure of lists\\
-\label{sec-1_2}%
-\item Access list elements\\
-\label{sec-1_3}%
-\item Append elements to lists\\
-\label{sec-1_4}%
-\item Deleting elements from lists\\
-\label{sec-1_5}%
-\end{itemize} % ends low level
+\begin{itemize}
+\item How to create lists
+\item Structure of lists
+\item Access list elements
+\item Append elements to lists
+\item Deleting elements from lists
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Question 1}
+\label{sec-2}
+
+\begin{itemize}
+\item What happens when you do nonempty[-1].
+\end{itemize}
+\end{frame}
+\begin{frame}
+\frametitle{Solution 1}
+\label{sec-3}
+
+\begin{itemize}
+\item It gives the last element , 1.234
+\end{itemize}
 \end{frame}
 \begin{frame}
-\frametitle{Summary}
-\label{sec-2}
+\frametitle{Questions}
+\label{sec-4}
+
+\begin{itemize}
+\item What is the syntax to get the element `and'
+\end{itemize}
+
+in the list,listinlist ?
+
+
+\begin{itemize}
+\item How would you get `and' using negative indices?
+\end{itemize}
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solutions}
+\label{sec-5}
+
+\begin{verbatim}
+
+listinlist[1]
+listinlist[-5]
+\end{verbatim}
+\end{frame}
+\begin{frame}
+\frametitle{Questions}
+\label{sec-6}
 
 
-  l=[1,2,3,4]
-  l[-1]
-  l.append(5)
-  del(l\footnote{FOOTNOTE DEFINITION NOT FOUND: 2 })
-  len(l)
+\begin{itemize}
+\item Remove the third element from the list, listinlist.
+\item Remove `and' from the list, listinlist.
+\end{itemize}
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Solutions}
+\label{sec-7}
+
+\begin{verbatim}
+
+del(listinlist[2])
+listinlist.remove('and')
+\end{verbatim}
+\end{frame}
+\begin{frame}[fragile]
+\frametitle{Summary}
+\label{sec-8}
+
+\begin{verbatim}
+
+l=[1,2,3,4]
+l[-1]
+l.append(5)
+del(l[2])
+l.remove(2)
+len(l)
+\end{verbatim}
+\end{frame}
+\begin{frame}
+\frametitle{Thank you!}
+\label{sec-9}
+
+  \begin{block}{}
+  \begin{center}
+  This spoken tutorial has been produced by the
+  \textcolor{blue}{FOSSEE} team, which is funded by the 
+  \end{center}
+  \begin{center}
+    \textcolor{blue}{National Mission on Education through \\
+      Information \& Communication Technology \\ 
+      MHRD, Govt. of India}.
+  \end{center}  
+  \end{block}
 \end{frame}
 
 \end{document}