diff options
author | hardythe1 | 2015-02-23 15:27:45 +0530 |
---|---|---|
committer | hardythe1 | 2015-02-23 15:27:45 +0530 |
commit | b57bd2053a40bd2ebbfd941894f7d921b426448f (patch) | |
tree | fb431dca4b56ac183accb53618fb5e075a42785c | |
parent | 86d4d1e402c52ae5a8e92dbb12fda7d996a4dd49 (diff) | |
download | st-scripts-b57bd2053a40bd2ebbfd941894f7d921b426448f.tar.gz st-scripts-b57bd2053a40bd2ebbfd941894f7d921b426448f.tar.bz2 st-scripts-b57bd2053a40bd2ebbfd941894f7d921b426448f.zip |
changed the scripts and slides as per new check list (revamp)
-rw-r--r-- | getting_started_with_for/script.odt | bin | 0 -> 36511 bytes | |||
-rw-r--r-- | getting_started_with_for/script.txt | 256 | ||||
-rw-r--r-- | getting_started_with_for/slides.tex | 334 | ||||
-rw-r--r-- | getting_started_with_lists/script.odt | bin | 0 -> 34989 bytes | |||
-rw-r--r-- | getting_started_with_lists/script.rst | 77 | ||||
-rw-r--r-- | getting_started_with_lists/script.txt | 230 | ||||
-rw-r--r-- | getting_started_with_lists/slides.tex | 248 |
7 files changed, 795 insertions, 350 deletions
diff --git a/getting_started_with_for/script.odt b/getting_started_with_for/script.odt Binary files differnew file mode 100644 index 0000000..b51b55c --- /dev/null +++ b/getting_started_with_for/script.odt diff --git a/getting_started_with_for/script.txt b/getting_started_with_for/script.txt new file mode 100644 index 0000000..eb4b705 --- /dev/null +++ b/getting_started_with_for/script.txt @@ -0,0 +1,256 @@ + +{| style="border-spacing:0;" +| style="border-top:0.05pt double #808080;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| <center>'''Visual Cue'''</center> +| style="border:0.05pt double #808080;padding:0.049cm;"| <center>'''Narration'''</center> + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 1 + +Title Slide +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Hello friends and welcome to the tutorial on '''“Getting Started with For Loop”''' + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 2 + +Objectives +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| At the end of this tutorial, you will be able to, + +# Understand indentation in '''Python''' +# Use the for '''loop'''. +# Use '''range()''' '''function'''. +# Write blocks in '''Python''' '''shell''' +# Write blocks in '''IPython''' '''interpreter''' + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 3 + +White-space +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| In '''Python''' whitespace is significant, and the blocks are visually separated. The convention is to indent the code using four spaces. + +As you can see in the slide, '''"Block B"''' is an '''inner block''', indented by 4 spaces. After '''"Block B"''' the next statement in '''"Block A" '''starts from the same indentation level of other '''"Block A" '''Statements. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 4 + +Excercise 1 +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Now, let us move straight into '''for''' '''loop'''. Write a '''for loop''' which iterates through a list of numbers and find the square root of each number. Numbers are 1369, 7225, 3364, 7056, 5625, 729, 7056, 576, 2916 + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Open text editor + +<nowiki>numbers = [1369, 7225, 3364, 7056, 5625, 729, 7056, 576, 2916]</nowiki> + +for each in numbers: + +print “Suare root of”, each, “is ”, sqrt(each) +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| For the problem, first we need to create a list of numbers and then iterate over the list and find the square root of each element in it. + +Let us create a script, rather than typing it out in the '''interpreter''' itself. + +Open your '''text editor''' and type '''numbers '''''is equal to within round brackets'' 1369 ''coma'' 7225 ''coma'' 3364, 7056, 5625, 729, 7056, 576, 2916. + +We have the list of numbers. Now, to iterate over it we say '''for''' '''each''' in '''numbers''' ''colon'' '''print''' ''opening double quotes'' Square root of ''closing double quotes'' ''coma'' '''each''' ''coma'' in ''double quotes'' '''is''' ''coma'' '''sqrt''' ''within'' ''round brackets'' '''each. '''Save the script as''' list_roots.py. ''' + + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| %run -i list_roots.py +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| We will run the script from the '''IPython interpreter. '''So, switch to your terminal start the '''ipython interpreter''' and run the script as, ''percentage '''''run minus i list_roots.py '''and we get the square roots of the numbers. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Switch to text editor +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| So that was easy! All what we did was iterate over the list element by element and then use the element for calculation. Note that here we used two variables, the variable '''numbers''', which is a list, and the other variable '''each''', which is the element of list under consideration in each cycle of the '''for loop'''. The variable names can be chosen by you. + +Note that the lines after for statement, is indented using four spaces. + +It means that line is a part of the '''for loop''' and it is a block of code, although it is only a single statement in the block. + +Also, the fourth line or the immediate line after the for block is not '''indented'''. + +It means that it is not a part of the for loop and the lines after that don't fall in the scope of the for loop. + +Thus each block is separated by the '''indentation''' level and that marks the importance of white-spaces in '''Python'''. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 5 + +Assignment 2 +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Print the square root of numbers in the list. And this time let us do it right in the '''IPython''' '''interpreter'''. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Switch to the IPython interpreter + +<nowiki>numbers = [1369, 7225, 3364, 7056, 5625, 729, 7056, 576, 2916]</nowiki> + +for each in numbers: + +print "Square root of", each, + +print "is", sqrt(each) + +Hit enter twice +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Switch to your '''terminal '''and type '''numbers '''''is equal to within round brackets'' 1369 ''coma'' 7225 ''coma'' 3364, 7056, 5625, 729, 7056, 576, 2916. + +We have the list of numbers. + +Write the same '''for loop '''we wrote in the script. + +Notice that, as soon as you press the enter key after for statement, the prompt changes to four dots and the cursor is not right after the four dots but there are four spaces from the dots. Please note that '''IPython '''automatically indents the block. The four dots tell you that you are inside the block. + +Now type the rest of the '''for loop'''. + +Now we have finished the statements in the block, and still the interpreter is showing four dots, this means that you are still inside the block. To exit from the block press the return key or the enter key twice without entering anything else. + +We get the expected ouput. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show slide 6 + +Exercise 3 +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| We will now perform an exercise to find cubes of numbers from 1 to 10 in the '''Python shell'''. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Switch to the terminal + +python + + +for i in range(1,11): + +Hit enter + +print i, "cube is", i**3 + +Hit enter +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| You can start the '''shell '''by issuing the command '''python''' from your '''terminal'''. + +Type the '''for '''statement as for i in range''' '''''within round brackets ''one ''coma ''eleven ''colon. '' + +Press enter once, and we will see that this time it shows three dots, but the cursor is close to the dots, so we have to indent the block. The '''python shell '''does not indent the code automatically. So enter four spaces there and then type the following print i ''coma in double quotes ''cube is ''coma ''i star star three. + +Now when we hit enter, we still see the four dots. To get out of the block, hit enter once again. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 7 + +range() function +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Okay! so the main thing we learned here is how to use the '''Python shell''' and the '''IPython interpreter''' to specify blocks. But while we were writing for loops we used something new, '''range() function'''. + +'''range() '''is a built in function in '''Python''' which can be used to generate a list of '''integers''' from a starting number to an ending number. Note that the ending number that you specify will not be included in the list. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 8 + +Assignment 4 +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Print all the odd numbers from 1 to 50. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Switch focus to ipython interpreter + +ipython + +print range(1,51,2) +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Let us do it in our '''IPython''' interpreter for ease of use. + +The problem can be solved by just using the range() function. + +It can be solved as, print range ''within square brackets ''one coma fifty one coma two + +This time we passed three parameters to range() function unlike the previous case where we passed only two parameters. The first parameter is the starting number of the sequence and the second parameter is the end of the range. + +Note that the sequence does not include the ending number. The third parameter is for stepping through the sequence. + +Here we gave two which means we are skipping every alternate element. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 9 + +Summary +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| This brings us to the end of the tutorial. In this tutorial,we learned to, + +# create blocks in python using '''for loop''' +# indent the blocks of code +# iterate over a list using '''for loop''' +# use the '''range() function''' + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 10 + +Evaluation +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Here are some self assessment questions for you to solve + +# 1. '''Indentation''' is not mandatory in '''Python''' + +* +** True +** False + +# 2. Write a code using '''for loop''' to print the product of all natural numbers from 1 to 20. + +3. What will be the output of - + +range ''within square brackets ''one ''coma ''five + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 11 + +Solutions +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| And the answers, + +# 1. False. Indentation is essential in python. + +2. We use the '''for loop''' in the following manner. + +y = 1 + +for x in range(1,21): + + y*=x + +print y + +# '''range(1, 5)''' will produce a list of integers from 1 to 4. +# <nowiki>[1,2,3,4]</nowiki> + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 12 + +FOSSEE +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| FOSSEE is Free and Open-source Software for Science and Engineering Education. The goal of this project is to enable all to use open source software tools. For more details, please visit the given link. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 13 + +About the Spoken Tutorial Project +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Watch the video available at the following link. It summarizes the Spoken Tutorial project. If you do not have good bandwidth, you can download and watch it. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 14 + +Spoken Tutorial Workshop +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| The Spoken Tutorial Project Team conducts SELF workshops using spoken tutorials, gives certificates to those who pass an online test. For more details, you may write to contact@spoken-tutorial.org + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 15 + +Acknowledgements +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Spoken Tutorial Project is a part of the "Talk to a Teacher" project. It is supported by the National Mission on Education through ICT, MHRD, Government of India. More information on this mission is available at the given link. + + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 16 + +Thank You +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Hope you have enjoyed this tutorial and found it useful. Thank you! + +|} + diff --git a/getting_started_with_for/slides.tex b/getting_started_with_for/slides.tex index 68c6100..b80cd8e 100644 --- a/getting_started_with_for/slides.tex +++ b/getting_started_with_for/slides.tex @@ -1,97 +1,82 @@ -% Created 2011-05-24 Tue 11:11 -\documentclass[presentation]{beamer} +\documentclass[17pt]{beamer} +%\documentclass{beamer} +\usetheme{Madrid} +\useoutertheme{noslidenum} +\setbeamertemplate{navigation symbols}{} +\usepackage{beamerthemesplit} +\usepackage{ae,aecompl} +\usepackage[scaled=.95]{helvet} +\usepackage[english]{babel} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} -\usepackage{fixltx2e} -\usepackage{graphicx} -\usepackage{longtable} -\usepackage{float} -\usepackage{wrapfig} -\usepackage{soul} -\usepackage{textcomp} -\usepackage{marvosym} -\usepackage{wasysym} -\usepackage{latexsym} -\usepackage{amssymb} -\usepackage{hyperref} -\tolerance=1000 -\usepackage[english]{babel} \usepackage{ae,aecompl} -\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet} +\usepackage{mathpazo,courier,euler} \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}} +\lstset{language=sh, + basicstyle=\ttfamily\bfseries, + showstringspaces=false, + keywordstyle=\color{black}\bfseries} + +% theme split +\usepackage{verbatim} +\newenvironment{colorverbatim}[1][]% +{% +\color{blue} +\verbatim +}% +{% +\endverbatim +}% + +\definecolor{NavyBlue}{RGB}{0, 76, 153} +\setbeamercolor{structure}{fg=NavyBlue} +\author[FOSSEE]{} +\institute[IIT Bombay]{} +\date[]{} + +% logo +\logo{\includegraphics[height=1.30cm]{../images/3t-logo.pdf}} +\logo{\includegraphics[height=0.6cm]{../images/fossee-logo.png} + +\hspace{200pt} +\includegraphics[scale=0.5]{../images/fossee-logo.png}\\ +\hspace{275pt} +\includegraphics[scale=0.9]{../images/3t-logo.pdf}} -\title{} -\author{FOSSEE} -\date{} - -\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} \begin{document} - - - - - - - - - - +\sffamily \bfseries +\title +[Getting Started With For Loop] +{Getting Started With For Loop} +\author +[FOSSEE, IIT - Bombay] +{\small Talk to a Teacher\\{\color{blue}\url{http://spoken-tutorial.org}}\\National Mission on Education + through ICT\\{\color{blue}\url{http://sakshat.ac.in}} \\ [0.8cm]Script by: Hardik Ghaghada \\ Narration by: \\ + [0.5cm] +{\small 15 May 2013}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} - -\begin{center} -\vspace{12pt} -\textcolor{blue}{\huge Getting started with \texttt{for}} -\end{center} -\vspace{18pt} -\begin{center} -\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} + \titlepage \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Objectives} -\label{sec-2} - At the end of this tutorial, you will be able to, - \begin{itemize} -\item Write blocks of code in python. -\item Use the ``for`` loop. -\item Use ``range()`` function. -\item Write blocks in python interpreter -\item Write blocks in ipython interpreter. -\end{itemize} -\end{frame} -\begin{frame} -\frametitle{Pre-requisite} -\label{sec-3} - - Spoken tutorial on- - -\begin{itemize} -\item Getting started with Lists +\item Understand indentation in Python +\item Use the for loop +\item Use range() function +\item Write blocks in Python shell +\item Write blocks in IPython interpreter \end{itemize} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile] \frametitle{Whitespace in Python} -\label{sec-4} - - \begin{itemize} \item Whitespace is significant -\begin{itemize} -\item blocks are visually separated -\end{itemize} -\item Blocks are indented using 4 spaces +\item Blocks are conventionally indented using 4 spaces \begin{verbatim} Block A Block A @@ -99,157 +84,136 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} Block B Block A \end{verbatim} - - \verb~Block B~ is an inner block and is indented using 4 spaces \end{itemize} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile] \frametitle{Exercise 1} -\label{sec-5} - Write a \verb~for~ loop which iterates through a list of numbers and find the square root of each number. -\begin{verbatim} - -\end{verbatim} - The numbers are, \begin{verbatim} - 1369, 7225, 3364, 7056, 5625, 729, 7056, + 1369, 7225, 3364, 7056, + 5625, 729, 7056, 576, 2916 \end{verbatim} \end{frame} -\begin{frame}[fragile] -\frametitle{Solution 1} -\label{sec-6} - - -\begin{itemize} -\item Open text editor and type the following code -\lstset{language=Python} -\begin{lstlisting} -numbers = [1369, 7225, 3364, 7056, 5625, 729, 7056, - 576, 2916] - -for each in numbers: - print "Square root of", each, "is", sqrt(each) - -print "This is not in for loop!" -\end{lstlisting} -\end{itemize} -\end{frame} -\begin{frame}[fragile] -\frametitle{Save \& run script} -\label{sec-7} - - -\begin{itemize} -\item Save the script as \verb~list_roots.py~ -\item Run in \verb~ipython~ interpreter as, -\begin{verbatim} - In []: %run -i list_roots.py -\end{verbatim} - -\end{itemize} -\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile] \frametitle{Exercise 2} -\label{sec-8} - Print the square root of numbers in the list. -\begin{verbatim} - -\end{verbatim} - Numbers are, \begin{verbatim} - 7225, 3268, 3364, 2966, 7056, 5625, 729, 5547, - 7056, 576, 2916 +7225, 3268, 3364, 2966, 7056, +5625, 729, 5547, 7056, 576, 2916 \end{verbatim} +\emph{do it in the ipython interpreter} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile] \frametitle{Exercise 3} -\label{sec-9} - - Find out the cube of all the numbers from 1 to 10. -\begin{verbatim} - -\end{verbatim} - - \emph{do it in the python interpreter} + Find out the cube of all the numbers from 1 to 10. \\ + \emph{do it in the python shell} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{\verb~range()~ function} -\label{sec-10} - - -\begin{itemize} -\item in built function in Python -\item generates a list of integers -\begin{itemize} -\item \emph{syntax:} range([start,] stop[, step]) -\item \emph{example:} -\begin{itemize} -\item range(1, 20) - \emph{generates integers from 1 to 20} -\item range(20) - \emph{generates integers from 0 to 20} -\end{itemize} -\end{itemize} -\end{itemize} + \begin{itemize} + \item built in function in Python + \item generates a list of integers + \begin{itemize} + \item \emph{syntax:} range([start,] stop[, step]) + \item \emph{example:} + \begin{itemize} + \item range(1, 20) - \emph{generates integers from 1 to 20} + \item range(20) - \emph{generates integers from 0 to 20} + \end{itemize} + \end{itemize} + \end{itemize} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Exercise 4} -\label{sec-11} - Print all the odd numbers from 1 to 50. \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Summary} -\label{sec-12} - In this tutorial,we learnt to, - \begin{itemize} -\item Create blocks in python using ``for +\item Create blocks in python using ``for'' \item Indent the blocks of code -\item Iterate over a list using ``for`` loop -\item Use the ``range()`` function +\item Iterate over a list using ``for'' loop +\item Use the ``range()'' function \end{itemize} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Evaluation} -\label{sec-13} - - \begin{enumerate} -\item Indentation is not mandatory in Python -\begin{itemize} -\item True -\item False -\end{itemize} -\vspace{8pt} -\item Write a code using ``for`` loop to print the product of all natural numbers from 1 to 20. -\vspace{8pt} -\item What will be the output of- - range(1,5) + \item Indentation is not mandatory in Python + \begin{itemize} + \item True + \item False + \end{itemize} + \vspace{8pt} + \item Write a ``for'' loop to print the product of all natural numbers from 1 to 20 + \vspace{8pt} + \item What will be the output of-range(1,5) \end{enumerate} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Solutions} -\label{sec-14} - - \begin{enumerate} -\item False -\vspace{8pt} -\item y = 1\\ -for x in range(1,21):\\ -\hspace{12pt} - y*=x\\ - print y -\vspace{8pt} -\item {[1,2,3,4]} + \item False + \vspace{8pt} + \item y = 1\\ + for x in range(1,21):\\ + \hspace{12pt} + y*=x\\ + print y + \vspace{8pt} + \item {[1,2,3,4]} \end{enumerate} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{FOSSEE} +{\color{NavyBlue}Free and Open Source Software for \\Education} \\ +\begin{itemize} +\item To enable the use of free and open source software tools +\item For more details, please visit: {\color{blue}\url{http://fossee.in/}} +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{About the Spoken Tutorial Project} +\begin{itemize} +\item Watch the video available at {\color{blue}\url{http://spoken-tutorial.org /What\_is\_a\_Spoken\_Tutorial}} +\item It summarises the Spoken Tutorial project +\item If you do not have good bandwidth, you can download and watch it +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Spoken Tutorial Workshops}The Spoken Tutorial Project Team +\begin{itemize} +\item Conducts workshops using spoken tutorials +\item Gives certificates to those who pass an online test +\item For more details, please write to \\ \hspace {0.5cm}{\color{blue}contact@spoken-tutorial.org} +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Acknowledgements} +\begin{itemize} +\item Spoken Tutorial Project is a part of the Talk to a Teacher project +\item Supported by the National Mission on Education through ICT, MHRD, Government of India +\item More information: \\{\color{blue}\url{http://spoken-tutorial.org/NMEICT-Intro}} +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \begin{block}{} @@ -260,9 +224,9 @@ for x in range(1,21):\\ \begin{block}{} \begin{center} For more Information, visit our website\\ - \url{http://fossee.in/} + {\color{blue}\url{http://fossee.in/}} \end{center} \end{block} \end{frame} - -\end{document}
\ No newline at end of file +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\end{document} diff --git a/getting_started_with_lists/script.odt b/getting_started_with_lists/script.odt Binary files differnew file mode 100644 index 0000000..065a8d2 --- /dev/null +++ b/getting_started_with_lists/script.odt diff --git a/getting_started_with_lists/script.rst b/getting_started_with_lists/script.rst index d3d528e..43bb612 100644 --- a/getting_started_with_lists/script.rst +++ b/getting_started_with_lists/script.rst @@ -1,58 +1,32 @@ -.. 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 : - Language Reviewer : Bhanukiran - Checklist OK? : <12-11-2010, Anand, OK> [2010-10-05] - - Script ------ .. L1 -{{{ Show the first slide containing title, name of the production -team along with the logo of MHRD }}} +{{{ Show the Title slide }}} .. R1 Hello friends and welcome to the tutorial on "Getting started with -lists". +Lists". .. L2 -{{{ Show slide with objectives }}} +{{{ Show 'objectives' slide }}} .. R2 -In this tutorial we will be getting acquainted with a python data -structure called lists. At the end of this tutorial, you will be able to, 1. Create lists #. Access list elements #. Append elements to lists #. Delete elements from lists + #. Find length of the lists + +.. L3 + +{{{ Show 'Lists' slide }}} .. R3 @@ -60,37 +34,38 @@ 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. +.. L4 -.. L3 -:: - ipython empty = [] type(empty) .. R4 - -This is an empty list without any elements. -Lets define a non-empty list as: +Let us start the IPython interpreter and creat an empty list. So, type on the +terminal ipython. Now, to create an empty list we say empty is equal to empty +square brackets. Remember that 'empty' is just a name of the list, we could give +any name required. Further, let us check the data type of the 'empty'. For this +we say, type(empty) and hitenter. As we can see 'empty' variable is of type +list. -.. L4 -:: +.. L5 +:: nonempty = ['spam', 'eggs', 100, 1.234] .. R5 + +That was about empty list. Now, let us define a non-empty list with some +elements in it. So, we say, nonempty is equal to within square brackets in +single quotes spam coma in single quotes eggs coma hundred coma one point two +three four. + -Thus, the simplest way of creating a list is typing out a sequence -of comma-separated values (or items) between two square brackets. +.. L4 + +.. R5 -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. Let us include a list within a list. diff --git a/getting_started_with_lists/script.txt b/getting_started_with_lists/script.txt new file mode 100644 index 0000000..825da3a --- /dev/null +++ b/getting_started_with_lists/script.txt @@ -0,0 +1,230 @@ + +{| style="border-spacing:0;" +| style="border-top:0.05pt double #808080;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| <center>'''Visual Cue'''</center> +| style="border:0.05pt double #808080;padding:0.049cm;"| <center>'''Narration'''</center> + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 1 + +Title Slide +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Hello friends and welcome to the tutorial on "Getting started with lists". + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 2 + +Objectives +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| In this tutorial we will be getting acquainted with a python data structure called lists. At the end of this tutorial, you will be able to, + +# Create lists +# Access list elements +# Append elements to lists +# Delete elements from lists +# Find out length of lists + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 3 + +Lists +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| List is a compound data type, it can contain data of mutually different data types. List is also a sequence data type where all the elements are arranged in a specific order. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| ipython + +<nowiki>empty = []</nowiki> + +type(empty) +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Lets start with creating an empty list. So, start the ipython interpreter and first create an empty list with no elements. Go to the '''terminal''', type '''ipython''' and hit enter. Now, to create an empty list we say '''empty''' ''is equal to empty square brackets''. Note that '''empty''' is just a name of the variable. To check the type of the variable '''empty''' we say type ''within round brackets'' name of the variable which in our case is '''empty'''''.'' As you can see the type is '''list''' + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| <nowiki>nonempty = ['spam', 'eggs', 100, 1.234]</nowiki> +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| That was about creating an empty list. Now, lets create a non empty list with some values in it. So, we say '''nonempty''''' is equal to within square brackets, in single quotes'' '''spam''' coma ''in single quotes'' '''eggs''' coma hundred coma one point two three four. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| <nowiki>listinlist=[[4,2,3,4],'and', 1, 2, 3, 4]</nowiki> +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Thus, the simplest way of creating a list is typing out a sequence 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''' is '''integer''' and '''float''' respectively. Thus, we can put elements of different data types in lists including lists itself. This property makes lists heterogeneous data structures. + +Let us include a list within a list. So, type '''listiinlist''' ''is equal to within square brackets opening sqare bracket'' four coma two coma three coma four ''closing square bracket'' coma ''in single quotes'' '''and''' coma one coma two coma three coma four + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| <nowiki>nonempty[0]</nowiki> + +<nowiki>nonempty[1]</nowiki> + +<nowiki>nonempty[3]</nowiki> +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| We can access an element of a list using its corresponding index. Index of the first element of a list is 0. So for the list nonempty, '''nonempty '''''within square brackets'' zero gives the first element, '''nonempty''' ''within square brackets one ''gives the second element and so on. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 4 + +Excercise 1 +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Pause the video here, try out the following exercise and resume the video. + +What happens when you do '''nonempty '''''within square brackets minus ''one. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Switch to the terminal + +<nowiki>nonempty[-1]</nowiki> +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| As you can see you get the last element which is 1.234. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| <nowiki>nonempty[-2]</nowiki> + +<nowiki>nonempty[-4]</nowiki> +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| 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. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| nonempty.append('onemore') + +nonempty + +nonempty.append(6) + +nonempty +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| We can also append elements to the end of a list using the ''append'' function. So, type '''nonempty''' ''dot append within round brackets in single quotes'' '''onemore'''. Then type '''nonempty''', as you can see the element '''onemore''' has been appended to the list. Type '''nonempty''' ''within square brackets'' '''six'''. Type '''nonempety '''and you can see '''six''' is appended to the list. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 5 + +Exercise 2 +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Please, pause the video here. Do the following exercise and then continue. + +# What is the syntax to get the element ''''and'''' in the list, '''listinlist'' '''''? +# How would you get ''''and'''' using negative indices? + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 6 + +Solution 2 +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| The solution is on your screen + +To get the element ''''''''and'''''''' from the list '''listlinlist''''' ''se say '''listinlist''''' within square brackets'' '''one'''. Next, to access the element ''''''''and'''''' ''using negative index, we say '''listinlist''''' within square brackets'' minus five + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| <nowiki>del(nonempty[1])</nowiki> +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| 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. We can use the '''del''' function to do this. So, type '''del''' ''within round brackets'' '''nonempty''' within ''square brackets'' '''one'''. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| nonempty.remove(100) +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| The function '''del''' deletes the element at index one, i.e the second element of the list which is ''''eggs''''. + +The other way is removing element is by content. Lets say one wishes to delete 100 from nonempty list. For this, one could use the function remove. So, type '''nonempty''' ''dot'' '''remove''' ''within round brackets'' hundred. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| nonempty.append('spam') + +nonempty + +nonempty.remove('spam') + +nonempty +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| But what if there were two 100's. To check that lets do a small experiment. We add one more element ''''spam'''' to our list '''nonempty'''. To do this we say '''nonempty''' ''dot'' '''append''' ''within round brackets'' in ''single quotes'' '''spam'''. Now, we remove the element '''spam''' using the '''remove''' function. If we now check, we will see that the first occurrence ''''spam'''' is removed and therefore the function '''remove''''' ''removes the first occurrence 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. + + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 7 + +Exercise 3 +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Pause the video here, try out the following exercise and resume the video. + +# Remove the third element from the list, '''listinlist'''. +# Remove 'and' from the list, '''listinlist'''. + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 8 + +Solution 3 +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| The solution is on your screen. + +'''Del '''''within round brackets '''''listinlist '''''within square brackets '''''two, '''this will remove the third element from the list '''listinlist. '''To remove the element '''and '''you can do '''listinlist '''''dot '''''remove '''''within round brackets in single quotes '''''and''' + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| len(nonempty) +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| 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''''. Type '''len''' ''withing round brackets'' '''nonempty'''. It returns the number of elements in the list nonempty. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 9 + +Summary +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| This brings us to the end of this tutorial. In this tutorial, we have learnt to, + +# Create lists. +# Access lists using their index numbers. +# Append elements to list using the function '''append'''. +# Delete Element from lists by specifying the index number of the element to be deleted in the '''del''' function. +# Delete element from list by content using '''remove''' function. +# Find out the list length using '''len''' function. + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 10 + +Evaluation +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Here are some self assessment questions for you to solve + +# How do you create an empty list ? +# Can you have a list inside a list ? +# How would you access the end of a list without finding its length? + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 11 + +Solutions +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| And the answers, + +# We create an empty list just by leaving the space inside the square brackets empty.'''Empty''' ''is equal to empty square brackets''. +# +# Yes. List can contain all the other data types, including list. +# +# We can access the last element of the list without knowing its length using negative indices. + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 12
+ +FOSSEE
+| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| FOSSEE is Free and Open-source Software for Science and Engineering Education. The goal of
this project is to enable all to use open source
software tools. For more details, please visit the
given link.
+ +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 13 + +About the Spoken Tutorial Project +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Watch the video available at the following link. It summarizes the Spoken Tutorial project. If you do
not have good bandwidth, you can download and
watch it. + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 14 + +Spoken Tutorial Workshop +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| The Spoken Tutorial Project Team conducts
SELF workshops using spoken tutorials, gives
certificates to those who pass an online test.
For more details, you may write to contact@spoken-tutorial.org + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 15 + +Acknowledgements +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Spoken Tutorial Project is a part of the "Talk to a
Teacher" project. It is supported by the National
Mission on Education through ICT, MHRD,
Government of India. More information on this
mission is available at the given link.
+ + + + +|- +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:none;padding:0.049cm;"| Show Slide 16 + +Thank You +| style="border-top:none;border-bottom:0.05pt double #808080;border-left:0.05pt double #808080;border-right:0.05pt double #808080;padding:0.049cm;"| Hope you have enjoyed this tutorial and found it
useful. Thank you! + +|} + diff --git a/getting_started_with_lists/slides.tex b/getting_started_with_lists/slides.tex index 01f8b10..c705a4c 100644 --- a/getting_started_with_lists/slides.tex +++ b/getting_started_with_lists/slides.tex @@ -1,70 +1,68 @@ -% Created 2011-05-24 Tue 09:52 -\documentclass[presentation]{beamer} -\usepackage[utf8]{inputenc} +\documentclass[17pt]{beamer} +%\documentclass{beamer} +\usetheme{Madrid} +\useoutertheme{noslidenum} +\setbeamertemplate{navigation symbols}{} +\usepackage{beamerthemesplit} +\usepackage{ae,aecompl} +\usepackage[scaled=.95]{helvet} +\usepackage[english]{babel} +\usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} -\usepackage{fixltx2e} -\usepackage{graphicx} -\usepackage{longtable} -\usepackage{float} -\usepackage{wrapfig} -\usepackage{soul} -\usepackage{textcomp} -\usepackage{marvosym} -\usepackage{wasysym} -\usepackage{latexsym} -\usepackage{amssymb} -\usepackage{hyperref} -\tolerance=1000 -\usepackage[english]{babel} \usepackage{ae,aecompl} -\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet} +\usepackage{mathpazo,courier,euler} \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}} +\lstset{language=sh, + basicstyle=\ttfamily\bfseries, + showstringspaces=false, + keywordstyle=\color{black}\bfseries} + +% theme split +\usepackage{verbatim} +\newenvironment{colorverbatim}[1][]% +{% +\color{blue} +\verbatim +}% +{% +\endverbatim +}% + +\definecolor{NavyBlue}{RGB}{0, 76, 153} +\setbeamercolor{structure}{fg=NavyBlue} +\author[FOSSEE]{} +\institute[IIT Bombay]{} +\date[]{} + +% logo +\logo{\includegraphics[height=1.30cm]{../images/3t-logo.pdf}} +\logo{\includegraphics[height=0.6cm]{../images/fossee-logo.png} + +\hspace{200pt} +\includegraphics[scale=0.5]{../images/fossee-logo.png}\\ +\hspace{275pt} +\includegraphics[scale=0.9]{../images/3t-logo.pdf}} -\title{} -\author{FOSSEE} -\date{2010-09-14 Tue} - -\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} \begin{document} - - - - - - - - - - - +\sffamily \bfseries +\title +[Getting Started With Lists] +{Getting Started With Lists} +\author +[FOSSEE, IIT - Bombay] +{\small Talk to a Teacher\\{\color{blue}\url{http://spoken-tutorial.org}}\\National Mission on Education + through ICT\\{\color{blue}\url{http://sakshat.ac.in}} \\ [0.8cm]Script by: Hardik Ghaghada \\ Narration by: \\ + [0.5cm] +{\small 15 May 2013}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} - -\begin{center} -\vspace{12pt} -\textcolor{blue}{\huge Getting started with Lists} -\end{center} -\vspace{18pt} -\begin{center} -\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} + \titlepage \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Objectives} -\label{sec-2} - At the end of this tutorial, you will be able to, - \begin{itemize} \item Create lists \item Access list elements @@ -72,108 +70,130 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} \item Delete elements from lists \end{itemize} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Lists} +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. +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Exercise 1} -\label{sec-3} - - \begin{itemize} \item What happens when you do nonempty[-1]. \end{itemize} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Exercise 2} -\label{sec-4} - - \begin{itemize} \item What is the syntax to get the element `and' in the list,listinlist ? \item How would you get `and' using negative indices? \end{itemize} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame}[fragile] \frametitle{Solution 2} -\label{sec-5} - - \lstset{language=Python} \begin{lstlisting} - listinlist[1] listinlist[-5] \end{lstlisting} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Exercise 3} -\label{sec-6} - - - \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{Solution 3} -\label{sec-7} - \lstset{language=Python} \begin{lstlisting} - del(listinlist[2]) listinlist.remove('and') \end{lstlisting} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Summary} + In this tutorial we have learnt how to, + \begin{itemize} + \item Create lists + \item Access elements + \item Use ``append'' function + \item Use ``del'' function + \item Use ``remove'' function. + \item Use ``len'' function. + \end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Evaluation} + \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 last element of a list without finding its length? + \end{enumerate} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Solutions} + \begin{enumerate} + \item empty=[] + \vspace{8pt} + \item Yes we can have list inside list\\ + \vspace{8pt} + \item Use negative index to access the last element of the list + \end{enumerate} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{Summary} -\label{sec-8} - - In this tutorial, we have learnt to – - +\frametitle{FOSSEE} +{\color{NavyBlue}Free and Open Source Software for \\Education} \\ \begin{itemize} -\item Create lists. -\item Access lists using their index numbers. -\item Append elements to list using the function ``append``. -\item Delete Element from lists by specifying the index number of the - element to be deleted in the ``del`` function. -\item Delete element from list by content using ``remove`` function. -\item Find out the list length using the ``len`` function. +\item To enable the use of free and open source software tools +\item For more details, please visit: {\color{blue}\url{http://fossee.in/}} \end{itemize} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{Evaluation} -\label{sec-9} - - -\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} +\frametitle{About the Spoken Tutorial Project} +\begin{itemize} +\item Watch the video available at {\color{blue}\url{http://spoken-tutorial.org /What\_is\_a\_Spoken\_Tutorial}} +\item It summarises the Spoken Tutorial project +\item If you do not have good bandwidth, you can download and watch it +\end{itemize} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} -\frametitle{Solutions} -\label{sec-10} - - -\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} +\frametitle{Spoken Tutorial Workshops}The Spoken Tutorial Project Team +\begin{itemize} +\item Conducts workshops using spoken tutorials +\item Gives certificates to those who pass an online test +\item For more details, please write to \\ \hspace {0.5cm}{\color{blue}contact@spoken-tutorial.org} +\end{itemize} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} +\frametitle{Acknowledgements} +\begin{itemize} +\item Spoken Tutorial Project is a part of the Talk to a Teacher project +\item Supported by the National Mission on Education through ICT, MHRD, Government of India +\item More information: \\{\color{blue}\url{http://spoken-tutorial.org/NMEICT-Intro}} +\end{itemize} \end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} - \begin{block}{} + \begin{block}{} \begin{center} \textcolor{blue}{\Large THANK YOU!} \end{center} @@ -181,9 +201,9 @@ nonempty = ['spam', `eggs', 100, 1.234]\\ \begin{block}{} \begin{center} For more Information, visit our website\\ - \url{http://fossee.in/} + {\color{blue}\url{http://fossee.in/}} \end{center} \end{block} \end{frame} - +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \end{document} |