+ 18

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. 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]]

21st May 2018, 6:31 AM
Ratnapal Shende
Ratnapal Shende - avatar
6 ответов
+ 9
please post the code sir
21st May 2018, 8:35 AM
Ratnapal Shende
Ratnapal Shende - avatar
+ 8
Numpy is very useful for this kind of task : https://code.sololearn.com/cOSMWiNNRYxb/?ref=app
5th Jun 2018, 7:18 AM
Cépagrave
Cépagrave - avatar
+ 6
i,j=3,5 print([[0 for k in range(j)]]+[[a for a in range(0,j*b,b)] for b in range(1,i)])
21st May 2018, 6:57 AM
Louis
Louis - avatar
+ 1
Write a program in javascript 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. 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]] pleass solve this quation
25th Jun 2019, 6:42 PM
ravi malviya
ravi malviya - avatar
0
row_num = int(input("Input number of rows: ")) col_num = int(input("Input number of columns: ")) multi_list = [[0 for col in range(col_num)] for row in range(row_num)] for row in range(row_num): for col in range(col_num): multi_list[row][col]= row*col print(multi_list)
2nd Sep 2018, 5:34 PM
MODASER
MODASER - avatar
0
input_str = raw_input() dimensions=[int(x) for x in input_str.split(',')] rowNum=dimensions[0] colNum=dimensions[1] multilist = [[0 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
4th Aug 2019, 6:51 PM
Pravin Mahadik
Pravin Mahadik - avatar