9. Write a python program to request user to input the number of rows and columns therefore create a two-dimensional array. One of the example in the output below.
The output is:
Expected Sample Answer:
Please input the columns number: 3
Please input the rows number: 4
[[0, 0, 0], [0, 1, 2], [0, 2, 4], [0, 3, 6]]
Sample Answer:
col_num = int(input("Please input the columns number: ")) row_num = int(input("Please input the rows number: ")) new_array = [[0 for i in range(col_num)] for j in range(row_num)] for i in range(row_num): for j in range(col_num): new_array[i][j]= i*j print(new_array)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)