Question: 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
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.
This is on python,
Below is the code given
import turtle import random
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
def draw_randsquare(t, square_size): '''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 #Get a random y position #Move the turtle to the x, y position - don't draw a line! #Call draw_square to draw a square of size square_size
def main(): '''Controls the program''' wn = turtle.Screen() jane = turtle.Turtle()
for color in ["red", "green", "blue", "orange"]: pass #This statement does nothing - you can remove it #Set jane's color to color #Call draw_randsquare to draw a square in a random location
wn.exitonclick()
main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
