Last active
September 19, 2018 19:28
-
-
Save Ad115/e9189175da28205223ee8be46ae5d67d to your computer and use it in GitHub Desktop.
Un caso común de uso de el operador módulo en Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
squirtle = turtle.Turtle() | |
# Los colores que usaremos | |
colors = ["red", "yellow", "blue", "orange", "green", "purple"] | |
n_colors = len(colors) | |
for i in range(100): | |
# Obtén el índice del color | |
idx = i % n_colors | |
# Obtén el color | |
color = colors[idx] | |
# Cambia el color | |
squirtle.pencolor(color) | |
# Avanza | |
squirtle.forward(i) | |
squirtle.left(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment