Dec-10-2017, 08:13 PM
Hi,
I'm a student to 1st semester and I have a problem to solve:
"Create a 5x5 random number table and calculate the sum of items per line, per column, and the sum of the elements in the diagonal table. Save the results to a text file."
This is my code until to the sum of items per line. After that I'm stuck!
Thanks in advance,
gmit
I'm a student to 1st semester and I have a problem to solve:
"Create a 5x5 random number table and calculate the sum of items per line, per column, and the sum of the elements in the diagonal table. Save the results to a text file."
This is my code until to the sum of items per line. After that I'm stuck!
import random f=[] for i in range (5): line = [] for j in range (5): line.append(random.randint(1,10)) f.append(line) for each in f: print(each) print (sum(each))If anyone knows please reply.
Thanks in advance,
gmit