additional_ipython.rst
changeset 212 c3172a51b555
parent 136 7f8b6a9fb61d
equal deleted inserted replaced
211:8bc4f7b3e038 212:c3172a51b555
       
     1 .. Author              : Nishanth
       
     2    Internal Reviewer 1 : 
       
     3    Internal Reviewer 2 : 
       
     4    External Reviewer   :
       
     5 
       
     6 .. Prerequisites: Embellinshing plots
       
     7 
       
     8 Script
       
     9 ======
       
    10 
       
    11 
     1 Hello friends and welcome to the tutorial on Additional Features of IPython
    12 Hello friends and welcome to the tutorial on Additional Features of IPython
     2 
    13 
     3 {{{ Show the slide containing title }}}
    14 {{{ Show the slide containing title }}}
     4 
    15 
     5 {{{ Show the slide containing the outline slide }}}
    16 {{{ Show the slide containing the outline slide }}}
   163 The reason for including a -i after run is to tell the interpreter that if any
   174 The reason for including a -i after run is to tell the interpreter that if any
   164 name is not found in script, search for it in the interpreter. Hence all these
   175 name is not found in script, search for it in the interpreter. Hence all these
   165 sin, plot, pi and show which are not available in script, are taken from the
   176 sin, plot, pi and show which are not available in script, are taken from the
   166 interpreter and used to run the script.
   177 interpreter and used to run the script.
   167 
   178 
       
   179 {{{ Pause here and try out the following exercises }}}
       
   180 
       
   181 %% 4 %% Run the script without using the -i option. Do you find any difference?
       
   182 
       
   183 {{{ continue from paused state }}}
       
   184 
       
   185 We see that it raises nameerror saying the name linspace is not found.
       
   186 
   168 {{{ Show summary slide }}}
   187 {{{ Show summary slide }}}
   169 
   188 
   170 This brings us to the end of the tutorial.
   189 This brings us to the end of the tutorial.
   171 we have looked at 
   190 we have looked at 
   172 
   191 
   181 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
   200 This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India
   182 
   201 
   183 Hope you have enjoyed and found it useful.
   202 Hope you have enjoyed and found it useful.
   184 Thankyou
   203 Thankyou
   185  
   204  
   186 .. Author              : Nishanth
   205 Questions
   187    Internal Reviewer 1 : 
   206 =========
   188    Internal Reviewer 2 : 
   207 
   189    External Reviewer   :
   208  1. How do you retrieve the recent 5 commands
       
   209 
       
   210     a. ``%hist``
       
   211     #. ``%hist -5``
       
   212     #. ``%hist 5``
       
   213     #. ``%hist 5-10``
       
   214 
       
   215     Answer: ``%hist 5``
       
   216     
       
   217  2. If there were 20 commands typed and ``%hist`` is used. How many commands 
       
   218     will be displayed.
       
   219 
       
   220     a. 10
       
   221     #. 20
       
   222     #. 21
       
   223     #. 19
       
   224 
       
   225     Answer: 21
       
   226 
       
   227  3. is ``%hist`` considered as a command
       
   228 
       
   229     a. True
       
   230     #. False
       
   231 
       
   232     Answer: True
       
   233 
       
   234  4. how do you retreive the commands from 20 to 50 (inclusive of 20 and 50)
       
   235 
       
   236     a. ``%hist 20 50``
       
   237     #. ``%hist 19 50``
       
   238     #. ``%hist 19 51``
       
   239     #. ``%hist 21 50``
       
   240 
       
   241     Answer: ``%hist 20 50``
       
   242 
       
   243  5. What does the ``%hist 2 5 7`` command do
       
   244 
       
   245     a. lists the second, fifth and seventh commands
       
   246     #. lists the commands from 2 to 5 and the seventh command
       
   247     #. raises an error
       
   248     #. lists the commands 2 to 7
       
   249 
       
   250     Answer: raises an error
       
   251 
       
   252  6. How many commands are displayed when lot of coomands were typed and 
       
   253     ``%hist`` is used.
       
   254 
       
   255     a. 20
       
   256     #. 10
       
   257     #. 50
       
   258     #. 40
       
   259 
       
   260     Answer: 40
       
   261 
       
   262  7. How do you save the lines 2 3 4 5 7 9 10 11
       
   263 
       
   264     a. ``%save filepath 2-5 7 9-11``
       
   265     #. ``%save filepath 2-11``
       
   266     #. ``%save filepath``
       
   267     #. ``%save 2-5 7 9 10 11``
       
   268 
       
   269     Answer: ``%save filepath 2-5 7 9-11``
       
   270 
       
   271  8. You are working in /home/user. Where is the file saved when you do
       
   272     ``%save hello.py 1-3`` 
       
   273 
       
   274     a. /home/user/hello.py
       
   275     #. /hello.py
       
   276     #. /home/hello.py
       
   277     #. /home/user/ipython/hello.py
       
   278 
       
   279     Answer: /home/user/hello.py
       
   280 
       
   281  9. Which lines are saved by the command ``%save filepath 2-5 7 1`` and in
       
   282     which order
       
   283 
       
   284     a. 2 3 4 5 7 1
       
   285     #. 1 2 3 4 5 6 7
       
   286     #. 2 5 7 1
       
   287     #. 1 2 5 7
       
   288 
       
   289  10. What happens when ``%save filepath line_numbers`` is used and a file
       
   290      already exists in that path.
       
   291 
       
   292     a. It is overwritten
       
   293     #. The commands are added to the file
       
   294     #. It raises an error
       
   295     #. A prompt to confirm overwriting is displayed 
       
   296 
       
   297     Answer: A prompt to confirm overwriting is displayed 
       
   298 
       
   299  11. Read through the documentation of ``%hist`` and find its alternative name
       
   300 
       
   301     Answer: ``%history``
       
   302 
       
   303  12. Are ``%run /home/user/saved.py`` and ``%run /home/user/saved`` the same
       
   304 
       
   305    a. Yes
       
   306    #. No
       
   307 
       
   308    Answer: Yes
       
   309 
       
   310  13. The file hello.py contains only one command ``x = x + 1``. What happens
       
   311      when you do ``%run hello.py``
       
   312 
       
   313     Answer: Raises a nameerror
       
   314 
       
   315   14. The file hello.py contains only one command ``x = x + 1``. If value of x
       
   316       is 5 and what does ``%run -i hello.py`` do.
       
   317 
       
   318     a. raises an error
       
   319     #. increments value of x by 1
       
   320     #. Does nothing
       
   321     
       
   322     Answer: increments the value of x by 1