Lecture  6 – Assignment 6
Part I

1.  Explain the statement “from numpy import array.”

•   It imports the array function from the numpy library into Python

2.  Explain “data = array(data)”

•   It converts the data variable into a NumPy array

3.  What does the array( ) function do to the list of lists?
•   It converts a list of lists to a NumPy array

4.  Fill-in-the-blank: Once your data is represented using a NumPy array, you can access it using __________ .
•   indexing

5.  Explain “print(data[0]”
•   It prints the value of the first element in the data array.

6.  Explain the index, -2
•   It accesses the second to last element in thet list or array.

7.  Explain the statement “data = array([11,22,33,44,55]).” What does it do?
•   It creates a NumPy array named data  with the values [11, 22, 33, 44, 55].

8.  Explain the output, data[0,0].
•   It accesses the element at the first row and first column of a two-dimensional array data.

9.  Explain “data[0, ].”
•   It accesses the first row of a two-dimensional array data in NumPy.

10. What does it mean when we say that structures can be sliced?
•   It means that a subsequence of the structure can be indexed and retrieved.

11. Fill-in -the-blank: The slice extends from the “from” index and ends ______ ______ ________ ________ ________ ______.
•   one item before the to index

12. Explain “data[ : ]”
•   It accesses all the elements in a two-dimensional array data.

13. Explain “data[ -3: ]”
•   It slices the last three rows of a two-dimensional array data.

14. In a 2D, explain what is meant by the statement, y = [ : , -1]
•   It selects all rows in the array and the last column only

15. Explain the statement “train = data[ :split, : ]”
•   The training dataset would be all rows from the beginning to the split point

16. Explain the statement “test = data[split: , : ]”
•   The test dataset would be all rows starting from the split point to the end of the dimension

17. Explain the tuple (6, 5) in terms of dimension and shape, and/or rehape.
•   It represents an array with 6 rows and 5 columns

18. Explain ‘Rows: %d’ % data.shape[0]
•   It uses a string formatting to create a string representation that includes the number of rows in the data array

19. What does the function, reshape( ), do?
•   It takes a single argument that specifies the new shape of the array.

20. Explain the arguments in the parentheses: (data.shape[0], data.shape[1], 1)


Part II
Directions:  In this section, use Jupyter Notebook.  All work should be done using python.  Upload your work to HTML.  Then highlight via HTML and upload to GT Canvas.

1.  What is the difference between a list and an array?
•   List can store elements of different types, but arrays can store elements only of the same type. List provides more flexibility as it doesn't require explicit looping, but arrays require explicit looping to print elements.

2.  Explain what is being done in the following algorithm (or chunk of code).
•   X1 = array([5,6])
•   print(x1)
•   x2 = array([8,9])
•   print(x2)
•   it will print two arrays, the first is [5, 6] and the second is [8,9]

3.  Given the array, array([1,3,2,6]), explain and state the following indexes.
•   data[1] 
•   data[3]
•   data[ -3]
•   data[ -4]
•   data[0]

•   data[1] is 3,  data[3] is 6, data[-3] is 3, data[-4] is 1 and data[0] is 1 

4.  Given the following array, array([6,8,10,12,15]), explain and state the following slicing of a subset of the indicated array.
•   data[0:3]
•   data[ -2: ]
•   data[3:4]
•   data[1:4]

•   data[0:3] is 6, 8, 10, 12
•   data[-2: ] is 12, 15
•   data [3:4] is 12, 15
•   data[1,4] is 8, 10, 12, 15