Using Python : without using a for loop
Create a 4×5 4 × 5 array ? X with random value. Print out ? X , as well as the largest value of each column.
import random X = [] for i in range(4): tmp = [] for j in range(5): tmp.append(random.randint(1,100)) X.append(tmp) print("Content of array X:") for i in range(4): for j in range(5): print(X[i][j],end="\t") print() for j in range(5): maxValue = -1 for i in range(1,4): if(maxValue < X[i][j]): maxValue = X[i][j] print("Max value of column",j,"is",maxValue)
Get Answers For Free
Most questions answered within 1 hours.