Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- from turtle import Turtle
- tut=Turtle()
- tut.getscreen().bgcolor('#cccccc')
- tut.speed(0)
- def draw_sq(t,h,w,c,bg,x,y):
- t.pensize(5)
- t.penup()
- t.goto(x,y)
- t.color(c,bg)
- t.begin_fill()
- t.pendown()
- t.setheading(0) #east
- t.forward(w) #to right width w
- t.left(90)
- t.forward(h) #draw up the height h
- t.left(90)
- t.forward(w)
- t.left(90)
- t.forward(h)
- t.end_fill()
- colours=['red','white','blue','yellow']
- for i in range(200):
- xi=randint(-10,10)
- yi=randint(-10,10)
- ci=randint(0,3)
- x=xi*40-100
- y=yi*60-150
- c=colours[ci]
- draw_sq(tut,150,200,'black',c,x,y)
- tut.hideturtle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement