getting-started-with-arrays/script.rst
changeset 304 d98f554bbec0
parent 261 c7f0069d698a
child 318 a45256cc5404
equal deleted inserted replaced
300:a130a1f494c3 304:d98f554bbec0
    69 
    69 
    70 And how can we make it a two dimensional array of order 2 by 4. Pause
    70 And how can we make it a two dimensional array of order 2 by 4. Pause
    71 here and try to do it yourself, try ``ar.tab`` and find a suitable
    71 here and try to do it yourself, try ``ar.tab`` and find a suitable
    72 method for that.
    72 method for that.
    73 
    73 
       
    74 {{{ switch to next slide, reshape() method }}}
       
    75 
    74 We can use the function ``reshape()`` for that purpose and it can be
    76 We can use the function ``reshape()`` for that purpose and it can be
    75 done as,
    77 done as,
    76 ::
    78 ::
    77 
    79 
    78     ar.reshape(2,4)
    80     ar.reshape(2,4)
    79     ar.reshape(4,2)
    81     ar.reshape(4,2)
    80     ar = ar.reshape(2,4)
    82     ar = ar.reshape(2,4)
       
    83 
       
    84 {{{ switch to next slide, creating array from list}}}
    81 
    85 
    82 Now, let us see how to convert a list object to an array. As you have
    86 Now, let us see how to convert a list object to an array. As you have
    83 already seen, in both of the previous statements we have passed a
    87 already seen, in both of the previous statements we have passed a
    84 list, so creating an array can be done so, first let us create a list
    88 list, so creating an array can be done so, first let us create a list
    85 ``l1``
    89 ``l1``
   108 ``a1.shape`` object is a tuple, and since a1 is a single dimensional
   112 ``a1.shape`` object is a tuple, and since a1 is a single dimensional
   109 array, it returned a tuple (4,).
   113 array, it returned a tuple (4,).
   110 
   114 
   111 {{{ switch to the next slide, unsolved exercise 2 }}}
   115 {{{ switch to the next slide, unsolved exercise 2 }}}
   112 
   116 
   113 Find out the shape of the other two arrays that we have created.
   117 Find out the shape of the other arrays that we have created.
   114 
   118 
   115 {{{ Array can have only a single type of data }}}
   119 {{{ Array can have only a single type of data }}}
   116 
   120 
   117 Now let us try to create a new array with a mix of elements and see
   121 Now let us try to create a new array with a mix of elements and see
   118 what will happen,
   122 what will happen,
   127 
   131 
   128     a4
   132     a4
   129 
   133 
   130 Did you notice it, 
   134 Did you notice it, 
   131 
   135 
       
   136 {{{ switch to next slide, implicit type casting }}}
       
   137 
   132 {{{ highlight all the array elements one by one using mouse 
   138 {{{ highlight all the array elements one by one using mouse 
   133 movements }}}
   139 movements }}}
   134 
   140 
   135 all the elements have been implicitly type casted as string, though
   141 all the elements have been implicitly type casted as string, though
   136 our first three elements were integers.
   142 our first three elements were integers.
   224     a1 * a2
   230     a1 * a2
   225 
   231 
   226 Returns an array with element by element multiplication, notice that
   232 Returns an array with element by element multiplication, notice that
   227 it does not perform matrix multiplication.
   233 it does not perform matrix multiplication.
   228 
   234 
   229 {{{ switch to next slide, recap slide }}}
   235 {{{ switch to next slide, summary slide }}}
   230 
   236 
   231 So this brings us to the end of this tutorial, in this tutorial we
   237 So this brings us to the end of this tutorial, in this tutorial we
   232 covered basics of arrays, how to create an array, converting a list to
   238 covered basics of arrays, how to create an array, converting a list to
   233 an array, basic array operations etc.
   239 an array, basic array operations etc.
   234 
   240