Draw A Rainbow(Python Programming)

Publié le: 28 janvier 2024
sur la chaîne: 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()


Sur cette page du site, vous pouvez voir la vidéo en ligne Draw A Rainbow(Python Programming) durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur PythonLove 28 janvier 2024, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 587 fois et il a aimé 9 téléspectateurs. Bon visionnage!