Cristian Sepúlveda
Andrés Fernando Cortés Pinzón
Muy buen concepto. felicidades
Fernando Jesús Núñez Valdez
Amazing!
Ya vas entendiendo la recursividad a la perfección, ¿verdad?
No sólo podemos hacer operaciones recursivas con textos y números; el límite es tu imaginación. En esta clase aprenderás a dibujar figuras geométrica usando funciones recursivas y controlando ángulos con la librería turtle de Python (viene incluida por defecto, no debes instalar nada).
Cristian Sepúlveda
Andrés Fernando Cortés Pinzón
Muy buen concepto. felicidades
Fernando Jesús Núñez Valdez
Amazing!
Les comparto un proyecto parecido que hice mientras estaba de intercambio :D Era sobre usando turtle, crear de forma recursiva los troncos de un árbol ( de forma aleatoria )
# Name: Carlos N. Trejo Garcia # Date: 03/23/18 #Imports import turtle import random #Creates a branch of a tree def tree(branchLen,t): LIMIT = 5 #Limit for minimum length of the tree #Check if the length is grather than the limit if branchLen > LIMIT: #Get the lengths of the next two branches left = branchLen - getLen() right = branchLen - getLen() #Acorrding to those lengths, check to see if this one is the last one #If it is, then this one is sa leaf. So use color green #Else, use color brown if amItheLast(left, right, LIMIT): t.color("green") else: t.color("brown") #The size of the pen is proporcional of the length t.pensize(branchLen * .12) #Print forward t.forward(branchLen) #Get angles of next two branches rig = getAngle() lef = getAngle() + rig ret = t.heading() #Store for return later #Go to the right t.right(rig) tree(left, t) #Go to the left t.left(lef) tree(right, t) #Return to original angle, stop drowing with the pen and go back t.setheading(ret) t.up() t.backward(branchLen) t.down() #Continue drowing #Returns if the actual branch is the last one (leaf?) #@Lef: Length of left branch - INT #@Rig: Length of right branch - INT #@Limit: The limit of the lenght in order to be draw - INT def amItheLast(lef, rig, limit): if lef > limit or rig > limit: return False else: return True #Get a random angle, between 15 and 45 def getAngle(): return random.randint(15,45) #Get a random length, between 5 and 20 def getLen(): return random.randint(5,20) #Creates and prints a tree def main(): #Pencile and canvas t = turtle.Turtle() myWin = turtle.Screen() #Set start position t.shape("turtle") t.left(90) t.up() t.backward(100) t.down() #Start drawing tree(75,t) myWin.exitonclick() main()
Mario Estanislao César Ariet
Bernardo Aguayo Ortega
woow, que cool
VICTOR CASTILLO
muy buenos patrones, investigare mas sobre el tema
David Behar
Me encantó esta clase, me recuerda a la tortuguita logo con la que aprendí a programar sin saber que estaba programando.
Para quien no sepa de qué les estoy hablando les dejo un link que habla de Logo.
Danelia Sanchez Sanchez
Con Logo fue mi primer acercamiento a programación :)
David Behar
Sí, con logo me metía a hacer figuras muy extrañas, aprendí a programar sin saber qué era eso
Samar Jaffal
Christian Gómez
Esta muy broken, pasa el código!
Omar Flores Grimontt
Secuencia de Fibonacci :D
Nicolas Esteban Prieto Sarmiento
Épico
Samar Jaffal
Muchachos no se por qué a mi no me funcionaba el ejercicio con el compilador que usan en el ejemplo. Me salía este error:
Tuve que usar el mismo compilador pero con un enlace diferente, ya que el error era al importar la librería turtle. Este es el enlace por si a alguien le sirve: https://repl.it/languages/python_turtle
Martín David Roldán
Gracias!
David Lara
gracias. Me estuve pegando cabezas un buen rato...
Carlos Eduardo Magallon Zepeda
Christian Gómez
Moisés Manuel Morín Hevia
El código está en el comentario anterior
Azael Ortega
🐍🎨
Juan Manuel Otero Rey
 win = turtle.Screen() def draw(tr, length): if length > 0: tr.forward(length) else: tr.backward(length) tr.left(135) draw(tr, length -2) draw(tr, 100) win.exitonclick()
Efraín Hernández García
https://repl.it/languages/python_turtle
el enlace para correr el programa
Mariana Gómez Betancourt
Gracias
Ezequiel Matías Rolón Pettinari
Jonathan Rangel Bernal
Asi me quedo a mi
import turtle myTurtle = turtle.Turtle() myWin = turtle.Screen() colors = ( '#006699', '#006666', '#660066', '#990000', '#ad3270', '#e65100', '#1a237e', '#827717', '#006064', '#f57f17', '#d50000', '#4a148c', ) def draw(myTurtle, length): if length > 0: myTurtle.forward(length) myTurtle.left(170) draw(myTurtle, length-10) for color in colors: myTurtle.pencolor(color) draw(myTurtle, 100)```
Leisy Karina Algarra Fernandez
import turtle myTurtle = turtle.Turtle() myWin = turtle.Screen() def draw(myTurtle,length): if length > 0: myTurtle.forward(length) myTurtle.right(60) myTurtle.left(-60) draw(myTurtle, length -2) draw(myTurtle, 100) myWin.exitonclick()```
keila martinez
esta super el arte recursivo con python
Adriana del Pilar Martinez Bautista
Saúl Alejandro Tapia Loya
Hice algunos experimentos diferentes!
Lorena Mosquera González
Me gusto mucho esta clase! :)
import turtle def draw(my_turtle, lenght): if lenght: my_turtle.forward(lenght) my_turtle.left(123) draw(my_turtle, lenght - 2) if __name__ == "__main__": my_turtle = turtle.Turtle() screen = turtle.Screen() colors = ( '#006699', '#006666', '#660066', '#990000', '#ad3270', '#e65100', '#1a237e', '#827717', '#006064', '#f57f17', '#d50000', '#4a148c', ) for color in colors: my_turtle.pencolor(color) draw(my_turtle, 100) screen.exitonclick()
No hay nada mas lindo en recursividad que los fractales!
Mi código para el copo de von Koch
import turtle tortuga = turtle.Turtle() ventana = turtle.Screen() def dibujar(tortuga, largo): if largo >40: dibujar(tortuga,largo/3) tortuga.left(60) dibujar(tortuga,largo/3) tortuga.right(120) dibujar(tortuga,largo/3) tortuga.left(60) dibujar(tortuga,largo/3) else: tortuga.forward(largo/3) tortuga.left(60) tortuga.forward(largo/3) tortuga.right(120) tortuga.forward(largo/3) tortuga.left(60) tortuga.forward(largo/3) if __name__ == "__main__": dibujar(tortuga,500) ventana.exitonclick()