67.0k views
4 votes
You should see the following code in your programming

import simplegui
def draw_handler(canvas);
# your code goes here
frame = simplegui.create_frame('Testing', 600, 600)
frame.set_canvas_background("black")
frame.set_draw_handler(draw handler)
rame.start()

User Fylix
by
4.8k points

1 Answer

5 votes

Answer:

import simplegui

import random

def draw_handler(canvas):

for x in range(1000):

colorList = ["Yellow", "Red", "Purple", "White", "Green", "Blue", "Pink", "Orange"]

c = random.choice(colorList)

x = random.randint(1,600)

y = random.randint(1,600)

canvas.draw_point([x, y], c)

frame = simplegui.create_frame('Testing', 600, 600)

frame.set_canvas_background("Black")

frame.set_draw_handler(draw_handler)

frame.start()

Step-by-step explanation:

I used a for loop, setting my range to 1000 which is how you create exactly 1000 points. Next, I defined my color array, my x randint value, and my y randint value. I set both the x and y randint values to 1 - 600 since the frame is 600x600. The rest is pretty self explanatory.

User Nickfox
by
4.7k points