getting-started-ipython/script.rst
changeset 347 7ac0296d1cf6
parent 275 146a6bf5c30b
child 378 fa4c9b11452b
equal deleted inserted replaced
346:f0c93ea97e4c 347:7ac0296d1cf6
    14 .. -------------
    14 .. -------------
    15 
    15 
    16 .. should have ``ipython`` and ``pylab`` installed. 
    16 .. should have ``ipython`` and ``pylab`` installed. 
    17      
    17      
    18 .. Author              : Puneeth 
    18 .. Author              : Puneeth 
    19    Internal Reviewer   : 
    19    Internal Reviewer   : Anoop Jacob Thomas<anoop@fossee.in>
    20    External Reviewer   :
    20    External Reviewer   :
    21    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    21    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    22 
    22 
    23 
    23 
    24 Script
    24 Script
    70 ::
    70 ::
    71   1+2 
    71   1+2 
    72 
    72 
    73 at the prompt. IPython promptly gives back the output as 3.  Notice
    73 at the prompt. IPython promptly gives back the output as 3.  Notice
    74 that the output is displayed with an ``Out[1]`` indication.
    74 that the output is displayed with an ``Out[1]`` indication.
       
    75 
       
    76 .. #[[Anoop: I think we can illustrate In [] and Out[] in slides]]
    75 
    77 
    76 Let's try out few other mathematical operations.
    78 Let's try out few other mathematical operations.
    77 ::
    79 ::
    78 
    80 
    79   5 - 3
    81   5 - 3
    93 and use the left arrow key to move the cursor on to the + symbol and
    95 and use the left arrow key to move the cursor on to the + symbol and
    94 then use the delete key to remove it and type 0 and * to change the
    96 then use the delete key to remove it and type 0 and * to change the
    95 expression to the required one.  We hit enter to see the output of
    97 expression to the required one.  We hit enter to see the output of
    96 ``print``. 
    98 ``print``. 
    97 
    99 
       
   100 .. #[[Anoop: We could create a slide with heading Tab Completion and
       
   101    give the question as an exercise, basically I feel more slides
       
   102    should be used]]
       
   103 
    98 Now, let's say we want to use the function ``round``. We type ``ro``
   104 Now, let's say we want to use the function ``round``. We type ``ro``
    99 at the prompt and hit the tab key. As you can see, the IPython
   105 at the prompt and hit the tab key. As you can see, the IPython
   100 completes the command. This feature is called the tab-completion.
   106 completes the command. This feature is called the tab-completion.
   101 
   107 
   102 Now, we remove all the characters and just type ``r`` and then hit
   108 Now, we remove all the characters and just type ``r`` and then hit
   103 tab. IPython does not complete the command since there are many
   109 tab. IPython does not complete the command since there are many
   104 possibilities. It just lists out all the possible completions.
   110 possibilities. It just lists out all the possible completions.
   105 
   111 
   106 Following is an exercise that you must do. 
   112 Following is an exercise that you must do. 
   107 
   113 
       
   114 .. #[[Anoop: Include slides for exercises]]
       
   115 
   108 %%1%% Type ``ab`` and hit tab to see what happens. Next, just type
   116 %%1%% Type ``ab`` and hit tab to see what happens. Next, just type
   109 ``a`` and hit tab to see what happens.
   117 ``a`` and hit tab to see what happens.
   110 
   118 
   111 Please, pause the video here. Do the exercise and then continue. 
   119 Please, pause the video here. Do the exercise and then continue. 
   112 
   120 
   114 the commands starting with a. 
   122 the commands starting with a. 
   115 
   123 
   116 Now, let's see what these functions are used for.  We will use the
   124 Now, let's see what these functions are used for.  We will use the
   117 help features of ipython to find this out.
   125 help features of ipython to find this out.
   118 
   126 
       
   127 .. #[[Anoop: Another slide which says about ? mark and round? etc, as
       
   128    few people cannot just follow by listening (like me) :)]]
       
   129 
   119 To get the help of any function, we first type the function, ``abs``
   130 To get the help of any function, we first type the function, ``abs``
   120 in our case and then add a ? at the end and hit enter.
   131 in our case and then add a ? at the end and hit enter.
   121 
   132 
   122 As the documentation says, ``abs`` accepts a number as an input and
   133 As the documentation says, ``abs`` accepts a number as an input and
   123 returns it's absolute value.
   134 returns it's absolute value.
   133 
   144 
   134 Does it work for decimals (or floats)?  Let's try typing abs(-10.5)
   145 Does it work for decimals (or floats)?  Let's try typing abs(-10.5)
   135 and we do get back 10.5.
   146 and we do get back 10.5.
   136 
   147 
   137 Following is an exercise that you must do. 
   148 Following is an exercise that you must do. 
       
   149 
       
   150 .. #[[Anoop: add slide]]
   138 
   151 
   139 %%2%% Look-up the documentation of ``round`` and see how to use it.
   152 %%2%% Look-up the documentation of ``round`` and see how to use it.
   140 
   153 
   141 Please, pause the video here. Do the exercise and then continue. 
   154 Please, pause the video here. Do the exercise and then continue. 
   142 
   155 
   150 documentation.
   163 documentation.
   151 
   164 
   152 The function ``round``, rounds a number to a given precision.
   165 The function ``round``, rounds a number to a given precision.
   153 
   166 
   154 Following are exercises that you must do. 
   167 Following are exercises that you must do. 
       
   168 
       
   169 .. #[[Anoop: add slide]]
   155 
   170 
   156 %%3%% Check the output of::
   171 %%3%% Check the output of::
   157 
   172 
   158   round(2.48)
   173   round(2.48)
   159   round(2.48, 1)
   174   round(2.48, 1)
   184 type Ctrl-C to interrupt the command and get back the ``ipython`` input
   199 type Ctrl-C to interrupt the command and get back the ``ipython`` input
   185 prompt.
   200 prompt.
   186 
   201 
   187 Following is an exercise that you must do. 
   202 Following is an exercise that you must do. 
   188 
   203 
       
   204 .. #[[Anoop: add slide]]
       
   205 
   189 %%4%% Try typing round(2.484, and hit enter. and then cancel the
   206 %%4%% Try typing round(2.484, and hit enter. and then cancel the
   190 command using Ctrl-C. Then, type the command, round(2.484, 2) and
   207 command using Ctrl-C. Then, type the command, round(2.484, 2) and
   191 resume the video.
   208 resume the video.
   192 
   209 
   193 Please, pause the video here. Do the exercises and then continue. 
   210 Please, pause the video here. Do the exercises and then continue. 
   199 
   216 
   200   round(2.484, 2)
   217   round(2.484, 2)
   201   
   218   
   202 This brings us to the end of the tutorial on getting started with
   219 This brings us to the end of the tutorial on getting started with
   203 ``ipython``.
   220 ``ipython``.
       
   221 
       
   222 .. #[[Anoop: add slides for interrupts, navigating history, I feel
       
   223     even a single point will also do]]
   204 
   224 
   205 In this tutorial we have learnt, how to
   225 In this tutorial we have learnt, how to
   206 {{{ show the outline/summary slide. }}}
   226 {{{ show the outline/summary slide. }}}
   207 
   227 
   208   1. invoke the ``ipython`` interpreter. 
   228   1. invoke the ``ipython`` interpreter. 
   216 
   236 
   217 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
   237 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
   218 
   238 
   219 Hope you have enjoyed and found it useful.
   239 Hope you have enjoyed and found it useful.
   220 Thank you!
   240 Thank you!
   221