For this milestone, you will be creating a simple n by n grid. Each grid cell will be a square, with all of them either filled or unfilled.  The grid should completely fill the Turtle window (more about this below.) You will first ask for 3 inputs: Grid size n as an integerPen color as a stringFill color as a string Then using the inputs, produce a grid using these 3 inputs. Here is a sample output: Grid size (n): (input) Pen color: (input) Fill color: (input) Bolded text are inputs and would not appear in the autograder's tests Next are some examples of the grid your program should produce: The fill color and pen color is up to your decision. By the end of this milestone, your program should be able to produce an n by n grid that is either filled or unfilled. For our grids to completely fill the Turtle window, we need to control both the size of the drawing canvas and the size of the window that holds the drawing canvas.  We have several methods and properties of the Screen object that will help us do this. Screen.screensize(width, height) - sets the size of the drawing canvas  Screen.setup(width, height) - sets the size of the window  Screen.screensize() - returns the canvas size as a tuple (width, height) Screen.canvwidth - equal to the canvas width Screen.canvheight - equal to the canvas height   # assuming variable s is a screen object size_for_canvas = 500 # window size  #   needs to be a little larger for window edge chrome s.setup(width=size_for_canvas + 10, height=size_for_canvas + 10)   # set the canvas size s.screensize(size_for_canvas, size_for_canvas)     NOTES on Turtle: turtle.mainloop() - Keep this while you're testing your program, should be the last line of code. Prevents your program from ending before you can see your turtle drawing. Delete it before you submit for grading, leaving it will prevent your program from terminating and the autograder will timeout. turtle.tracer(False) - turns drawing off, please use to speed up drawing (Turtle code is slow only if window is updated as code runs) turtle.tracer(True) - turns drawing on, where ever this is placed in your code will trigger a window update, so drawing will appear.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

For this milestone, you will be creating a simple n by n grid. Each grid cell will be a square, with all of them either filled or unfilled.  The grid should completely fill the Turtle window (more about this below.)

You will first ask for 3 inputs:

  • Grid size n as an integerPen color as a stringFill color as a string

Then using the inputs, produce a grid using these 3 inputs.

Here is a sample output:

Grid size (n): (input) Pen color: (input) Fill color: (input)

Bolded text are inputs and would not appear in the autograder's tests

Next are some examples of the grid your program should produce:

The fill color and pen color is up to your decision.

By the end of this milestone, your program should be able to produce an n by n grid that is either filled or unfilled.

For our grids to completely fill the Turtle window, we need to control both the size of the drawing canvas and the size of the window that holds the drawing canvas.  We have several methods and properties of the Screen object that will help us do this.

  • Screen.screensize(width, height) - sets the size of the drawing canvas 
  • Screen.setup(width, height) - sets the size of the window 
  • Screen.screensize() - returns the canvas size as a tuple (width, height)
  • Screen.canvwidth - equal to the canvas width
  • Screen.canvheight - equal to the canvas height

 

# assuming variable s is a screen object

size_for_canvas = 500

# window size 

#   needs to be a little larger for window edge chrome

s.setup(width=size_for_canvas + 10, height=size_for_canvas + 10)

 

# set the canvas size

s.screensize(size_for_canvas, size_for_canvas)

 

 

NOTES on Turtle:

turtle.mainloop() - Keep this while you're testing your program, should be the last line of code. Prevents your program from ending before you can see your turtle drawing. Delete it before you submit for grading, leaving it will prevent your program from terminating and the autograder will timeout.

turtle.tracer(False) - turns drawing off, please use to speed up drawing (Turtle code is slow only if window is updated as code runs)

turtle.tracer(True) - turns drawing on, where ever this is placed in your code will trigger a window update, so drawing will appear.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

can you used to the basic turtle like t.forward, t.left, t.right used that in the code it has to be draw out

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education