Question

In: Computer Science

Using Python : Create a 4×5 4 × 5 array ? X with random value. Print...

Using Python :

Create a 4×5 4 × 5 array ? X with random value. Print out ? X , as well as the largest value of each column.

Solutions

Expert Solution

Please find the answer below, Have mentioned all the details in the comments.

matrix.py:

import random as r
#row count
m = 4
#column count
n = 5

#matrix
X = []

#loops to generate the matrix with random values
for i in range(m):
row = []
for j in range(n):
# you need to increment through dataList here, like this:
row.append(r.random())
X.append(row)
  
#print matrix
print(X)
#to print max from each column
for j in range(n):
max_col = -1;
for i in range(m):
if(X[i][j] > max_col):
max_col = X[i][j]
print("Max in coloumn ", j , " is: ",max_col)

Output:

Please find the picture of the code snippet for your reference of the code indentaion:


Related Solutions

Using Python: Normalize a 5x5 random matrix hints: use numpy create a random matrix X apply...
Using Python: Normalize a 5x5 random matrix hints: use numpy create a random matrix X apply Normalization: (X - Mean) / Deviation
Create a two-dimensional array A using random integers from 1 to 10. Create a two-dimensional array B using random integers from -10 to 0.
This program is for C.Create a two-dimensional array A using random integers from 1 to 10. Create a two-dimensional array B using random integers from -10 to 0. Combine the elements of A + B to create two- dimensional array C = A + B. Display array A, B and C to the screen for comparison. (Note a[0] + b[0] = c[0], a[1] + b[1] = c[1], etc.)
Using Python Shell 2.7, create a file called Assignment6_1.py Create an array based on a basic...
Using Python Shell 2.7, create a file called Assignment6_1.py Create an array based on a basic array Create a for loop that will print the array index the array, print out the index append an element to the array, print out the array insert an element into the array, print out the array pop an element from the array, print out the array remove an element from the array, print out the array reverse the order of the array, print...
Using an array and a function, print the values of an array backwards. Please follow these...
Using an array and a function, print the values of an array backwards. Please follow these guidelines: - Setup your array manually (whichever values you want, as many as you want and whichever datatype you prefer). - Call your function. You should send two parameters to such function: the array’s length and the array. - Inside the function, go ahead and print the array backwards. - Your function shouldn’t return anything.
Write a program in Java that initializes an array with ten random integers and then print...
Write a program in Java that initializes an array with ten random integers and then print three lines of output, containing: Every element at an odd index Every odd element All elements in reverse order   The program should use three different methods to implement the functionalities above. Call the primary source file ArrayManipulator.java
5. Which value of x, with −4 ≤ x ≤ 4, corresponds to the global (absolute)...
5. Which value of x, with −4 ≤ x ≤ 4, corresponds to the global (absolute) maximum of the functions f(x) = x 2 (3x 2 − 4x − 36) + c, where c is some given real number? (a) −2 (b) 2 (c) 3 (d) 0 (e) None of the above. * 14. Find f(x) by solving the initial value problem. f 0 (x) = e x − 2x; f (0) = 2 (a) f (x) = e x...
2) create a python program that uses a for loop and range to print out the...
2) create a python program that uses a for loop and range to print out the values 10 8 6 4 2 3) Create a python program that yses a for loop to print out ["bob","al","bert"]
Write a program in c++ that reads x[4]. Then create the array y[6||6], such that the...
Write a program in c++ that reads x[4]. Then create the array y[6||6], such that the first quarter of y consists of the value of the first element of x. The second quarter of y consists of the value of the second element of x. The third quarter of y consists of the value of the third element of x. The fourth quarter of y consists of the value of the fourth element of x?
Using Python, Establish random centroids according to the k , and create your own algorithm to...
Using Python, Establish random centroids according to the k , and create your own algorithm to make clusters: create a functions kmeans() that accepts a dataframe and k as parameters, and returns the clusters created.
In C Create a multi-dimensional array and print it out forwards, backwards and then transpose.
In C Create a multi-dimensional array and print it out forwards, backwards and then transpose.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT