Amazing Python Turtle Designs Part 2


Video :-



Source_Code :- 

import turtle
turtle.bgcolor("black")
turtle.pensize(2)

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
    turtle.goto(120,-120)
    while True:
        if turn(i) == 'L':
            turtle.circle(-4,90, 36)
            if (i%2 == 0):
                turtle.color("red")
            else:
                turtle.color("yellow")

        else:
            turtle.circle(4, 90, 36)
            if (i%2 == 0):
                turtle.color("light blue")
            else:
                turtle.color("green")

        i += 1

#Subscribe SCIENTIFICODER For Amazing Projects and Hacks


HOPE You liked it !!


No comments:

Post a Comment