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
icon
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
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 ()
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
C-string
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