draw circle using squares
I am checking out a Python course at udacity and found an interesting Python module named Turtle. Now let me share with you a simple code that I just have written.
import turtle
def draw_square():
window = turtle.Screen()
window.bgcolor("red")
brad = turtle.Turtle()
brad.shape("turtle")
brad.color("yellow")
brad.speed(5)
counter = 0
while counter < 36:
brad.forward(100)
brad.right(90)
brad.forward(100)
brad.right(90)
brad.forward(100)
brad.right(90)
brad.forward(100)
brad.right(100)
counter += 1
window.exitonclick()
if __name__ == "__main__":
draw_square()
Just save the code in a file and run it, and you will see something like this:
Now a simple question for you. How did I come up with the number 36 in the while loop? (while counter < 36).

Comments