Back

Explore Courses Blog Tutorials Interview Questions

Explore Tech Questions and Answers

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

0 votes
2 views
by (120 points)

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 or register to answer this question.

Browse Categories

...