diff -r de16a94027f9 -r f105cfcc2498 getting-started-with-for/script.rst --- a/getting-started-with-for/script.rst Tue Oct 12 00:25:54 2010 +0530 +++ b/getting-started-with-for/script.rst Tue Oct 12 13:02:39 2010 +0530 @@ -43,6 +43,11 @@ for indentation. Do that while typing so that they can actually see what is being typed. +As you can see in the slide, ``Block B`` is an inner block and it is +indented using 4 spaces, and after ``Block B`` the next statement in +``Block A`` starts from the same indentation level of other ``Block +A`` statements. + Now let us move straight into ``for`` loop. {{{ switch to next slide, problem statement of exercise 1 }}} @@ -85,6 +90,8 @@ square_roots. It is only complicating stuff. Simply iterate and print. +{{{ switch to next slide, save and run script }}} + {{{ save the script }}} Now save the script, and run it from your IPython interpreter. I @@ -151,6 +158,8 @@ the list. And this time let us do it right in the IPython interpreter. +{{{ switch to next slide, Indentation in ``ipython`` }}} + {{{ switch focus to the IPython interpreter }}} So let us start with making a list. Type the following @@ -166,11 +175,14 @@ four dots tell you that you are inside a block. Now type the rest of the ``for`` loop, +{{{ switch to next slide, Indentation in ``ipython`` (cont'd) }}} + .. #[Nishanth]: Tell that IPython does auto indentation. :: - print "Square root of", each, "is", sqrt(each) + print "Square root of", each, + print "is", sqrt(each) Now we have finished the statements in the block, and still the interpreter is showing four dots, which means you are still inside the @@ -178,6 +190,8 @@ without entering anything else. It printed the square root of each number in the list, and that is executed in a ``for`` loop. +{{{ switch to next slide, Indentation in ``python`` interpreter }}} + Now, let us find the cube of all the numbers from one to ten. But this time let us try it in the vanilla version of Python interpreter. @@ -187,6 +201,9 @@ {{{ open the python interpreter in the terminal using the command python to start the vanilla Python interpreter }}} +{{{ switch to next slide, Indentation in ``python`` interpreter +(cont'd) }}} + Start with, :: @@ -214,6 +231,8 @@ Then say this list can also be generated using the range function and hence introduce range. +{{{ switch to the next slide, ``range()`` function }}} + Okay! so the main thing here we learned is how to use Python interpreter and IPython interpreter to specify blocks. But while we were generating the multiplication table we used something new, @@ -225,12 +244,14 @@ .. #[Nishanth]: Show some examples of range without the step argument May be give an exercise with negative numbers as arguments -Now, let us print all the odd numbers from 1 to 50. Let us do it in -our IPython interpreter for ease of use. - {{{ switch to next slide, problem statement of the next problem in solved exercises }}} +Now, let us print all the odd numbers from 1 to 50. Pause here and try +to solve the problem yourself. + +Let us do it in our IPython interpreter for ease of use. + {{{ switch focus to ipython interpreter }}} The problem can be solved by just using the ``range()`` function. @@ -248,7 +269,7 @@ number. The third parameter is for stepping through the sequence. Here we gave two which means we are skipping every alternate element. -{{{ switch to next slide, recap slide }}} +{{{ switch to next slide, summary slide }}} Thus we come to the end of this tutorial. We learned about blocks in Python, indentation, blocks in IPython, for loop, iterating over a