Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

Students also viewed these Databases questions

Question

Be able to explain the concept of constructive discharge

Answered: 1 week ago