Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (120 points)
recategorized by

Write a program NumberGrid.py that contains a function make_grid to create a grid of numbers according to the examples below. The function should have two positive parameters to set the number of rows and number of columns in the grid, and should return the 2D list. The main program should create 3 examples of grids and print them. You can decide how to print the resulting 2D list.

Example executions:

grid(3,5) should create a 3x5 2D list containing the following elements

[[1, 2, 3, 4, 5],

 [6, 7, 8, 9, 10],

 [11, 12, 13, 14, 15]]

grid(4,2) should create a 4x2 2D list containing the following elements

[[1, 2],

 [3, 4],

 [5, 6],

 [7, 8]]

grid(1,1) should create a 1x1 2D list containing the following element

[[1]]

Please log in to answer this question.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...