summary |
shortlog |
changelog |
graph |
tags |
bookmarks |
branches |
files |
changeset |
raw | zip | gz | bz2 |
help

author | Amit Sethi |

Thu, 11 Nov 2010 23:44:59 +0530 | |

changeset 486 | 591369704df0 |

parent 485 | fd3902300f20 (current diff) |

parent 484 | a1828587a617 (diff) |

child 487 | cb3974daced5 |

Mergind heads

--- a/dictionaries/script.rst Thu Nov 11 23:40:39 2010 +0530 +++ b/dictionaries/script.rst Thu Nov 11 23:44:59 2010 +0530 @@ -20,7 +20,8 @@ .. Author : Anoop Jacob Thomas <anoop@fossee.in> Internal Reviewer : Puneeth External Reviewer : - Checklist OK? : <put date stamp here, if OK> [2010-10-05] + Language Reviewer : Bhanukiran + Checklist OK? : <11-11-2010, Anand, OK> [2010-10-05] .. #[Puneeth: Quickref] @@ -139,8 +140,8 @@ extensions['cpp'] = 'C++ source code' extensions -As you can see, it did not add a new thing nor gave an error, but it -simply replaces the existing value with the new one. +As you can see, it neither added a new thing nor gave an error, but it +simply replaced the existing value with the new one. Now let us learn how to check if a particular key is present in the dictionary. For that we can use ``in``,

--- a/getting-started-with-arrays/script.rst Thu Nov 11 23:40:39 2010 +0530 +++ b/getting-started-with-arrays/script.rst Thu Nov 11 23:44:59 2010 +0530 @@ -20,7 +20,8 @@ .. Author: Anoop Jacob Thomas <anoop@fossee.in> Internal Reviewer : Puneeth External Reviewer : - Checklist OK? : <put date stamp here, if OK> [2010-10-05] + Language Reviewer : Bhanukiran + Checklist OK? : <11-11-2010,Anand, OK > [2010-10-05] =========================== Getting started with Arrays @@ -34,17 +35,17 @@ {{{ switch to next slide, outline slide }}} -In this tutorial, we will learn about arrays, we will learn how to convert -a list into an array array operations and also why an array is preferred -over lists. +In this tutorial, we will learn about the data structure called an array, how to convert +a list into an array, operations on arrays and also why an array is preferred +to lists. .. #[Puneeth: Fix the grammar above.] {{{ switch to next slide on overview of array }}} Arrays are homogeneous data structures. Unlike lists, arrays cannot have -heterogeneous data elements, that is, it can have only one type of data -type, either all integers, or strings, or float, and not a mix. +heterogeneous data elements, that is, they can have only one type of data +as their entries, be them all integers, strings, or maybe floats, but not a mix. .. #[Puneeth: Use multiple short sentences, rather than one long sentence I would've written something like this. @@ -52,8 +53,9 @@ Unlike lists, arrays are homogeneous data structures. They can have only type of data, ....] -Arrays are really fast in mathematical operations when compared to lists, -because of the same type of data in arrays. +Arrays of a given length are comparatively much faster in mathematical +operations than lists of the same length, because of the fact that they are +homogeneous data structures. .. #[Puneeth: For what size of an array is that the comparison? @@ -77,7 +79,7 @@ a1 = array([1,2,3,4]) -Notice that here we created a one dimensional array. Also notice the object +Notice that we created a one dimensional array here. Also notice the object we passed to create an array. We passed a list to create an array. Now let us see how to create a two dimensional array. Pause here and try to @@ -112,7 +114,7 @@ .. #[Puneeth: say, creating the same array as before. for some time I got .. confused .] -And we obtained a single dimensional array with elements from 1 to 8. +And we obtained a one dimensional array with elements from 1 to 8. :: @@ -120,7 +122,7 @@ .. #[Puneeth: be consistent with voice. say, we obtained... or something.] -And how can we make it a two dimensional array of order 2 by 4. Pause here +And how can we make it a two dimensional array of order 2 by 4? Pause here and try to do it yourself, try ``ar.tab`` and find a suitable method for that. @@ -154,13 +156,13 @@ {{{ switch to the next slide, problem statement of unsolved exercise 1 }}} -Create a three dimensional array of the order (2,2,4). +Create a three dimensional array of the shape (2,2,4). .. #[Puneeth: s/order/shape or size ?] {{{ switch to the next slide, shape of an array }}} -To find the shape of an array we can use the object ``.shape``, let us +To find the shape of an array we can use the method ``.shape``, let us check the shape of the arrays we have created so far, .. #[Puneeth: s/object/method ?] @@ -200,8 +202,8 @@ a4 = array([1,2,3,'a string']) -Well, we expected an error as previously I said that an array can have only -homogeneous elements, but it didn't give an error. Let us check the values +Well, we would expect an error as it has been previously mentioned that arrays handle +elements with the same datatype, but it didn't raise an error. Let us check the values in the new array created. In your IPython terminal type, :: @@ -218,8 +220,8 @@ {{{ highlight all the array elements one by one using mouse movements }}} -all the elements have been implicitly type casted as string, though our -first three elements were integers. +all the elements have been implicitly type casted as strings, though our +first three elements were meant to be integers. .. #[Puneeth: when I type a4 it says some ``dtype`` etc. I don't understand .. what it is, can you explain? ;)] @@ -229,25 +231,26 @@ .. #[Puneeth: something needs to motivate this. why are we suddenly talking .. of an identity matrix?] -Now let us see how to create identity matrix, an identity matrix is a -square matrix in which all the diagonal elements are one and rest of the -elements zero. We can create an identity matrix using the method +Now let us see how to create an identity matrix of a given size, that is a +two-dimensional array in which all the diagonal elements are ones and rest of the +elements are zeros. We can create an identity matrix using the function ``identity()``. -The function ``identity()`` takes an integer argument, +The function ``identity()`` takes an integer argument which specifies the +size of the desired matrix, :: identity(3) -As you can see the identity method returned a three by three square matrix -with all the diagonal elements as one and the rest of the elements as zero. +As you can see the identity function returned a three by three square matrix +with all the diagonal elements as ones and the rest of the elements as zeros. .. #[Puneeth: You say array here, matrix there -- it's a bit messed up. .. Clarify, explicitly.] -``zeros()`` function accepts a tuple, which is the order of the array we -want to create, and it generates an array with all elements zero. +``zeros()`` function accepts a tuple, which is the order of the array that we +want to create, and it generates an array with all elements as zeros. {{{ switch to the next slide, problem statement of solved exercise 1 }}}

--- a/getting-started-with-for/script.rst Thu Nov 11 23:40:39 2010 +0530 +++ b/getting-started-with-for/script.rst Thu Nov 11 23:44:59 2010 +0530 @@ -22,7 +22,8 @@ Internal Reviewer : Nishanth Internal Reviewer(2): Amit External Reviewer : - Checklist OK? : <put date stamp here, if OK> [2010-10-05] + Language Reviewer : Bhanukiran + Checklist OK? : <10-11-2010, Anand, OK> [2010-10-05] ============================= @@ -31,7 +32,7 @@ {{{ show welcome slide }}} -Hello and welcome to the tutorial getting started with ``for`` loop. +Hello and welcome to the tutorial `Getting started with ``for`` loop`. {{{ switch to next slide, outline slide }}} @@ -156,7 +157,7 @@ it means that it is not part of the ``for`` loop and the lines after that doesn't fall in the scope of the ``for`` loop. Thus each block is -separated by the indentation level. Thus marking the importance of +separated by the indentation level and that marks the importance of white-spaces in Python. {{{ switch to the slide which shows the problem statement of the first @@ -204,8 +205,8 @@ 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 -block. To exit from the block press return key or the enter key twice +interpreter is showing four dots, this means that you are still inside the +block. To exit from the block press the return key or the enter key twice without entering anything else. It printed the square root of each number in the list, and that is executed in a ``for`` loop. @@ -252,7 +253,7 @@ {{{ switch to the next slide, ``range()`` function }}} -Okay! so the main thing here we learned is how to use Python +Okay! so the main thing that we learned here is how to use Python interpreter and IPython interpreter to specify blocks. But while we were generating the multiplication table we used something new, ``range()`` function. ``range()`` is an inbuilt function in Python

--- a/getting-started-with-functions/script.rst Thu Nov 11 23:40:39 2010 +0530 +++ b/getting-started-with-functions/script.rst Thu Nov 11 23:44:59 2010 +0530 @@ -23,7 +23,8 @@ .. Author : Anoop Jacob Thomas <anoop@fossee.in> Internal Reviewer : External Reviewer : - Checklist OK? : <put date stamp here, if OK> [2010-10-05] + Language Reviewer : Bhanukiran + Checklist OK? : <put date stamp here, not OK> [2010-10-05] ============================== @@ -32,29 +33,29 @@ {{{ show welcome slide }}} -Hello and welcome to the tutorial, getting started with functions. +Hello and welcome to the tutorial getting started with functions. {{{ switch to next slide, outline slide }}} In this tutorial we will learn about functions in python, how to -define functions, passing arguments to functions, docstrings, and -function return value. +define functions, arguments to functions, docstrings, and function +return value. {{{ switch to next slide, Function }}} -While writing code, we would like to reduce the number of lines of -code and using functions is a way of reusing the code. A function is -a portion of code within a larger program that performs a specific -task and is relatively independent of the remaining code. Now let us -get more familiar with functions, +While writing code, we always want to reduce the number of lines of +code and functions is a way of reusing the code. Thus the same lines +of code can be used as many times as needed. A function is a portion of code +within a larger program that performs a specific task and is +relatively independent of the remaining code. Now let us get more +familiar with functions, {{{ switch to next slide, f(x) a mathematical function }}} -Consider a mathematical function f(x) = x squared. Here x is a -variable and with different values of x the value of function will -change. When x is one f(1) will return the value 1 and f(2) will -return us the value 4. Let us now see how to define the function f(x) -in Python. +Consider a mathematical function f(x) = x square. Here x is a variable +and with different values of x the value of function will change. When +x is one f(1) will return the value 1 and f(2) will return us the +value 4. Let us now see how to define the function f(x) in python. {{{ switch to next slide, define f(x) in Python }}} @@ -64,22 +65,19 @@ def f(x): return x*x -Let us see, if the function ``f``, we defined, works as we expect. +Well that defined the function, so before learning what we did let us +see if it returns the expected values, try, :: f(1) f(2) -Yes, it returned 1 and 2 respectively. - -Now, let us see what we did. The first line ``def f(x)`` is used to -define the name and the parameters to the function. ``def`` is a -keyword and ``f`` is the name of the function and ``x`` the parameter -of the function. - -The second line is the body of the function. Incidentally, this -function has a single line definition. Note that the body of the -function is indented, just like any other code block, in Python. +Yes, it returned 1 and 4 respectively. And now let us see what we did. +We wrote two lines: The first line ``def f(x)`` is used to define the +name and the parameters to the function and the second line is used to +fix what the function is supposed to return. ``def`` is a keyword and +``f`` is the name of the function and ``x`` the parameter of the +function. {{{ switch to next slide, problem statement 1 }}} @@ -96,18 +94,18 @@ def cube(n): return n**3 -Now let us see how to write functions without arguments. +And now let us see how to write functions without arguments. {{{ switch to next slide, greet function }}} -Let us define a new function called ``greet`` which will print ``Hello +let us define a new function called ``greet`` which will print ``Hello World``. :: def greet(): print "Hello World!" -Now try calling the function, +now try calling the function, :: greet() @@ -127,22 +125,22 @@ {{{ switch to next slide, solution 2 }}} -The problem can be solved as shown, +The problem can be solved as, :: def avg(a,b): return (a + b)/2 Thus if we want a function to accept more arguments, we just list them -separated with a comma between the parenthesis after the function name +separated with a comma between the parenthesis after the function's name in the ``def`` line. {{{ switch to next slide, docstring }}} It is always a good practice to document the code that we write, and for a function we define we should write an abstract of what the -function does, and that is called a doc-string. Let us modify the -function ``avg`` and add doc-string to it. Do the following, +function does, and that is called a docstring. Let us modify the +function ``avg`` and add docstring to it. Do the following, :: def avg(a,b): @@ -150,7 +148,7 @@ returns the average of a and b""" return (a+b)/2 -Note that doc-strings are entered in the immediate line after the +Note that docstrings are entered in the immediate line after the function definition and put as a triple quoted string. And here as far as the code functionality is concerned, we didn't do anything. We just added an abstract of what the function does. @@ -170,7 +168,7 @@ It doesn't have a docstring associated with it. Also we cannot infer anything from the function name, and thus we are forced to read the -code to understand anything about the function. +code to understand about the function. {{{ switch to next slide, exercise 3 }}} @@ -238,8 +236,8 @@ {{{ switch to next slide, even_digits }}} .. def even_digits( n ): -.. """returns True if all the digits of number n is even -.. returns False if all the digits of number n is not even""" +.. """returns True if all the digits in the number n are even, +.. returns False if all the digits in the number n are not even""" .. if n < 0: n = -n .. while n > 0: .. if n % 2 == 1: @@ -290,9 +288,6 @@ We also did few code reading exercises. -{{{ Show the "sponsored by FOSSEE" slide }}} +{{{ switch to next slide, Thank you }}} -This tutorial was created as a part of FOSSEE project, NME ICT, MHRD India - -Hope you have enjoyed and found it useful. Thank you!

--- a/matrices/script.rst Thu Nov 11 23:40:39 2010 +0530 +++ b/matrices/script.rst Thu Nov 11 23:44:59 2010 +0530 @@ -26,9 +26,10 @@ .. Author : Anoop Jacob Thomas <anoop@fossee.in> - Internal Reviewer : + Internal Reviewer : Puneeth External Reviewer : - Checklist OK? : <put date stamp here, if OK> [2010-10-05] + Language Reviewer : Bhanukiran + Checklist OK? : <11-11-2010, Anand, OK> [2010-10-05] .. #[punch: please mark the exercises, using the syntax we decided upon.] @@ -42,7 +43,7 @@ {{{ switch to next slide, outline slide }}} In this tutorial we will learn about matrices, creating matrices using -direct data, by converting a list and matrix operations. Finding +direct data, converting a list and matrix operations. Finding inverse of a matrix, determinant of a matrix, eigen values and eigen vectors of a matrix, norm and singular value decomposition of matrices. @@ -59,7 +60,7 @@ .. #[Puneeth: don't use ``matrix``. Use ``array``. The whole script will .. have to be fixed.] -Using the tuple ``m1.shape`` we can find out the shape or size of the +Using the method ``shape`` we can find out the shape or size of the matrix, ::

--- a/other-type-of-plots/script.rst Thu Nov 11 23:40:39 2010 +0530 +++ b/other-type-of-plots/script.rst Thu Nov 11 23:44:59 2010 +0530 @@ -20,7 +20,8 @@ .. Author : Anoop Jacob Thomas <anoop@fossee.in> Internal Reviewer : Puneeth External Reviewer : - Checklist OK? : <put date stamp here, if OK> [2010-10-05] + Language Reviewer : Bhanukiran + Checklist OK? : <10-11-2010, Anand, OK> [2010-10-05] .. #[Puneeth: Quickref missing] @@ -30,7 +31,7 @@ {{{ show the first slide }}} -Hello and welcome to the tutorial other type of plots. +Hello and welcome to the tutorial ``The other kinds of plots``. .. #[Puneeth: this sentence doesn't read well] @@ -40,10 +41,10 @@ .. them? Tell that we have only looked at one type of plot all the .. while, etc.] -Till now we have seen only one type of plot, and in this tutorial us -see more type of plots like scatter plot, pie chart, bar chart and -log-log plot. We will see few other more plots and also see an -introduction to matplotlib help. +Till now we have seen only one kind of plotting, and in this tutorial we +are going to see more kinds of plots such as the scatter plot, the pie chart, the bar chart and +the log-log plot. This tutorial covers the making of other kinds of +plots and also gives an introduction to matplotlib help. .. #[Puneeth: cover, see and introduce you. be consistent. does, the .. "We" include the viewer or not?] @@ -56,7 +57,7 @@ each having the value of one variable determining the position on the horizontal axis and the value of the other variable determining the position on the vertical axis. This kind of plot is also called a -scatter chart, scatter diagram and scatter graph. +scatter chart, a scatter diagram or a scatter graph. Before we proceed further, start your IPython interpreter :: @@ -70,7 +71,7 @@ exercise }}} Now, let us plot a scatter plot showing the percentage profit of -company A from the year 2000-2010. The data for the same is available +a company A from the year 2000-2010. The data for the same is available in the file ``company-a-data.txt``. {{{ open the file company-a-data.txt and show the content }}} @@ -81,7 +82,7 @@ {{{ close the file and switch to the terminal }}} -To produce the scatter plot first we need to load the data from the +To produce the scatter plot, we first need to load the data from the file using ``loadtxt``. We learned it in one of the previous sessions, and it can be done as :: @@ -119,8 +120,7 @@ .. scatter(year,profit,color='r',marker='d') -Now let us see another plot, pie chart and try to plot the same data -as a pie chart. +Now let us see another kind of plot, the pie chart, for the same data. .. #[Puneeth: instead of just saying that, say that let's plot a pie .. chart for the same data. continuity, will be good.] @@ -165,7 +165,7 @@ {{{ switch to the slide which says about bar chart }}} -Now let us move on to bar chart. A bar chart or bar graph is a chart +Now let us move on to the bar charts. A bar chart or bar graph is a chart with rectangular bars with lengths proportional to the values that they represent. @@ -202,7 +202,7 @@ {{{ switch to the slide which says about log-log graph }}} -Now let us move on to log-log plot. A log-log graph or log-log plot is +Now let us move on to the log-log plot. A log-log graph or a log-log plot is a two-dimensional graph of numerical data that uses logarithmic scales on both the horizontal and vertical axes. Because of the nonlinear scaling of the axes, a function of the form y = ax\ :sup:`b` will

--- a/savefig/script.rst Thu Nov 11 23:40:39 2010 +0530 +++ b/savefig/script.rst Thu Nov 11 23:44:59 2010 +0530 @@ -17,7 +17,8 @@ .. Author : Anoop Jacob Thomas <anoop@fossee.in> Internal Reviewer : Puneeth External Reviewer : - Checklist OK? : <put date stamp here, if OK> [2010-10-05] + Language Reviewer : Bhanukiran + Checklist OK? : <10-11-2010, Anand, OK> [2010-10-05] .. #[Puneeth: Quickref missing.] @@ -93,7 +94,7 @@ {{{ Highlight the .png part using mouse movements }}} -Here I have used an extension ``.png`` which means i want to save the +Here I have used an extension ``.png`` which means I want to save the image as a PNG file. Now let us locate ``sine.png`` file saved. We saved the file to

--- a/using python modules/script.rst Thu Nov 11 23:40:39 2010 +0530 +++ b/using python modules/script.rst Thu Nov 11 23:44:59 2010 +0530 @@ -20,7 +20,8 @@ .. Author : Anoop Jacob Thomas <anoop@fossee.in> Internal Reviewer : Puneeth External Reviewer : - Checklist OK? : <put date stamp here, if OK> [2010-10-05] + Language Reviewer : Bhanukiran + Checklist OK? : <11-11-2010, Anand, OK> [2010-10-05] ====================