# HG changeset patch # User Puneeth Chaganti # Date 1286954531 -19800 # Node ID a45256cc540419f0ceda4cfa06a4bfd9a6384cd5 # Parent c6d31837cb06d9889005346a24dd4b9db05426b2 Reviewed getting started with arrays, script. diff -r c6d31837cb06 -r a45256cc5404 getting-started-with-arrays/script.rst --- a/getting-started-with-arrays/script.rst Wed Oct 13 11:15:37 2010 +0530 +++ b/getting-started-with-arrays/script.rst Wed Oct 13 12:52:11 2010 +0530 @@ -11,29 +11,56 @@ .. * array operations .. + =+ - * /= +.. Objectives +.. ---------- + +.. Clearly state the objectives of the LO (along with RBT level) + +.. Prerequisites +.. ------------- + +.. 1. Name of LO-1 +.. 2. Name of LO-2 +.. 3. Name of LO-3 + +.. Author: Anoop Jacob Thomas + Internal Reviewer : Puneeth + External Reviewer : + Checklist OK? : [2010-10-05] + =========================== Getting started with Arrays =========================== +.. #[Puneeth: Prerequisites and Objectives are missing. Fill them in] + {{{ show the welcome slide }}} Welcome to the spoken tutorial on getting started with arrays. {{{ switch to next slide, outline slide }}} -In this tutorial, we will learn about arrays, how to convert a list -into an array and also why an array is preferred over lists. And array -operations. +In this tutorial, we will learn about arrays, how to convert a list into an +array and also why an array is preferred over lists. And array operations. + +.. #[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. +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. + +.. #[Puneeth: Use multiple short sentences, rather than one long sentence + I would've written something like this. -Arrays are really fast in mathematical operations when compared to -lists, it is at least 80 to 100 times faster than lists. + 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, +it is at least 80 to 100 times faster than lists. + +.. #[Puneeth: For what size of an array is that the comparison? {{{ switch to the next slide, creating arrays }}} @@ -42,39 +69,63 @@ I am assuming that you have your IPython interpreter running with the ``-pylab`` option, so that you have the required modules loaded. +.. #[Puneeth: 'I am assuming' doesn't sound right. Ask them to open if it +.. is not open?] + To create an array we will use the function ``array()`` as, + :: a1 = array([1,2,3,4]) -Notice that here we created a one dimensional array. Also notice the -object we passed to create an array. Now let us see how to create a -two dimensional array. Pause here and try to do it yourself before -looking at the solution. +Notice that here we created a one dimensional array. Also notice the object +we passed to create an array. Now let us see how to create a two +dimensional array. Pause here and try to do it yourself before looking at +the solution. + +.. #[Puneeth: I don't think this question can be solved by an average +.. viewer. Questions during the tutorial, should generally be to re-iterate +.. concepts learnt? ] + +.. #[Puneeth: Also, you didn't even point out that we are converting a +.. list, using the ``array`` function. Bring the later section about +.. converting a list, here. A separate section is not necessary, IMHO.] This is how we create two dimensional arrays. + :: a2 = array([[1,2,3,4],[5,6,7,8]]) +.. #[Puneeth: Again, you could explain a bit about the fact that we are +.. converting a list of lists.] + Let us see an easy method of creating an array with elements 1 to 8. + :: ar = arange(1,9) +.. #[Puneeth: say, creating the same array as before. for some time I got +.. confused .] + And it created a single dimensional array of elements from 1 to 8. + :: print ar -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. +.. #[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 try to do it yourself, try ``ar.tab`` and find a suitable method for +that. {{{ switch to next slide, reshape() method }}} -We can use the function ``reshape()`` for that purpose and it can be -done as, +We can use the function ``reshape()`` for that purpose and it can be done +as, + :: ar.reshape(2,4) @@ -84,14 +135,15 @@ {{{ switch to next slide, creating array from list}}} Now, let us see how to convert a list object to an array. As you have -already seen, in both of the previous statements we have passed a -list, so creating an array can be done so, first let us create a list -``l1`` +already seen, in both of the previous statements we have passed a list, so +creating an array can be done so, first let us create a list ``l1`` + :: l1 = [1,2,3,4] -Now we can convert the list to an array as, +Now we can convert the list to an array as, + :: a3 = array(l1) @@ -101,70 +153,96 @@ Create a three dimensional array of the order (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 check the shape of the arrays we have created so far, + +.. #[Puneeth: s/object/method ?] + :: a1.shape -``a1.shape`` object is a tuple, and since a1 is a single dimensional -array, it returned a tuple (4,). +``a1.shape`` object is a tuple, and since a1 is a single dimensional array, +it returned a tuple (4,). + +.. #[Puneeth: first show a 2D array, so that it becomes easier to explain. +.. Also, the word ``tuple`` need not be mentioned. ] {{{ switch to the next slide, unsolved exercise 2 }}} Find out the shape of the other arrays that we have created. +.. #[Puneeth: solution missing.] + {{{ Array can have only a single type of data }}} -Now let us try to create a new array with a mix of elements and see -what will happen, +.. #[Puneeth: I guess, this whole section can be skipped. If you want to +.. keep this, just briefly mention that arrays are homogeneous in the +.. intro, don't explain it there.] + +Now let us try to create a new array with a mix of elements and see what +will happen, + :: 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 in the new array created. In your IPython terminal type, +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 +in the new array created. In your IPython terminal type, :: a4 -Did you notice it, +Did you notice it, {{{ switch to next slide, implicit type casting }}} -{{{ highlight all the array elements one by one using mouse -movements }}} +.. #[Puneeth: typecasting may be unnecessary. (Also too advanced?) an +.. average guy wouldn't use arrays with strings.] + +.. #[Puneeth: You may want to mention that float is the default dtype.] -all the elements have been implicitly type casted as string, though -our first three elements were integers. +{{{ 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. + +.. #[Puneeth: when I type a4 it says some ``dtype`` etc. I don't understand +.. what it is, can you explain? ;)] {{{ switch to the next slide, identity & zeros methods }}} -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 ``identity()``. +.. #[Puneeth: something needs to motivate this. why are we suddenly talking +.. of an 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 ``identity()``. The function ``identity()`` takes an integer argument, + :: identity(3) -As you can see the identity method returned a three by three square -array with all the diagonal elements as one and the rest of the -elements as zero. +As you can see the identity method returned a three by three square array +with all the diagonal elements as one and the rest of the elements as zero. -``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. +.. #[Puneeth: You say array here, matrix there -- it's a bit messed up. +.. Clarify, explicitly.] -{{{ switch to the next slide, problem statement of the solved exercise -1 }}} +``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. -Let us creates an array of the order four by five with all the -elements zero. We can do it using the method zeros, -:: +{{{ switch to the next slide, problem statement of solved exercise 1 }}} + +Let us creates an array of the order four by five with all the elements +zero. We can do it using the method zeros, :: zeros((4,5)) @@ -216,8 +294,7 @@ a -We can use all the mathematical operations with arrays, Now let us try -this +We can use all the mathematical operations with arrays, Now let us try this :: a1 = array([1,2,3,4]) @@ -229,20 +306,25 @@ a1 * a2 -Returns an array with element by element multiplication, notice that -it does not perform matrix multiplication. +Returns an array with element by element multiplication, notice that it +does not perform matrix multiplication. {{{ switch to next slide, summary slide }}} -So this brings us to the end of this tutorial, in this tutorial we -covered basics of arrays, how to create an array, converting a list to -an array, basic array operations etc. +So this brings us to the end of this tutorial, in this tutorial we covered +basics of arrays, how to create an array, converting a list to an array, +basic array operations etc. + +.. #[Puneeth: s/how to create an array/creating an array] {{{ switch to next slide, thank you }}} Thank you! -.. Author: Anoop Jacob Thomas - Reviewer 1: - Reviewer 2: - External reviewer: +.. + Local Variables: + mode: rst + indent-tabs-mode: nil + sentence-end-double-space: nil + fill-column: 75 + End: diff -r c6d31837cb06 -r a45256cc5404 progress.org --- a/progress.org Wed Oct 13 11:15:37 2010 +0530 +++ b/progress.org Wed Oct 13 12:52:11 2010 +0530 @@ -1,55 +1,55 @@ -| S.No | Name | Units | Author | 1st Review (Status) | 2nd Review (Status) | -|---------+----------------------------------------+-------+----------+---------------------+---------------------| -| 1.2 LO: | getting started with =ipython= | 2 | Punch | | | -| 1.3 LO: | using the =plot= command interactively | 2 | Amit | Anoop (Pending) | Puneeth (Pending) | -| 1.4 LO: | embellishing a plot | 2 | Nishanth | Anoop (Done) | Madhu (Done) | -| 1.5 LO: | saving plots | 2 | Anoop | | | -| 1.6 LO: | multiple plots | 3 | Madhu | Nishanth (Done) | Punch (Pending) | -| 1.7 LO: | additional features of IPython | 2 | Nishanth | Amit (Pending) | Madhu (Pending) | -| 1.8 LO: | module level assessment | 3 | Madhu | | | -|---------+----------------------------------------+-------+----------+---------------------+---------------------| -| 2.2 LO: | loading data from files | 3 | Punch | Nishanth (Done) | Anoop (Pending) | -| 2.3 LO: | plotting the data | 3 | Amit | Anoop (Pending) | Punch (Pending) | -| 2.4 LO: | other types of plots | 3 | Anoop | | | -| 2.5 LO: | module level assessment | 3 | Nishanth | | | -|---------+----------------------------------------+-------+----------+---------------------+---------------------| -| 3.1 LO: | getting started with lists | 2 | Amit | Madhu (Pending) | Nishanth (Done) | -| 3.2 LO: | getting started with =for= | 2 | Anoop | Nishanth (Done) | Amit (Done) | -| 3.3 LO: | getting started with strings | 2 | Madhu | | | -| 3.4 LO: | getting started with files | 3 | Punch | | | -| 3.5 LO: | parsing data | 3 | Nishanth | Amit (Done) | Punch (Pending) | -| 3.6 LO: | statistics | 2 | Amit | Anoop (Pending) | Puneeth (Pending) | -| 3.7 LO: | module level assessment | 3 | Madhu | | | -|---------+----------------------------------------+-------+----------+---------------------+---------------------| -| 4.1 LO: | getting started with arrays | 2 | Anoop | | | -| 4.2 LO: | accessing parts of arrays | 4 | Punch | | | -| 4.3 LO: | Matrices | 3 | Anoop | | | -| 4.4 LO: | Least square fit | 2 | Nishanth | Punch (Pending) | Anoop (Pending) | -| 4.5 LO: | Assessment | 3 | Punch | | | -|---------+----------------------------------------+-------+----------+---------------------+---------------------| -| 5.1 LO: | getting started with sage notebook | 3 | Madhu | | | -| 5.2 LO: | getting started with symbolics | 3 | Amit | Madhu (Pending) | Nishanth (Pending) | -| 5.3 LO: | using Sage | 4 | Punch | | | -| 5.4 LO: | using sage to teach | 3 | Nishanth | | | -| 5.5 LO: | Assessment | 3 | Anoop | | | -|---------+----------------------------------------+-------+----------+---------------------+---------------------| -| 6.1 LO: | basic datatypes & operators | 4 | Amit | Madhu (Pending) | Nishanth (Done) | -| 6.2 LO: | I/O | 1 | Nishanth | | | -| 6.3 LO: | conditionals | 2 | Madhu | | | -| 6.4 LO: | loops | 2 | Puneeth | | | -| 6.5 LO: | Assessment | 3 | Anoop | | | -|---------+----------------------------------------+-------+----------+---------------------+---------------------| -| 7.1 LO: | manipulating lists | 3 | Madhu | | | -| 7.2 LO: | manipulating strings | 2 | Punch | | | -| 7.3 LO: | getting started with tuples | 2 | Nishanth | | | -| 7.4 LO: | dictionaries | 2 | Anoop | | | -| 7.5 LO: | sets | 2 | Nishanth | | | -| 7.6 LO: | Assessment | 3 | Amit | | | -|---------+----------------------------------------+-------+----------+---------------------+---------------------| -| 8.1 LO: | getting started with functions | 3 | Nishanth | | | -| 8.2 LO: | advanced features of functions | 3 | Punch | | | -| 8.3 LO: | using python modules | 3 | Anoop | | | -| 8.4 LO: | writing python scripts | 2 | Nishanth | | | -| 8.5 LO: | testing and debugging | 2 | Amit | | | -| 8.6 LO: | Assessment | 3 | Madhu | | | -|---------+----------------------------------------+-------+----------+---------------------+---------------------| +| S.No | Name | Units | Author | Review | Checklist | +|---------+----------------------------------------+-------+----------+-----------------+-----------| +| 1.2 LO: | getting started with =ipython= | 2 | Punch | | | +| 1.3 LO: | using the =plot= command interactively | 2 | Amit | Anoop (Pending) | | +| 1.4 LO: | embellishing a plot | 2 | Nishanth | Anoop (Done) | | +| 1.5 LO: | saving plots | 2 | Anoop | | | +| 1.6 LO: | multiple plots | 3 | Madhu | Nishanth (Done) | | +| 1.7 LO: | additional features of IPython | 2 | Nishanth | Amit (Pending) | | +| 1.8 LO: | module level assessment | 3 | Madhu | | | +|---------+----------------------------------------+-------+----------+-----------------+-----------| +| 2.2 LO: | loading data from files | 3 | Punch | Nishanth (Done) | | +| 2.3 LO: | plotting the data | 3 | Amit | Anoop (Pending) | | +| 2.4 LO: | other types of plots | 3 | Anoop | | | +| 2.5 LO: | module level assessment | 3 | Nishanth | | | +|---------+----------------------------------------+-------+----------+-----------------+-----------| +| 3.1 LO: | getting started with lists | 2 | Amit | Madhu (Pending) | | +| 3.2 LO: | getting started with =for= | 2 | Anoop | Nishanth (Done) | | +| 3.3 LO: | getting started with strings | 2 | Madhu | | | +| 3.4 LO: | getting started with files | 3 | Punch | | | +| 3.5 LO: | parsing data | 3 | Nishanth | Amit (Done) | | +| 3.6 LO: | statistics | 2 | Amit | Anoop (Pending) | | +| 3.7 LO: | module level assessment | 3 | Madhu | | | +|---------+----------------------------------------+-------+----------+-----------------+-----------| +| 4.1 LO: | getting started with arrays | 2 | Anoop | Punch (Done) | | +| 4.2 LO: | accessing parts of arrays | 4 | Punch | | | +| 4.3 LO: | Matrices | 3 | Anoop | | | +| 4.4 LO: | Least square fit | 2 | Nishanth | Punch (Pending) | | +| 4.5 LO: | Assessment | 3 | Punch | | | +|---------+----------------------------------------+-------+----------+-----------------+-----------| +| 5.1 LO: | getting started with sage notebook | 3 | Madhu | | | +| 5.2 LO: | getting started with symbolics | 3 | Amit | Madhu (Pending) | | +| 5.3 LO: | using Sage | 4 | Punch | | | +| 5.4 LO: | using sage to teach | 3 | Nishanth | | | +| 5.5 LO: | Assessment | 3 | Anoop | | | +|---------+----------------------------------------+-------+----------+-----------------+-----------| +| 6.1 LO: | basic datatypes & operators | 4 | Amit | Madhu (Pending) | | +| 6.2 LO: | I/O | 1 | Nishanth | | | +| 6.3 LO: | conditionals | 2 | Madhu | | | +| 6.4 LO: | loops | 2 | Puneeth | | | +| 6.5 LO: | Assessment | 3 | Anoop | | | +|---------+----------------------------------------+-------+----------+-----------------+-----------| +| 7.1 LO: | manipulating lists | 3 | Madhu | | | +| 7.2 LO: | manipulating strings | 2 | Punch | | | +| 7.3 LO: | getting started with tuples | 2 | Nishanth | | | +| 7.4 LO: | dictionaries | 2 | Anoop | | | +| 7.5 LO: | sets | 2 | Nishanth | | | +| 7.6 LO: | Assessment | 3 | Amit | | | +|---------+----------------------------------------+-------+----------+-----------------+-----------| +| 8.1 LO: | getting started with functions | 3 | Nishanth | | | +| 8.2 LO: | advanced features of functions | 3 | Punch | | | +| 8.3 LO: | using python modules | 3 | Anoop | | | +| 8.4 LO: | writing python scripts | 2 | Nishanth | | | +| 8.5 LO: | testing and debugging | 2 | Amit | | | +| 8.6 LO: | Assessment | 3 | Madhu | | | +|---------+----------------------------------------+-------+----------+-----------------+-----------|