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...


4. Complete the following program to draw four squares in random locations. Complete<br>draw_square to draw a square. Complete draw_randsquare and main as instructed by the<br>comments.<br>Save & Run<br>11/1/2021, 4:15:21 PM - 2 of 2<br>import turtle<br>2 import random<br>3<br>4 def draw_square (t, sz) :<br>5<br>'''Draws a square of size sz using turtle t'''<br>6<br>pass<br>#This statement does nothing<br>- you can remove it<br>7<br>#Your code here<br>use a loop to draw a square<br>8<br>for i in range (4)<br>9<br>t.forward (sz)<br>10<br>t.left (90)<br>11<br>12 def draw_randsquare (t, square_size) :<br>13<br>'''Uses draw square to draw a square in a random location'''<br>14<br>pass #This statement does nothing<br>you can remove it<br>15<br>#Get a random x position<br>

Extracted 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<br>draw_square to draw a square. Complete draw_randsquare and main as instructed by the<br>comments.<br>Save & Run<br>11/1/2021, 4:15:21 PM - 2 of 2<br>16<br>#Get a random y position<br>17<br>#Move the turtle to the x, y position<br>don't draw a line!<br>18<br>#Call draw square to draw a square of size square__size<br>19<br>20 def main () :<br>21<br>''Controls the program''<br>22<br>wn = turtle.Screen ()<br>23<br>jane = turtle.Turtle ()<br>24<br>25<br>for color in [

Extracted 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 ()

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here