Question: Using the turtle library, write a function draw_grid(n,m): Itll take two positive ints n and m and draws an n m grid of squares of

Using the turtle library, write a function draw_grid(n,m):

Itll take two positive ints n and m and draws an n m grid of squares of the size of your choice, where n is the height in squares and m is the width in squares.

For example, draw_grid(6,5) would draw:

Using the turtle library, write a function draw_grid(n,m): Itll take two positive

Set the title of the turtle window to be My n-by-m grid, replacing n and m with the dimensions from the function. For example, if the user called draw_grid(6,5), the title should be My 6-by-5 grid. (Remember, title() takes any string, and you can format strings using the %d formatting tools.

I am using jupyter console and jupyter notebook.

Okay below is what I have so far. When I import grid it works but then when I draw_grid (#,#), with the # being two random numbers selected by me, I get the error message "name 'draw_grid' is not defined." Can somebody please tell me where I went wrong and the correct way to format this. I'm still unfamilar with using turtle in def functions.

import turtle

def draw_grid (n,m): """Draws a grid using n as the height in squares and m as the width in squares Arg: n (int): postive integer m (int): positive integer Returns: drawing: grid of both integers """ scrn = turtle.Screen() scrn.title('My n-by-m grid')

Figure 1: Result of draw grid (6,5)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!