Python Turtle Code: Peacock Tail

Publicado el: 13 febrero 2022
en el canal de: Basic Python Turtle Art
216
3

A spread-out tail using 3 kinds of feathers. The Python Turtle code uses 2 switches: sw1 for main or primary feather, and sw2 for secondary feathers A and B.

Please feel free to copy and paste the Python Turtle code below. Don't hesitate to ask questions about the code if you have any. Enjoy!
import turtle
scrin = turtle.Screen()
t = turtle.Turtle()
t.pensize(5)
t.speed(4)
t.right(20)
sw1 = 0 #switch: sw1 = 0 for main "feather", sw1 = 1 for secondary ones
sw2 = 0 #secondswitch: sw2 = 0 for secondary "feather" A, = 1 for B
for i in range(23):
t.penup()
t.goto(0, -120)
t.forward(50)
t.pendown()
t.forward(290)
if sw1 == 0: #conditional for main "feather", which has circles at tip of rib
t.right(90)
t.fillcolor("red")
for j in [20, 10]:
t.begin_fill()
t.circle(j)
t.end_fill()
t.fillcolor("yellow")
t.left(100)
sw1 = 1 #sw1 switches to 1 from 0 to avoid successive main "feathers"
else:
if sw2 == 0: #conditional for secondary "feather" A, which has circles at mid rib
t.backward(100)
t.right(90)
t.fillcolor("red")
for j in [20, 10]:
t.begin_fill()
t.circle(j)
t.end_fill()
t.fillcolor("yellow")
t.left(100)
sw1 = 0 #sw1 switches back to 0 after a secondary "feather" is drawn
sw2 = 1 #sw2 switches to 1 from 0 to avoid successive secondary "feathers" A
else: #conditional for secondary "feather" B, which has circles at low rib
t.backward(200)
t.right(90)
t.fillcolor("red")
for j in [20, 10]:
t.begin_fill()
t.circle(j)
t.end_fill()
t.fillcolor("yellow")
t.left(100)
sw1 = 0 #sw1 switches back to 0 after a secondary "feather" is drawn
sw2 = 0 #sw2 switches back to 0 to avoid successive secondary "feathers" B
scrin.exitonclick()


En esta página del sitio puede ver el video en línea Python Turtle Code: Peacock Tail de Duración hora minuto segunda en buena calidad , que subió el usuario Basic Python Turtle Art 13 febrero 2022, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 216 veces y le gustó 3 a los espectadores. Disfruta viendo!