Answer the question
In order to leave comments, you need to log in
How to display a matrix in a classical form (not a linear list)?
Hello!
There is a script that displays the matrix as a linear list:
import random
z = 4
x = random.sample(range(50), z)
y = random.sample(range(50), z)
for i in x:
for u in y:
print(i*u)
14
259
343
42
68
1258
1666
204
74
1369
1813
222
84
1554
2058
252
[1, 2, 3, 4]
[1, 2, 3, 4]
4 8 12 16
3 6 9 12
2 4 6 8
1 2 3 4
Answer the question
In order to leave comments, you need to log in
Two days - yes you are cool, my head hurts from a five-minute thought!
for i in x:
print(*[i*u for u in y])
import random
z = 4
x = random.sample(range(50), z)
y = random.sample(range(50), z)
for i in x:
for u in y:
print('{:4d}'.format(i*u), end=' ')
print('')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question