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 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
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"]
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.
WITH using methods create an array with numbers
IN JAVA  Prompt 3:WITH using methods create an array with numbersint [] number = { 35, 68, 80, 34, 45, 79, 80};Display the numbers in the array using for loopDisplay the sumFind biggest element in the arrayDisplay the numers in the array with index numbersDisplay the numers using for loop in ascending order (sort)
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.
Using Python and Kivy to create a App to ask users 5 questions with Yes or...
Using Python and Kivy to create a App to ask users 5 questions with Yes or No button. 1. Are you older than 14? 2. Did you pass 8th or 9th Grade? 3. Are you ready gor highschool? 4. Do you have 4 more years to complete highschool? 5. Are you homeschool? If the users click Yes for 3 questions or more than you should get a results page saying this users is in highschool or else the user is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT