getting-started-ipython/script.rst
changeset 246 95e7682e9d43
parent 217 b595f90016c5
child 275 146a6bf5c30b
equal deleted inserted replaced
245:3ed6ef2ea91f 246:95e7682e9d43
     1 .. Objectives
     1 .. Objectives
     2 .. ----------
     2 .. ----------
     3 
     3 
     4 .. Clearly state the objectives of the LO (along with RBT level)
     4 .. At the end of this tutorial, you will be able to 
       
     5 
       
     6 .. 1. invoke the ``ipython`` interpreter. 
       
     7 .. #. quit the ``ipython`` interpreter. 
       
     8 .. #. navigate in the history of ``ipython``. 
       
     9 .. #. use tab-completion. 
       
    10 .. #. look-up documentation of functions. 
       
    11 .. #. interrupt incomplete or incorrect commands.
     5 
    12 
     6 .. Prerequisites
    13 .. Prerequisites
     7 .. -------------
    14 .. -------------
     8 
    15 
     9 ..   1. Name of LO-1
    16 .. should have ``ipython`` and ``pylab`` installed. 
    10 ..   2. Name of LO-2
       
    11 ..   3. Name of LO-3
       
    12      
    17      
    13 .. Author              : Puneeth 
    18 .. Author              : Puneeth 
    14    Internal Reviewer   : 
    19    Internal Reviewer   : 
    15    External Reviewer   :
    20    External Reviewer   :
    16    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    21    Checklist OK?       : <put date stamp here, if OK> [2010-10-05]
    22 {{{ Show the slide containing title }}}
    27 {{{ Show the slide containing title }}}
    23 
    28 
    24 Hello Friends and Welcome to the tutorial on getting started with
    29 Hello Friends and Welcome to the tutorial on getting started with
    25 ``ipython``. 
    30 ``ipython``. 
    26 
    31 
    27 {{{ Show slide with outline of the session. }}}
    32 {{{ Show slide with outline }}}
    28 
    33 
    29 This tutorial will cover the basic usage of the ``ipython``
    34 This tutorial will cover the basic usage of the ``ipython``
    30 interpreter. The following topics would be covered.
    35 interpreter. The following topics would be covered.
    31 
    36 
    32 IPython is an enhanced Python interpreter that provides features like
    37 IPython is an enhanced Python interpreter that provides features like
    33 tabcompletion, easier access to help and many other functionalities
    38 tabcompletion, easier access to help and lot of other functionality
    34 which are not available in the vannila Python interpreter.
    39 which are not available in the vanilla Python interpreter.
    35 
    40 
    36 First let us see how to invoke the ``ipython`` interpreter.
    41 First let us see how to invoke the ``ipython`` interpreter.
    37 
    42 
    38 We type
    43 We type
    39 ::
    44 ::
    96 
   101 
    97 Now, we remove all the characters and just type ``r`` and then hit
   102 Now, we remove all the characters and just type ``r`` and then hit
    98 tab. IPython does not complete the command since there are many
   103 tab. IPython does not complete the command since there are many
    99 possibilities. It just lists out all the possible completions.
   104 possibilities. It just lists out all the possible completions.
   100 
   105 
   101 %% %% Pause the video here and type ``ab`` and hit tab to see what
   106 Following is an exercise that you must do. 
   102 happens. Next, jut type ``a`` and hit tab to see what happens. 
   107 
       
   108 %%1%% Type ``ab`` and hit tab to see what happens. Next, jut type
       
   109 ``a`` and hit tab to see what happens.
       
   110 
       
   111 Please, pause the video here. Do the exercise and then continue. 
   103 
   112 
   104 ``ab`` tab completes to ``abs`` and ``a<tab>`` gives us a list of all
   113 ``ab`` tab completes to ``abs`` and ``a<tab>`` gives us a list of all
   105 the commands starting with a. 
   114 the commands starting with a. 
   106 
   115 
   107 Now, let's see what these functions are used for.  We will use the
   116 Now, let's see what these functions are used for.  We will use the
   123 We get 19, as expected, in both the cases.  
   132 We get 19, as expected, in both the cases.  
   124 
   133 
   125 Does it work for decimals (or floats)?  Let's try typing abs(-10.5)
   134 Does it work for decimals (or floats)?  Let's try typing abs(-10.5)
   126 and we do get back 10.5.
   135 and we do get back 10.5.
   127 
   136 
   128 Following is an (are) exercise(s) that you must do. 
   137 Following is an exercise that you must do. 
   129 
   138 
   130 %%1%% Look-up the documentation of ``round`` and see how to use it.
   139 %%2%% Look-up the documentation of ``round`` and see how to use it.
   131 
   140 
   132 Please, pause the video here. Do the exercises and then continue. 
   141 Please, pause the video here. Do the exercise and then continue. 
   133 
   142 
   134 ::
   143 ::
   135 
   144 
   136  round?
   145  round?
   137 
   146 
   140 Optional parameters are shown in square brackets anywhere in Python
   149 Optional parameters are shown in square brackets anywhere in Python
   141 documentation.
   150 documentation.
   142 
   151 
   143 The function ``round``, rounds a number to a given precision.
   152 The function ``round``, rounds a number to a given precision.
   144 
   153 
   145 %% %% Pause the video here and check the output of
   154 Following are exercises that you must do. 
   146 round(2.48)
   155 
   147 round(2.48, 1)
   156 %%3%% Check the output of::
   148 round(2.48, 2)
   157 
   149 and then resume the video. 
   158   round(2.48)
   150 
   159   round(2.48, 1)
   151 ::
   160   round(2.48, 2)
       
   161 
   152   round(2.484)
   162   round(2.484)
   153   round(2.484, 1)
   163   round(2.484, 1)
   154   round(2.484, 2)
   164   round(2.484, 2)
       
   165 
       
   166 Please, pause the video here. Do the exercises and then continue. 
   155 
   167 
   156 We get 2.0, 2.5 and 2.48, which are what we expect. 
   168 We get 2.0, 2.5 and 2.48, which are what we expect. 
   157 
   169 
   158 Let's now see how to correct typing errors that we make when typing at
   170 Let's now see how to correct typing errors that we make when typing at
   159 the terminal. As already shown, if we haven't hit the enter key
   171 the terminal. As already shown, if we haven't hit the enter key
   172 type Ctrl-C to interrupt the command and get back the ``ipython`` input
   184 type Ctrl-C to interrupt the command and get back the ``ipython`` input
   173 prompt.
   185 prompt.
   174 
   186 
   175 Following is an exercise that you must do. 
   187 Following is an exercise that you must do. 
   176 
   188 
   177 %%2%% Try typing round(2.484, and hit enter. and then cancel the
   189 %%4%% Try typing round(2.484, and hit enter. and then cancel the
   178 command using Ctrl-C. Then, type the command, round(2.484, 2) and
   190 command using Ctrl-C. Then, type the command, round(2.484, 2) and
   179 resume the video.
   191 resume the video.
   180 
   192 
   181 Please, pause the video here. Do the exercises and then continue. 
   193 Please, pause the video here. Do the exercises and then continue. 
   182 
   194 
   191 ``ipython``.
   203 ``ipython``.
   192 
   204 
   193 In this tutorial we have learnt
   205 In this tutorial we have learnt
   194 {{{ show the outline/summary slide. }}}
   206 {{{ show the outline/summary slide. }}}
   195 
   207 
   196 
       
   197 {{{ Show the "sponsored by FOSSEE" slide }}}
   208 {{{ Show the "sponsored by FOSSEE" slide }}}
   198 
   209 
   199 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
   210 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
   200 
   211 
   201 Hope you have enjoyed and found it useful.
   212 Hope you have enjoyed and found it useful.