Cool python turtle library patters Bonus Blog

 pattern 1:



from turtle import * 

from random import randint 

bgcolor('black') 

x = 1 

speed(0) 

while x < 400: 

  

 r = randint(0,255) 

 g = randint(0,255)  

 b = randint(0,255) 

  

 colormode(255)  

 pencolor(r,g,b) 

 fd(50 + x) 

 rt(90.991) 

 x = x+1 

  

exitonclick()



pattern 2:


import turtle


def turn(i):

    left = (((i & -i) << 1) & i) != 0

    return 'L' if left else 'R'


def curve(iteration):

    return ''.join([turn(i + 1) for i in range(2 ** iteration - 1)])


if _name_ == '_main_':

    turtle.showturtle()

    turtle.hideturtle()

    turtle.speed(0)

    i = 1

    while True:

        if turn(i) == 'L':

            turtle.circle(-4, 90, 36)

        else:

            turtle.circle(4, 90, 36)

        i += 1


Comments

Popular posts from this blog

Samsung May Introduce New Virtual Assistant Called 'Sam'

Internet Explorer 11 desktop app retirement