diff options
author | Jovina | 2011-05-25 16:29:48 +0530 |
---|---|---|
committer | Jovina | 2011-05-25 16:29:48 +0530 |
commit | 58cdb783e3e48d859cbc776373da257bf7b22cbe (patch) | |
tree | 2add894bf98e308e2080221e5dec8b2bb82f16e9 /getting_started_with_for | |
parent | 37051a2dc7b8c0cd47f2e91391612887c0f1adb9 (diff) | |
download | st-scripts-58cdb783e3e48d859cbc776373da257bf7b22cbe.tar.gz st-scripts-58cdb783e3e48d859cbc776373da257bf7b22cbe.tar.bz2 st-scripts-58cdb783e3e48d859cbc776373da257bf7b22cbe.zip |
Modified the scripts and slides in module 2.
Diffstat (limited to 'getting_started_with_for')
-rw-r--r-- | getting_started_with_for/script.rst | 21 | ||||
-rw-r--r-- | getting_started_with_for/slides.org | 29 | ||||
-rw-r--r-- | getting_started_with_for/slides.tex | 89 |
3 files changed, 103 insertions, 36 deletions
diff --git a/getting_started_with_for/script.rst b/getting_started_with_for/script.rst index 304cbe5..c3eecc1 100644 --- a/getting_started_with_for/script.rst +++ b/getting_started_with_for/script.rst @@ -55,14 +55,20 @@ At the end of this tutorial, you will be able to, .. L3 +{{{ Show slide with pre-requisite }}} + {{{ switch to next slide, 'Whitespace in python' }}} .. R3 +Before beginning this tutorial,we would suggest you to complete the +tutorial on "Getting started with Lists". + In Python whitespace is significant, and the blocks are visually separated.The best practice 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. +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. @@ -83,7 +89,7 @@ Now let us move straight into ``for`` loop. .. L6 -{{{ switch to slide showing Question 1 }}} +{{{ switch to slide showing exercise 1 }}} .. R6 @@ -96,7 +102,8 @@ numbers are 1369, 7225, 3364, 7056, 5625, 729, 7056, 576, 2916 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. And let us create a script, rather than typing it out in the -interpreter itself. Open your text editor and type the following code shown on the slide. +interpreter itself. Open your text editor and type the following code +shown on the slide. .. L7 @@ -156,7 +163,7 @@ white-spaces in Python. .. L13 -{{{ switch to slide showing Question 2 }}} +{{{ switch to slide showing exercise 2 }}} .. R13 @@ -220,7 +227,7 @@ number in the list, which was executed in the ``for`` loop. .. L19 -{{{ switch to slide Question 3 }}} +{{{ switch to slide exercise 3 }}} .. R19 @@ -289,7 +296,7 @@ specify will not be included in the ``list``. .. L25 -{{{ switch to next slide Question 4 }}} +{{{ switch to next slide exercise 4 }}} .. R25 @@ -386,6 +393,6 @@ And the answers, .. R31 -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_for/slides.org b/getting_started_with_for/slides.org index f922baa..aafe1bb 100644 --- a/getting_started_with_for/slides.org +++ b/getting_started_with_for/slides.org @@ -54,6 +54,9 @@ - Use ``range()`` function. - Write blocks in python interpreter - Write blocks in ipython interpreter. +* Pre-requisite + Spoken tutorial on- + - Getting started with Lists * Whitespace in Python - Whitespace is significant - blocks are visually separated @@ -64,7 +67,7 @@ : Block B : Block A ~Block B~ is an inner block and is indented using 4 spaces -* Question 1 +* Exercise 1 Write a ~for~ loop which iterates through a list of numbers and find the square root of each number. : @@ -86,13 +89,13 @@ - Save the script as ~list_roots.py~ - Run in ~ipython~ interpreter as, : In []: %run -i list_roots.py -* Question 2 +* Exercise 2 Print the square root of numbers in the list. : Numbers are, : 7225, 3268, 3364, 2966, 7056, 5625, 729, 5547, : 7056, 576, 2916 -* Question 3 +* Exercise 3 Find out the cube of all the numbers from 1 to 10. : /do it in the python interpreter/ @@ -103,7 +106,7 @@ - /example:/ - range(1, 20) - /generates integers from 1 to 20/ - range(20) - /generates integers from 0 to 20/ -* Question 4 +* Exercise 4 Print all the odd numbers from 1 to 50. * Summary In this tutorial,we learnt to, @@ -117,6 +120,7 @@ - True - False + 2. Write a code using ``for`` loop to print the product of all natural numbers from 1 to 20. @@ -124,14 +128,21 @@ 3. What will be the output of- range(1,5) * Solutions - 1. False + - False + - 2. y = 1 - for x in range(1,21): - y*=x + - y = 1\\ + for x in range(1,21):\\ + y*=x\\ print y + + + - + #+ begin_src python + [1,2,3,4] + #+ end_src + - 3. [1,2,3,4] * #+begin_latex \begin{block}{} diff --git a/getting_started_with_for/slides.tex b/getting_started_with_for/slides.tex index d8706fc..68c6100 100644 --- a/getting_started_with_for/slides.tex +++ b/getting_started_with_for/slides.tex @@ -1,4 +1,4 @@ -% Created 2011-05-13 Fri 12:39 +% Created 2011-05-24 Tue 11:11 \documentclass[presentation]{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} @@ -43,14 +43,18 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} \begin{frame} \begin{center} -\textcolor{blue}{Getting started -- \texttt{for}} +\vspace{12pt} +\textcolor{blue}{\huge Getting started with \texttt{for}} \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} @@ -67,9 +71,19 @@ MHRD, Govt. of India \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 +\end{itemize} +\end{frame} \begin{frame}[fragile] \frametitle{Whitespace in Python} -\label{sec-3} +\label{sec-4} \begin{itemize} @@ -90,8 +104,8 @@ MHRD, Govt. of India \end{itemize} \end{frame} \begin{frame}[fragile] -\frametitle{Question 1} -\label{sec-4} +\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. @@ -107,7 +121,7 @@ MHRD, Govt. of India \end{frame} \begin{frame}[fragile] \frametitle{Solution 1} -\label{sec-5} +\label{sec-6} \begin{itemize} @@ -126,7 +140,7 @@ print "This is not in for loop!" \end{frame} \begin{frame}[fragile] \frametitle{Save \& run script} -\label{sec-6} +\label{sec-7} \begin{itemize} @@ -139,8 +153,8 @@ print "This is not in for loop!" \end{itemize} \end{frame} \begin{frame}[fragile] -\frametitle{Question 2} -\label{sec-7} +\frametitle{Exercise 2} +\label{sec-8} Print the square root of numbers in the list. \begin{verbatim} @@ -154,8 +168,8 @@ print "This is not in for loop!" \end{verbatim} \end{frame} \begin{frame}[fragile] -\frametitle{Question 3} -\label{sec-8} +\frametitle{Exercise 3} +\label{sec-9} Find out the cube of all the numbers from 1 to 10. \begin{verbatim} @@ -166,7 +180,7 @@ print "This is not in for loop!" \end{frame} \begin{frame} \frametitle{\verb~range()~ function} -\label{sec-9} +\label{sec-10} \begin{itemize} @@ -183,14 +197,14 @@ print "This is not in for loop!" \end{itemize} \end{frame} \begin{frame} -\frametitle{Question 4} -\label{sec-10} +\frametitle{Exercise 4} +\label{sec-11} Print all the odd numbers from 1 to 50. \end{frame} \begin{frame} \frametitle{Summary} -\label{sec-11} +\label{sec-12} In this tutorial,we learnt to, @@ -202,6 +216,41 @@ print "This is not in for loop!" \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) +\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]} +\end{enumerate} +\end{frame} +\begin{frame} \begin{block}{} \begin{center} |