Question: 1. Implement the following function in the PyDev module functions . py and test it from a PyDev module named to1 . py: def generate_matrix_num(rows,

 1. Implement the following function in the PyDev module functions .py and test it from a PyDev module named to1 . py:def generate_matrix_num(rows, cols, low, high, value_type): Generates a 20 list of numbersof the given type, 'float' or 'int'. (To generate random float numberuse random. uniform and to generate random integer number use random. randint)

1. Implement the following function in the PyDev module functions . py and test it from a PyDev module named to1 . py: def generate_matrix_num(rows, cols, low, high, value_type): Generates a 20 list of numbers of the given type, 'float' or 'int'. (To generate random float number use random. uniform and to generate random integer number use random. randint) Use: matrix = generate_matrix_num(rows, cols, low, high, value_type) Parameters: 10 rows - number of rows in the list (int > 0) 11 cols - number of columns (int > 0) 12 low - low value of range (float) 13 high - high value of range (float > low) 14 value_type - type of values in the list, 'float' or 'int' (str) 15 Returns : 16 matrix - a 2D list of random numbers (20 list of float/int) 17 18 unn Sample testing: Number of rows : 3 Number of columns : 4 Low value: =10 High value: 10 Type of values: float [[-6 . 715521262896857, 2. 832332263818408, -9. 639174469550253, -7. 413579152118894], [-5. 711470115891877, -8. 196169662276777, 5. 957379822776547, ,-1.3505501293285107], [6. 01327913528462, 0.5179270486063707, 2.22213388673. Implement the following function in the PyDev module functions . py and test it from a PyDev module named to3 . py: def print_matrix_num(matrix, value_type) : Prints the contents of a 20 list in a formatted table. Prints float values with 2 decimal points and prints row and column headings. Use: print_matrix_num(matrix, 'float') 10 00 - Use: print_matrix_num(matrix, 'int') 10 Parameters : 11 matrix - a 20 list of values (20 list) 12 value_type - type of values in the list, 'float' or 'int' (str) 13 Returns : 14 None . 15 16 Sample testing: Number of rows : 3 Number of columns: 4 Low value: =10 High value: 10 Type of values: float 0 1 2 3 3. 19 5 . 40 0. 00 6. 38 HO -5. 07 3.55 -6.90 -0.73 N -6.91 7.86 0. 24 -8 . 407. Implement the following function in the PyDev module functions .py and test it from a PyDev module named t97. py: 1 def Find_position(matrix): 2 """ 3 _______________________________________________________ 4 Determines the first locations [row, column] of smallest and 5 largest values in a 20 list. 6 Use: s_loc, l_loc = find_position(matrix) 7 _______________________________________________________ 8 Parameters: 9 matrix a EU list of numbers (ZD list) 10 Returns: 11 s_loc - a list of of the row and column location of 12 the smallest value in matrix (list of int) 13 l_loc - a list of of the row and column location of 14 the largest value in matrix (list of int) 15 16 """ Sampbtemmg: Number of rows: 4 Number of columns: 3 Low value: 10 High value: 10 0 1 2 0 3 10 9 1 2 5 6 4 3 0 4 7 Smallest position: [0, 1] Smallest value: 10 Largest position: [1, 1] Largest Value: 10 13. Implement the following function in the PyDev module functions . py and test it from a PyDev module named t13 . py: def scalar_multiply(matrix, num) : OUIAWN Update matrix by multiplying each element of matrix by num. Use: scalar_multiply(matrix, num) Parameters : matrix - the matrix to multiply (20 list of int/float) 10 0O num - the number to multiply by (int/float) 10 Returns : 11 None 12 13 Sample testing: Matrix before scalar multiplication: 0 IN -6 CO W WW HaHa N Enter number : 5 Matrix after scalar multiplication: 1 2 35 -30 HO -30 15 5 -20 15 30 WN -25 40 514. Implement the following function in the PyDev module Functions .py and test it from a PyDev module named t14. py: 1 def matrix_transpose(a): 2 ..." 3 _______________________________________________________ 4 Transpose the contents of matrix a. 5 Use: b = matrix_transpose(a): 6 _______________________________________________________ 7 Parameters: 8 a a 2D list (2D list of ?) 9 Returns: 10 b - the transposed matrix (20 'List of ?) 11 12 '\"\"' Sample testing: Original matrix: 0 1 2 O 5 4 9 1 5 0 7 2 6 9 10 3 5 9 3 0 1 2 3 0 5 5 6 5 1 4 0 9 9 2 9 7 10 3

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 Programming Questions!