import random
matrix = []
subarray = []
dim_m = int(input("Input amount of rows"))
dim_n = int(input("Input amount of columns"))
rand_gen_top = int(input("Input random generation max value"))
rows_avg_list = []
cols_avg_list = []
rows_avg = 0
cols_avg = 0
for i in range(0, dim_n, 1):
for j in range(0, dim_m, 1):
subarray.append(random.randint(0, rand_gen_top))
rows_avg += subarray[j]
matrix.append(subarray)
rows_avg_list.append(rows_avg / dim_m)
cols_avg += matrix[i][j]
cols_avg_list.append(cols_avg / dim_n)
print("\nMatrix dimension m =", dim_m)
print("\nMatrix dimension n =", dim_n)
print("\nRange of random generated numbers from 0 to:", rand_gen_top)
print("\nMatrix A:\n")
for i in range(0, dim_m, 1):
print(matrix[i])
print("\nAverage in rows:", rows_avg_list)
print("\nAverage in columns:", cols_avg_list)
import random
matrix = []
subarray = []
dim_m = int(input("Input amount of rows"))
dim_n = int(input("Input amount of columns"))
rand_gen_top = int(input("Input random generation max value"))
rows_avg_list = []
cols_avg_list = []
rows_avg = 0
cols_avg = 0
for i in range(0, dim_n, 1):
for j in range(0, dim_m, 1):
subarray.append(random.randint(0, rand_gen_top))
rows_avg += subarray[j]
matrix.append(subarray)
rows_avg_list.append(rows_avg / dim_m)
subarray = []
rows_avg = 0
for j in range(0, dim_m, 1):
for i in range(0, dim_n, 1):
cols_avg += matrix[i][j]
cols_avg_list.append(cols_avg / dim_n)
cols_avg = 0
print("\nMatrix dimension m =", dim_m)
print("\nMatrix dimension n =", dim_n)
print("\nRange of random generated numbers from 0 to:", rand_gen_top)
print("\nMatrix A:\n")
for i in range(0, dim_m, 1):
print(matrix[i])
print("\nAverage in rows:", rows_avg_list)
print("\nAverage in columns:", cols_avg_list)