# HG changeset patch # User Anoop Jacob Thomas # Date 1288187528 -19800 # Node ID 0fbe8a18587f575ff7731c54aacdf9e5d6ba87d6 # Parent 91d16630c90fb35f295c4c37da26067d2fb322a7 reviewed the script loops. diff -r 91d16630c90f -r 0fbe8a18587f loops/script.rst --- a/loops/script.rst Wed Oct 27 16:57:45 2010 +0530 +++ b/loops/script.rst Wed Oct 27 19:22:08 2010 +0530 @@ -16,8 +16,8 @@ .. #. conditionals -.. Author : - Internal Reviewer : +.. Author : Puneeth + Internal Reviewer : Anoop Jacob Thomas External Reviewer : Checklist OK? : [2010-10-05] @@ -26,7 +26,7 @@ {{{ Show the slide containing title }}} -Hello Friends. Welcome this tutorial on loops in Python. +Hello Friends. Welcome to the tutorial on loops in Python. {{{ Show the outline slide }}} @@ -34,6 +34,13 @@ shall then look at the ``break``, ``continue`` and ``pass`` keywords and how to use them. +.. #[[Anoop: for loop is a pre-requisite and has been already covered, + so i think our emphasize can be on while loops]] + +.. #[[Anoop: Instead of saying we will learn keywords pass, break and + continue, I think it is better to tell them that we will learn more + about loops]] + {{{ switch to the ipython terminal }}} We have an ``ipython`` terminal, that we shall use through out this @@ -60,6 +67,8 @@ other block in Python, the code within the ``while`` block is indented to the right by 4 spaces. +{{{ switch to next slide }}} + Following is an exercise that you must do. %%1%% Write a ``while`` loop to print the squares of all the even @@ -67,6 +76,8 @@ Please, pause the video here. Do the exercise and then continue. +{{{ switch to next slide after a seconds break}}} + :: i = 2 @@ -88,11 +99,15 @@ Following is an exercise that you must do. +{{{ switch to next slide }}} + %%2%% Write a ``for`` loop to print the squares of all the even numbers below 10. Please, pause the video here. Do the exercise and then continue. +{{{ switch to next slide after a seconds break }}} + :: for n in range(2, 10, 2): @@ -126,6 +141,8 @@ ``continue`` is used to skip execution of the rest of the loop on this iteration and continue to the end of this iteration. +.. #[[Anoop: should add slides for break, continue, pass]] + Say, we wish to print the squares of all the odd numbers below 10, which are not multiples of 3, we would modify the for loop as follows. :: @@ -138,11 +155,19 @@ Following is an exercise that you must do. +{{{ switch to next slide }}} + %%3%%Using the ``continue`` keyword modify the ``for`` loop to print the squares of even numbers below 10, to print the squares of only multiples of 4. (Do not modify the range function call.) +.. #[[Anoop: can you be more explicit/specific on do no modify say we + can ask them to use range(2, 10, 2) and solve the problem]] + Please, pause the video here. Do the exercise and then continue. + +{{{ switch to next slide after a seconds break}}} + :: for n in range(2, 10, 2): diff -r 91d16630c90f -r 0fbe8a18587f loops/slides.tex --- a/loops/slides.tex Wed Oct 27 16:57:45 2010 +0530 +++ b/loops/slides.tex Wed Oct 27 19:22:08 2010 +0530 @@ -1,4 +1,4 @@ -% Created 2010-10-10 Sun 21:15 +% Created 2010-10-27 Wed 17:51 \documentclass[presentation]{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} @@ -8,6 +8,7 @@ \usepackage{float} \usepackage{wrapfig} \usepackage{soul} +\usepackage{t1enc} \usepackage{textcomp} \usepackage{marvosym} \usepackage{wasysym} @@ -62,14 +63,13 @@ \frametitle{Solution 1} \label{sec-3} -\lstset{language=Python} -\begin{lstlisting} +\begin{verbatim} In []: i = 2 In []: while i<10: ....: print i*i ....: i += 2 -\end{lstlisting} +\end{verbatim} \end{frame} \begin{frame} \frametitle{Question 2} @@ -82,11 +82,10 @@ \frametitle{Solution 2} \label{sec-5} -\lstset{language=Python} -\begin{lstlisting} +\begin{verbatim} In []: for n in range(2, 10, 2): ....: print n*n -\end{lstlisting} +\end{verbatim} \end{frame} \begin{frame} \frametitle{Question 3} @@ -100,13 +99,12 @@ \frametitle{Solution 3} \label{sec-7} -\lstset{language=Python} -\begin{lstlisting} +\begin{verbatim} for n in range(2, 10, 2): if n%4: continue print n*n -\end{lstlisting} +\end{verbatim} \end{frame} \begin{frame} \frametitle{Summary} diff -r 91d16630c90f -r 0fbe8a18587f progress.org --- a/progress.org Wed Oct 27 16:57:45 2010 +0530 +++ b/progress.org Wed Oct 27 19:22:08 2010 +0530 @@ -36,7 +36,7 @@ | 6.1 LO: | basic datatypes & operators | 4 | Amit | Punch (Done) | | | 6.2 LO: | I/O | 1 | Nishanth | | | | 6.3 LO: | conditionals | 2 | Madhu | | | -| 6.4 LO: | loops | 2 | Puneeth | Anoop(Pending) | | +| 6.4 LO: | loops | 2 | Puneeth | Anoop(Done) | | | 6.5 LO: | Assessment | 3 | Anoop | | | |---------+----------------------------------------+-------+----------+---------------------------------------+-----------| | 7.1 LO: | manipulating lists | 3 | Madhu | | |