Rainbow by Turtle

An example for programming lessons at school

Rainbow by Turtle
import turtle t = turtle.Turtle() # Setting the title turtle.title("Rainbow by Turtle") t.hideturtle() # Setting the rainbow width rainbow_width = 20 t.width(rainbow_width+1) t.left(90) # Setting the rainbow radius r=50 angle=180 # Colors for the rainbow colors=["violet", "indigo", "blue", "green", "yellow", "orange", "red"] for i in colors: t.color(i) r=r+rainbow_width t.circle(r, angle) t.up() t.right(90) t.forward(rainbow_width) t.down() t.left(90) angle=angle*(-1) t.done()

No comments:

Post a Comment