Term 
        
        What is the value of np.array(['a', 'b', 'c'])[2] ?  |  
          | 
        
        
        Definition 
         | 
        
        
         | 
        
        
        Term 
        
        What is the value of np.zeros(6).size?  |  
          | 
        
        
        Definition 
         | 
        
        
         | 
        
        
        Term 
        
        | Write code to get the 2nd and 3rd elements of array x. |  
          | 
        
        
        Definition 
         | 
        
        
         | 
        
        
        Term 
        
        What values are printed by the following code? 
x = np.array([2,4,6,8,10]) 
print(x[1:4])  |  
          | 
        
        
        Definition 
         | 
        
        
         | 
        
        
        Term 
        
        What is the result of this code? 
x = np.array([4,6,2,4,9,5]) 
x < 5  |  
          | 
        
        
        Definition 
        
        True, False,  True,  True, False, False  |  
          | 
        
        
         | 
        
        
        Term 
        
        What is the result of this code?  (write 'error' if error) 
x = np.array([4,6,2,4,9,5]) 
y = np.array([3]) 
x < y  |  
          | 
        
        
        Definition 
        
        False, False,  True, False, False, False 
  
Even though the arrays have different sizes, broadcasting makes the result the same as if y = np.array([3,3,3,3,3,3,]). 
   |  
          | 
        
        
         | 
        
        
        Term 
        
        What is the result of this code? 
  
x = np.array([4, 6, 2, 5]) 
x[[True, True, False, True]]  |  
          | 
        
        
        Definition 
         | 
        
        
         | 
        
        
        Term 
        
        What is the result of this code? 
  
x = np.array([4, 6, 2, 5]) 
x[x < 5]  |  
          | 
        
        
        Definition 
         | 
        
        
         | 
        
        
        Term 
        
        What is the result of this code? 
  
x = np.array([2, 0, 1, 6]) 
y = np.array([1, 2, 3, 4]) 
y[x < 2]  |  
          | 
        
        
        Definition 
         | 
        
        
         | 
        
        
        Term 
        
        What's the result of this code?  (say 'error' if an error) 
  
x = np.array([4, 6, 2, 4, 9, 5]) 
x[[4,4,3]]  |  
          | 
        
        
        Definition 
        
        The array [5, 5, 9] 
  
This is "fancy indexing", where an array (or list) is used to index into an array.  |  
          | 
        
        
         | 
        
        
        Term 
        
        What's the result of this code?  (say 'error' if an error) 
  
x = np.array([4, 6, 3, 12, 8, 1]) 
x[[np.ones(3)]]  |  
          | 
        
        
        Definition 
         | 
        
        
         | 
        
        
        Term 
        
        What's the result of this code?  (say 'error' if an error) 
  
x = np.array([4, 6, 3, 12, 8, 1, 9]) 
x[x[1:3]]  |  
          | 
        
        
        Definition 
        
        Array [9, 12]. 
  
This is a tricky.  x[1:3] gives array [6,3]. 
x[[6,3]] is array [9, 12]  |  
          | 
        
        
         | 
        
        
        Term 
        
        What's the result of this code?  (say 'error' if an error) 
  
x = np.array([4, 6, 3, 12, 8, 1, 9]) 
x[4,2]  |  
          | 
        
        
        Definition 
        
        Error. 
  
But x[[4,2]] gives array [8,3]  |  
          | 
        
        
         | 
        
        
        Term 
        
        What's the result of this code?  (say 'error' if an error) 
  
x = np.array([1.2, 2.3, -3.4, 4.5]) 
np.concat(x, x[x > 3])  |  
          | 
        
        
        Definition 
        
        It's an error, because the arrays to be concatenated need to be in a list (or tuple). 
  
But this works: np.concat([x, x[x > 3]]).  |  
          | 
        
        
         | 
        
        
        Term 
        
        What's the result of this code?  (say 'error' if an error) 
  
x = np.array([3,2,1]) 
y = np.array([1,2,3]) 
np.concat([x,y,x])  |  
          | 
        
        
        Definition 
        
        Array [3,2,1,1,2,3,3,2,1]  |  
          | 
        
        
         | 
        
        
        Term 
        
        What's the result of this code?  (say 'error' if an error) 
  
x = np.array([3,2,1]) 
np.concat([x,x]).size  |  
          | 
        
        
        Definition 
        
        6 
  
size gives the number of values in an array  |  
          | 
        
        
         | 
        
        
        Term 
        
        What's the result of this code?  (say 'error' if an error) 
  
np.arange(3) > 1  |  
          | 
        
        
        Definition 
        
        Array [False, False, True]  |  
          | 
        
        
         | 
        
        
        Term 
        
        What is the result of this code? 
  
x = np.array([4, 6, 2, 5]) 
x[x < 5]  |  
          | 
        
        
        Definition 
         | 
        
        
         |