Write a program which takes 2 digits, x,y as input and generates a 2-dimensional array. The element value in the i-th row and j-th column of the array should be i*j.
Answers
Answered by
0
The element value in the i-th row and j-th column of the array should be i*j.
Note: i=0,1.., X-1; j=0,1,¡Y-1.
Example
Suppose the following inputs are given to the program:
3,5
Then, the output of the program should be:
[[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8]]
Answered by
0
Answer:
input1 = input("Enter input seperated by comma: ")
dimensions = [int(x) for x in input1.split(",")]
rowNum = dimensions[0]
colNum = dimensions[1]
multilist = [[for col in range(colNum)] for row in range(rowNum)]
for row in range(rowNum):
for col in range(colNum):
multilist[row][col] = row*col
print(multilist)
Explanation:
Similar questions
Chemistry,
6 months ago
World Languages,
6 months ago
Music,
6 months ago
English,
1 year ago
Math,
1 year ago
Social Sciences,
1 year ago
Chemistry,
1 year ago