Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python3
- from turtle import *
- from random import *
- def random_color():
- red = randint(0, 255)
- blue = randint(0, 255)
- green = randint (0, 255)
- color(red, blue, green)
- def random_place():
- penup()
- x = randint (-100, 100)
- y = randint (-100, 100)
- goto(x, y)
- pendown()
- def random_heading():
- setheading(randint (1, 360))
- def draw_rectangle():
- random_color()
- random_place()
- hideturtle()
- length = randint(10, 100)
- height = randint (10, 100)
- begin_fill()
- forward(length)
- right(90)
- forward(height)
- right(90)
- forward(length)
- right(90)
- forward(height)
- right(90)
- end_fill()
- def draw_triangle():
- random_color()
- random_place()
- hideturtle()
- length = randint (10, 100)
- height = randint (10, 100)
- begin_fill()
- forward(length)
- right(120)
- forward(length)
- right(120)
- forward(length)
- right(120)
- end_fill()
- def draw_star():
- random_color()
- random_place()
- begin_fill()
- for side in range(5):
- left(144)
- forward(50)
- end_fill()
- shape("turtle")
- speed(7)
- random_color()
- random_place()
- random_heading()
- clear()
- setheading(0)
- for i in range(20):
- draw_rectangle()
- draw_triangle()
- draw_star()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement