Python Program Rainbow Using Turtle

how to create rainbow in python


  • Turtle is a Python feature like a drawing board.
  • Turtle is a special feathers of Python.
  • You can use functions like turtle.forword (....) and turtle.left(....) which can move        the turtle around the board.
  • range (360) turtle.  
  • These are Python Turtle project, you are going to draw a  RAINBOW.



Installation

pip install pythonturtle

or

sudo pip install pythonturtle

The First step is to import libraries

import turtle

or 

from turtle import *


Rainbow.py


 # import turtle library
 import turtle             
 colors = [ "red","orange","yellow","green","blue","pink"]
 my_arrow = turtle.Pen()
 turtle.bgcolor("black")
 for x in range(360):
    my_arrow.pencolor(colors[x % 6])
    my_arrow.width(x/50 + 1)
    my_arrow.forward(x)
    my_arrow.left(59)