Question: Arrays.py Write the following functions in Python. See the commented out part of the program for expected results. Also, make sure your functions dont modify

Arrays.py

Write the following functions in Python. See the commented out part of the program for expected results. Also, make sure your functions dont modify the array (if any received as parameter.

Arrays.py Write the following functions in Python. See the commented out part

7. Write the function first_n_rows (A,n) that receives a 2D array A and an integer n, where n>0, and returns a 2D array containing the first n rows of A (or all of A if A has less than n rows). 8. Write the function first_n_colums (A,n) that receives a 2D array A and an integer n, where n>0, and returns a 2D array containing the first n columns of A (or all of A if A has less than n columns). 9. Write the function last_n_rows (A,n) that receives a 2D array A and an integer n, where n>0, and returns a 2D array containing the last n rows of A (or all of A if A has less than n rows). 10. Write the function last_ n _colums (A,n) that receives a 2D array A and an integer n, where n>0, and returns a 2D array containing the last n columns of A (or all of A if A has less than n columns). array with r rows and c columns where every element is equal to n. 12. Write the function diagonal (A) that receives a square array A and returns a 1D array containing the elements in the diagonal of A (that is [A[0,0],A[1,1], ). 13. Write the function count_digits (A) that counts the number of times each of the numbers 0,1,,9 appears in an array. The function should receive an array A of any dimensionality and return a 1D array of length 10, where the first element in the array is the number of times 0 appears in A, the second element is the number of times 1 appears in A, and so on. Do this by having an array of counters count, then iterate over all elements of A, and for every element, check if it is a single digit, that is, it is greater or equal to 0 and less or equal to 9 , if the element is a digit, add one to the corresponding counter, otherwise do nothing

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!