4. Complete the following program to draw four squares in random locations. Complete draw_square to draw a square. Complete draw_randsquare and main as instructed by the comments. Save & Run 11/1/2021, 4:15:21 PM - 2 of 2 import turtle 2 import random 3 4 def draw_square (t, sz): ''Draws a square of size sz using turtle t''' pass #This statement does nothing - you can remove it #Your code here - use a loop to draw a square for i in range (4) 9. t.forward (sz) 10 t.left (90) 11 12 def draw_randsquare (t, square_size): 13 ''Uses draw_square to draw a square in a random location''' pass #This statement does nothing - you can remove it #Get a random x position 14 15
4. Complete the following program to draw four squares in random locations. Complete draw_square to draw a square. Complete draw_randsquare and main as instructed by the comments. Save & Run 11/1/2021, 4:15:21 PM - 2 of 2 import turtle 2 import random 3 4 def draw_square (t, sz): ''Draws a square of size sz using turtle t''' pass #This statement does nothing - you can remove it #Your code here - use a loop to draw a square for i in range (4) 9. t.forward (sz) 10 t.left (90) 11 12 def draw_randsquare (t, square_size): 13 ''Uses draw_square to draw a square in a random location''' pass #This statement does nothing - you can remove it #Get a random x position 14 15
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
Related questions
Question
![4. Complete the following program to draw four squares in random locations. Complete
draw_square to draw a square. Complete draw_randsquare and main as instructed by the
comments.
Save & Run
11/1/2021, 4:15:21 PM - 2 of 2
import turtle
2 import random
3
4 def draw_square (t, sz) :
5
'''Draws a square of size sz using turtle t'''
6
pass
#This statement does nothing
- you can remove it
7
#Your code here
use a loop to draw a square
8
for i in range (4)
9
t.forward (sz)
10
t.left (90)
11
12 def draw_randsquare (t, square_size) :
13
'''Uses draw square to draw a square in a random location'''
14
pass #This statement does nothing
you can remove it
15
#Get a random x position](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F73f5456d-4636-4f64-a6cd-c1722dc52480%2F82579903-8a1e-442f-bf4d-710bf6c52aaa%2F0jcejop_processed.png&w=3840&q=75)
Transcribed Image Text:4. Complete the following program to draw four squares in random locations. Complete
draw_square to draw a square. Complete draw_randsquare and main as instructed by the
comments.
Save & Run
11/1/2021, 4:15:21 PM - 2 of 2
import turtle
2 import random
3
4 def draw_square (t, sz) :
5
'''Draws a square of size sz using turtle t'''
6
pass
#This statement does nothing
- you can remove it
7
#Your code here
use a loop to draw a square
8
for i in range (4)
9
t.forward (sz)
10
t.left (90)
11
12 def draw_randsquare (t, square_size) :
13
'''Uses draw square to draw a square in a random location'''
14
pass #This statement does nothing
you can remove it
15
#Get a random x position
![4. Complete the following program to draw four squares in random locations. Complete
draw_square to draw a square. Complete draw_randsquare and main as instructed by the
comments.
Save & Run
11/1/2021, 4:15:21 PM - 2 of 2
16
#Get a random y position
17
#Move the turtle to the x, y position
don't draw a line!
18
#Call draw square to draw a square of size square__size
19
20 def main () :
21
''Controls the program''
22
wn = turtle.Screen ()
23
jane = turtle.Turtle ()
24
25
for color in ["red", "green", "blue", "orange"]:
26
pass
#This statement does nothing
you can remove it
27
#Set jane's color to color
28
#Call draw randsquare to draw a square in a random location
29
30
wn.exitonclick ()](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F73f5456d-4636-4f64-a6cd-c1722dc52480%2F82579903-8a1e-442f-bf4d-710bf6c52aaa%2Fnu7jey6_processed.png&w=3840&q=75)
Transcribed Image Text:4. Complete the following program to draw four squares in random locations. Complete
draw_square to draw a square. Complete draw_randsquare and main as instructed by the
comments.
Save & Run
11/1/2021, 4:15:21 PM - 2 of 2
16
#Get a random y position
17
#Move the turtle to the x, y position
don't draw a line!
18
#Call draw square to draw a square of size square__size
19
20 def main () :
21
''Controls the program''
22
wn = turtle.Screen ()
23
jane = turtle.Turtle ()
24
25
for color in ["red", "green", "blue", "orange"]:
26
pass
#This statement does nothing
you can remove it
27
#Set jane's color to color
28
#Call draw randsquare to draw a square in a random location
29
30
wn.exitonclick ()
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education