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):