Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'Naren'
- import turtle
- import random
- window=turtle.Screen()
- window.bgcolor('black')
- def draw_square(n,color,path):
- point=turtle.Turtle()
- point.color(color)
- point.shape('turtle')
- point.speed(8)
- for i in range(1,5):
- if path=='rt':
- point.rt(90)
- point.fd(n)
- elif path=='lt':
- point.lt(90)
- point.fd(n)
- elif path=='fd_lt':
- point.fd(n)
- point.lt(90)
- elif path=='fd_rt':
- point.fd(n)
- point.rt(90)
- def draw_beautiful_carpet():
- paths=['rt','lt','fd_lt','fd_rt']
- colors=['darkViolet','darkGreen','darkBlue','darkCyan','maroon','white','grey','khaki']
- for s in paths:
- for i in range(1,400,10):
- if i == 400:
- draw_square(i,'black',s)
- else:
- draw_square(i,random.choice(colors),s)
- draw_beautiful_carpet()
- window.exitonclick()
Advertisement
Add Comment
Please, Sign In to add comment