accessing-pieces-arrays/script.rst
changeset 457 68813d8d80fb
parent 402 9bf3411b264d
equal deleted inserted replaced
456:be96dc6c9743 457:68813d8d80fb
    60              [51, 52, 53, 54, 55]])
    60              [51, 52, 53, 54, 55]])
    61 
    61 
    62 Pause the video here and make sure you have the arrays A and C,
    62 Pause the video here and make sure you have the arrays A and C,
    63 typed in correctly.
    63 typed in correctly.
    64 
    64 
       
    65 {{{ Pause the recording and type the arrays A,C }}}
       
    66 
    65 Let us begin with the most elementary thing, accessing individual
    67 Let us begin with the most elementary thing, accessing individual
    66 elements. Also, let us first do it with the one-dimensional array
    68 elements. Also, let us first do it with the one-dimensional array
    67 A, and then do the same thing with the two-dimensional array. 
    69 A, and then do the same thing with the two-dimensional array. 
    68 
    70 
    69 To access, the element 34 in A, we say, 
    71 To access, the element 34 in A, we say, 
    70 
    72 
    71 ::
    73 ::
    72 
    74 
    73   A[2]
    75   A[2]
    74 
    76 
       
    77 A of 2, note that we are using square brackets.
       
    78 
    75 Like lists, indexing starts from 0 in arrays, too. So, 34, the
    79 Like lists, indexing starts from 0 in arrays, too. So, 34, the
    76 third element has the index 2. 
    80 third element has the index 2. 
    77 
    81 
    78 Now, let us access the element 34 from C. To do this, we say
    82 Now, let us access the element 34 from C. To do this, we say
    79 ::
    83 ::
    80 
    84 
    81   C[2, 3]
    85   C[2, 3]
       
    86 
       
    87 C of 2,3.
    82 
    88 
    83 34 is in the third row and the fourth column, and since indexing
    89 34 is in the third row and the fourth column, and since indexing
    84 begins from zero, the row index is 2 and column index is 3. 
    90 begins from zero, the row index is 2 and column index is 3. 
    85 
    91 
    86 Now, that we have accessed one element of the array, let us change
    92 Now, that we have accessed one element of the array, let us change