Draw A Rainbow(Python Programming)

Publicado el: 28 enero 2024
en el canal de: PythonLove
587
9

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()


En esta página del sitio puede ver el video en línea Draw A Rainbow(Python Programming) de Duración hora minuto segunda en buena calidad , que subió el usuario PythonLove 28 enero 2024, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 587 veces y le gustó 9 a los espectadores. Disfruta viendo!