summaryrefslogtreecommitdiff
path: root/getting_started_with_lists
diff options
context:
space:
mode:
Diffstat (limited to 'getting_started_with_lists')
-rw-r--r--getting_started_with_lists/script.rst55
-rw-r--r--getting_started_with_lists/script.rst.orig224
-rw-r--r--getting_started_with_lists/slides.org6
-rw-r--r--getting_started_with_lists/slides.tex35
4 files changed, 55 insertions, 265 deletions
diff --git a/getting_started_with_lists/script.rst b/getting_started_with_lists/script.rst
index ee9ce1c..2264d45 100644
--- a/getting_started_with_lists/script.rst
+++ b/getting_started_with_lists/script.rst
@@ -60,7 +60,8 @@ List is a compound data type, it can contain data of mutually
different datatypes. List is also a sequence data type where all the
elements are arranged in a specific order.
-Start the ipython interpreter and first create an empty list with no elements.
+Start the ipython interpreter and first create an empty list with no
+elements.
.. L3
::
@@ -87,9 +88,9 @@ of comma-separated values (or items) between two square brackets.
As we can see, lists can contain different kinds of data. In the
previous example 'spam' and 'eggs' are strings whereas 100 and 1.234 are
-integer and float respectively. Thus, we can put elements of different datatypes in
-lists including lists itself. This property makes lists heterogeneous
-data structures.
+integer and float respectively. Thus, we can put elements of different
+datatypes in lists including lists itself. This property makes lists
+heterogeneous data structures.
Let us include a list within a list.
@@ -114,7 +115,7 @@ nonempty[3] the last element.
.. L7
-{{{ Switch to the slide Question 1 }}}
+{{{ Switch to the slide exercise 1 }}}
.. R7
@@ -142,12 +143,14 @@ As you can see you get the last element which is 1.234.
.. R9
In python negative indices are used to access elements from the end.
--1 gives the last element which is the 4th element , -2 gives second element to last
-and -4 gives the fourth from the last which, in this case, is the first element.
+-1 gives the last element which is the 4th element , -2 gives second
+element to last and -4 gives the fourth from the last which, in this case,
+is the first element.
.. R10
-We can also append elements to the end of a list using the ``append`` function.
+We can also append elements to the end of a list using the ``append``
+function.
.. L10
::
@@ -159,7 +162,7 @@ We can also append elements to the end of a list using the ``append`` function.
.. L11
-{{{ Switch to slide Question 2 }}}
+{{{ Switch to slide exercise 2 }}}
.. R11
@@ -179,7 +182,8 @@ As we can see nonempty is appended with 'onemore' and 6 at the end.
.. R13
-Let us move further.We can use ``len`` function to check the number of elements in the list.
+Let us move further.We can use ``len`` function to check the number of
+elements in the list.
Let us find out the length of the list 'nonempty'.
.. L13
@@ -199,12 +203,12 @@ There are two ways of doing it. One is by using index.
.. R15
-The function ``del`` deletes the element at index 1, i.e the second element of the
-list, 'eggs'.
+The function ``del`` deletes the element at index 1, i.e the second
+element of the list, 'eggs'.
The other way is removing element by content. Lets say
-one wishes to delete 100 from nonempty list.For this, one could use the function
-``remove``.
+one wishes to delete 100 from nonempty list.For this, one could use
+the function ``remove``.
.. L15
::
@@ -227,11 +231,12 @@ experiment.
.. R17
If we now check, we will see that the first occurence 'spam' is removed
-and therefore the function `remove` removes the first occurence of the element in the sequence
-and leaves others untouched.
+and therefore the function `remove` removes the first occurence of the
+element in the sequence and leaves others untouched.
One should remember this, that while ``del`` removes by index number,
-`remove` removes on the basis of content being passed on.Let us take an example.
+`remove` removes on the basis of content being passed on.Let us take
+an example.
.. L17
@@ -252,12 +257,12 @@ del gives us [1,2,3].
.. R19
-remove will give us [2,1,3]. Since it deletes the first occurrence of what is
-returned by x[2] which is 1.
+remove will give us [2,1,3]. Since it deletes the first occurrence of
+what is returned by x[2] which is 1.
.. L20
-{{{ Switch to the slide Question 3 }}}
+{{{ Switch to the slide exercise 3 }}}
.. R20
@@ -281,7 +286,7 @@ The solution is on your screen.
.. R22
This brings us to the end of this tutorial.
-In this tutorial we learnt to,
+In this tutorial, we have learnt to,
1. Create lists.
#. Access lists using their index numbers.
@@ -311,7 +316,8 @@ Here are some self assessment questions for you to solve
And the answers,
-1. We create an empty list just by leaving the space inside the square brackets empty.
+1. We create an empty list just by leaving the space inside the square
+brackets empty.
::
empty=[]
@@ -322,7 +328,8 @@ And the answers,
list_in_list=[2.3,[2,4,6],'string,'all datatypes can be there']
-3. Using negative indices, we can access the list from the end using negative indices.
+3. Using negative indices, we can access the list from the end using
+ negative indices.
This is an example
::
@@ -335,6 +342,6 @@ And the answers,
.. R25
-Hope you have enjoyed and found it useful.
+Hope you have enjoyed this tutorial and found it useful.
Thank you!
diff --git a/getting_started_with_lists/script.rst.orig b/getting_started_with_lists/script.rst.orig
deleted file mode 100644
index 3f068eb..0000000
--- a/getting_started_with_lists/script.rst.orig
+++ /dev/null
@@ -1,224 +0,0 @@
-.. Objectives
-.. ----------
-
-.. By the end of this tutorial, you will be able to
-
-.. Create Lists.
-.. Access List elements.
-.. Append elemets to list
-.. Delete list elemets
-
-.. 1. getting started with ipython
-
-
-
-.. Prerequisites
-.. -------------
-
-.. 1. getting started with strings
-.. #. getting started with lists
-.. #. basic datatypes
-
-.. Author : Amit
- Internal Reviewer : Anoop Jacob Thomas <anoop@fossee.in>
- External Reviewer :
- Checklist OK? : <put date stamp here, if OK> [2010-10-05]
-
-.. #[[Anoop: Slides contain only outline and summary
-
-Script
-------
- {{{ Show the slide containing title }}}
-
-Hello friends and welcome to the tutorial on getting started with
-lists.
-
- {{{ Show the slide containing the outline slide }}}
-
-In this tutorial we will be getting acquainted with a python data
-structure called lists. We will learn ::
-
- * How to create lists
- * Structure of lists
- * Access list elements
- * Append elements to lists
- * Delete elements from lists
-
-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 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
- follow this.]]
-
-We will first create an empty list with no elements. On your IPython
-shell type ::
-
- empty = []
- type(empty)
-
-
-This is an empty list without any elements.
-
-.. #[[Anoop: the document has to be continous, without any
- subheadings, removing * Filled lists]]
-
-Lets now see how to define a non-empty list. We do it as,::
-
- nonempty = ['spam', 'eggs', 100, 1.234]
-
-Thus the simplest way of creating a list is typing out a sequence
-of comma-separated values (items) between square brackets.
-All the list items need not be of the same data type.
-
-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 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 ::
-
- 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]
-the second element and so on and nonempty[3] the last element. ::
-
- nonempty[0]
- 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.]]
-
-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]
- nonempty[-4]
-
--1 gives the last element which is the 4th element , -2 second to last
-and -4 gives the fourth from last element which is first element.
-
-We can append elements to the end of a list using append command. ::
-
- nonempty.append('onemore')
- nonempty
- 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
-nonempty. In this case it 6 ::
-
- len(nonempty)
-
-
-
-Just like we can append elements to a list we can also remove them.
-There are two ways of doing it. One is by using index. ::
-
- del(nonempty[1])
-
-
-
-deletes the element at index 1, 'eggs' which is the second element of
-the list. The other way is removing element by content. Lets say one
-wishes to delete 100 from nonempty list the syntax of the command
-should be
-
-.. #[[Anoop: let x = [1,2,1,3]
- now x.remove(x[2])
- still x is [2,1,3] so that is not the way to remove
- element by index, it removed first occurrence of 1(by
- content) and not based on index, so make necessary
- changes]]
-
-::
-
- nonempty.remove(100)
-
-but what if there were two 100's. To check that lets do a small
-experiment. ::
-
- nonempty.append('spam')
- nonempty
- 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 }}}
-
-
-In this tutorial we came across a sequence data type called lists. ::
-
- * We learned how to create lists.
- * How to access lists.
- * Append elements to list.
- * Delete Element from list.
- * And Checking list length.
-
-
-
-{{{ show Sponsored by Fossee Slide }}}
-
-This tutorial was created as a part of FOSSEE project.
-
-I hope you found this tutorial useful.
-
-Thank You
-
-..
- * Author : Amit Sethi
- * First Reviewer :
- * Second Reviewer : Nishanth
diff --git a/getting_started_with_lists/slides.org b/getting_started_with_lists/slides.org
index 235b3f7..5c6e25d 100644
--- a/getting_started_with_lists/slides.org
+++ b/getting_started_with_lists/slides.org
@@ -54,10 +54,10 @@
- Append elements to lists
- Delete elements from lists
-* Question 1
+* Exercise 1
- What happens when you do nonempty[-1].
-* Question 2
+* Exercise 2
- What is the syntax to get the element 'and'
in the list,listinlist ?
- How would you get 'and' using negative indices?
@@ -70,7 +70,7 @@
listinlist[-5]
#+end_src python
-* Question 3
+* Exercise 3
- Remove the third element from the list, listinlist.
diff --git a/getting_started_with_lists/slides.tex b/getting_started_with_lists/slides.tex
index d1c81e1..01f8b10 100644
--- a/getting_started_with_lists/slides.tex
+++ b/getting_started_with_lists/slides.tex
@@ -1,4 +1,4 @@
-% Created 2011-05-11 Wed 15:13
+% Created 2011-05-24 Tue 09:52
\documentclass[presentation]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
@@ -19,7 +19,8 @@
\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
\usepackage{listings}
\lstset{language=Python, basicstyle=\ttfamily\bfseries,
-commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
+commentstyle=\color{red}\itshape, stringstyle=\color
+{darkgreen},
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\providecommand{\alert}[1]{\textbf{#1}}
@@ -44,14 +45,18 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\begin{frame}
\begin{center}
-\textcolor{blue}{Getting started with Lists}
+\vspace{12pt}
+\textcolor{blue}{\huge Getting started with Lists}
\end{center}
+\vspace{18pt}
\begin{center}
-\includegraphics[scale=0.25]{../images/iitb-logo.png}\\
-Developed by FOSSEE Team, IIT-Bombay. \\
-Funded by National Mission on Education through ICT
-
-MHRD, Govt. of India
+\vspace{10pt}
+\includegraphics[scale=0.95]{../images/fossee-logo.png}\\
+\vspace{5pt}
+\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\
+\scriptsize Funded by National Mission on Education through ICT\\
+\scriptsize MHRD,Govt. of India\\
+\includegraphics[scale=0.30]{../images/iitb-logo.png}\\
\end{center}
\end{frame}
\begin{frame}
@@ -68,7 +73,7 @@ MHRD, Govt. of India
\end{itemize}
\end{frame}
\begin{frame}
-\frametitle{Question 1}
+\frametitle{Exercise 1}
\label{sec-3}
@@ -77,7 +82,7 @@ MHRD, Govt. of India
\end{itemize}
\end{frame}
\begin{frame}
-\frametitle{Question 2}
+\frametitle{Exercise 2}
\label{sec-4}
@@ -100,7 +105,7 @@ listinlist[-5]
\end{lstlisting}
\end{frame}
\begin{frame}
-\frametitle{Question 3}
+\frametitle{Exercise 3}
\label{sec-6}
@@ -144,7 +149,9 @@ listinlist.remove('and')
\begin{enumerate}
\item How do you create an empty list?
+\vspace{8pt}
\item Can you have a list inside a list ?
+\vspace{8pt}
\item How would you access the end of a list without finding its length?
\end{enumerate}
\end{frame}
@@ -155,16 +162,16 @@ listinlist.remove('and')
\begin{enumerate}
\item empty=[]
+\vspace{8pt}
\item Yes\\
list\_in\_list=[2.3,[2,4,6],'string,'all datatypes can be there']
+\vspace{8pt}
\item Using negative indices\\
nonempty = ['spam', `eggs', 100, 1.234]\\
nonempty[-1]
\end{enumerate}
\end{frame}
\begin{frame}
-\frametitle{Acknowledgement}
-\label{sec-11}
\begin{block}{}
\begin{center}
@@ -179,4 +186,4 @@ nonempty = ['spam', `eggs', 100, 1.234]\\
\end{block}
\end{frame}
-\end{document} \ No newline at end of file
+\end{document}