getting-started-with-for/script.rst
changeset 521 88a01948450d
parent 474 f137f3e036d9
equal deleted inserted replaced
520:8249ae9d570a 521:88a01948450d
    20      
    20      
    21 .. Author              : Anoop Jacob Thomas <anoop@fossee.in>
    21 .. Author              : Anoop Jacob Thomas <anoop@fossee.in>
    22    Internal Reviewer   : Nishanth
    22    Internal Reviewer   : Nishanth
    23    Internal Reviewer(2): Amit
    23    Internal Reviewer(2): Amit
    24    External Reviewer   :
    24    External Reviewer   :
    25    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    25    Language Reviewer   : Bhanukiran
       
    26    Checklist OK?       : <10-11-2010, Anand, OK> [2010-10-05]
    26 
    27 
    27 
    28 
    28 =============================
    29 =============================
    29 Getting started with for loop
    30 Getting started with for loop
    30 =============================
    31 =============================
    31 
    32 
    32 {{{ show welcome slide }}}
    33 {{{ show welcome slide }}}
    33 
    34 
    34 Hello and welcome to the tutorial getting started with ``for`` loop. 
    35 Hello and welcome to the tutorial `Getting started with ``for`` loop`. 
    35 
    36 
    36 {{{ switch to next slide, outline slide }}}
    37 {{{ switch to next slide, outline slide }}}
    37 
    38 
    38 In this tutorial we will learn about ``for`` loops in python, and also
    39 In this tutorial we will learn about ``for`` loops in python, and also
    39 learn how to write blocks of code in Python.
    40 learn how to write blocks of code in Python.
   154 
   155 
   155 {{{ highlight the fourth line - the line just after for loop }}}
   156 {{{ highlight the fourth line - the line just after for loop }}}
   156 
   157 
   157 it means that it is not part of the ``for`` loop and the lines after
   158 it means that it is not part of the ``for`` loop and the lines after
   158 that doesn't fall in the scope of the ``for`` loop. Thus each block is
   159 that doesn't fall in the scope of the ``for`` loop. Thus each block is
   159 separated by the indentation level. Thus marking the importance of
   160 separated by the indentation level and that marks the importance of
   160 white-spaces in Python.
   161 white-spaces in Python.
   161 
   162 
   162 {{{ switch to the slide which shows the problem statement of the first
   163 {{{ switch to the slide which shows the problem statement of the first
   163 problem to be tried out }}}
   164 problem to be tried out }}}
   164 
   165 
   202 
   203 
   203         print "Square root of", each,
   204         print "Square root of", each,
   204 	print "is", sqrt(each)
   205 	print "is", sqrt(each)
   205 
   206 
   206 Now we have finished the statements in the block, and still the
   207 Now we have finished the statements in the block, and still the
   207 interpreter is showing four dots, which means you are still inside the
   208 interpreter is showing four dots, this means that you are still inside the
   208 block. To exit from the block press return key or the enter key twice
   209 block. To exit from the block press the return key or the enter key twice
   209 without entering anything else. It printed the square root of each
   210 without entering anything else. It printed the square root of each
   210 number in the list, and that is executed in a ``for`` loop.
   211 number in the list, and that is executed in a ``for`` loop.
   211 
   212 
   212 {{{ switch to next slide, Indentation in ``python`` interpreter }}}
   213 {{{ switch to next slide, Indentation in ``python`` interpreter }}}
   213 
   214 
   250                 Then say this list can also be generated using
   251                 Then say this list can also be generated using
   251                 the range function and hence introduce range.
   252                 the range function and hence introduce range.
   252 
   253 
   253 {{{ switch to the next slide, ``range()`` function }}}
   254 {{{ switch to the next slide, ``range()`` function }}}
   254 
   255 
   255 Okay! so the main thing here we learned is how to use Python
   256 Okay! so the main thing that we learned here is how to use Python
   256 interpreter and IPython interpreter to specify blocks. But while we
   257 interpreter and IPython interpreter to specify blocks. But while we
   257 were generating the multiplication table we used something new,
   258 were generating the multiplication table we used something new,
   258 ``range()`` function. ``range()`` is an inbuilt function in Python
   259 ``range()`` function. ``range()`` is an inbuilt function in Python
   259 which can be used to generate a ``list`` of integers from a starting
   260 which can be used to generate a ``list`` of integers from a starting
   260 number to an ending number. Note that the ending number that you
   261 number to an ending number. Note that the ending number that you