This is a short video on how to draw a rainbow with or in python Programming language. The short tutorial showcases the python code in few lines. The module used is turtle.
The python tutorial is short and easy to understand. Here is the approach:
Import Turtle.
Set screen
Make Turtle Object
Define colors used for drawing
Loop to draw semi-circles oriented by 180-degree position.
The code:
import turtle
mypen= turtle.Turtle()
mypen.shape('turtle')
mypen.speed(10)
window= turtle.Screen()
window.bgcolor('white')
rainbow= ['red','orange','yellow','green','blue','indigo','violet']
size= 180
mypen.penup()
mypen.goto(0,-180)
for color in rainbow:
mypen.color(color)
mypen.fillcolor(color)
mypen.begin_fill()
mypen.circle(size)
mypen.end_fill()
size-=20
turtle.done()
On this page of the site you can watch the video online Draw A Rainbow(Python Programming) with a duration of hours minute second in good quality, which was uploaded by the user PythonLove 28 January 2024, share the link with friends and acquaintances, this video has already been watched 587 times on youtube and it was liked by 9 viewers. Enjoy your viewing!