diff options
Diffstat (limited to 'loops/script.rst')
-rw-r--r-- | loops/script.rst | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/loops/script.rst b/loops/script.rst index 131dcb8..0c1c886 100644 --- a/loops/script.rst +++ b/loops/script.rst @@ -1,12 +1,34 @@ -======== - Script -======== +.. Objectives +.. ---------- -{{{ show the welcome slide }}} +.. By the end of this tutorial, you will be able to -Welcome this tutorial on loops in Python. +.. 1. use the ``for`` loop +.. #. use the ``while`` loop +.. #. Use ``break``, ``continue`` and ``pass`` statements to play around +.. with loops. -{{{ show the outline slide }}} +.. Prerequisites +.. ------------- + +.. 1. getting started with ipython +.. #. getting started with for +.. #. conditionals + + +.. Author : + Internal Reviewer : + External Reviewer : + Checklist OK? : <put date stamp here, if OK> [2010-10-05] + +Script +------ + +{{{ Show the slide containing title }}} + +Hello Friends. Welcome this tutorial on loops in Python. + +{{{ Show the outline slide }}} In this tutorial, we shall look at ``while`` and ``for`` loops. We shall then look at the ``break``, ``continue`` and ``pass`` keywords @@ -38,8 +60,12 @@ executes the block of code within the loop, if it is. As with any other block in Python, the code within the ``while`` block is indented to the right by 4 spaces. -E%% %% Pause the video here and write a ``while`` loop to print the -squares of all the even numbers below 10. Then, return to the video. +Following is an exercise that you must do. + +%%1%% Write a ``while`` loop to print the squares of all the even +numbers below 10. Then, return to the video. + +Please, pause the video here. Do the exercise and then continue. :: @@ -60,9 +86,13 @@ then iterate over it and print the required stuff. for n in range(1, 10, 2): print n*n -E%% %% Pause the video here and write a ``for`` loop to print the +Following is an exercise that you must do. + +%%2%% Pause the video here and write a ``for`` loop to print the squares of all the even numbers below 10. Then, return to the video. +Please, pause the video here. Do the exercise and then continue. + :: for n in range(2, 10, 2): @@ -106,10 +136,13 @@ which are not multiples of 3, we would modify the for loop as follows. print n*n -E%% %%Pause the video here and 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.) Then, resume the video. +Following is an exercise that you must do. + +%%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.) + +Please, pause the video here. Do the exercise and then continue. :: for n in range(2, 10, 2): @@ -117,8 +150,15 @@ function call.) Then, resume the video. continue print n*n +{{{ Show summary slide }}} + That brings us to the end of this tutorial. In this tutorial, we have learnt about looping structures in Python and the use of the keywords ``pass``, ``break`` and ``continue``. -Thank You! +{{{ Show the "sponsored by FOSSEE" slide }}} + +This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India + +Hope you have enjoyed and found it useful. +Thank you! |