Skip to content

Instantly share code, notes, and snippets.

@fabian57
Created April 7, 2015 18:50
Show Gist options
  • Save fabian57/20c30926686899169f39 to your computer and use it in GitHub Desktop.
Save fabian57/20c30926686899169f39 to your computer and use it in GitHub Desktop.
height = input("How high should it be?")
levels = input("How many levels should it have?")
import turtle
t = turtle.Turtle()
t.speed(0)
t.hideturtle()
t.penup()
t.left(90)
t.backward(height*2)
t.pendown()
def tree(length, level):
t.forward(length)
if level == 0:
return
else:
t.right(10)
tree(length*0.8, level-1)
t.penup()
t.backward(length*0.8)
t.pendown()
t.left(20)
tree(length*0.8, level-1)
t.penup()
t.backward(length*0.8)
t.pendown()
t.right(10)
tree(height, levels)
raw_input("Press ENTER to close the turtle window.")
turtle.bye()
@laowantong
Copy link

Oui, t'as raison, mais c'est une base pour des arbres aléatoires beaucoup moins ennuyeux!

Rien à redire sur ton programme, c'est très bien.

@fabian57
Copy link
Author

fabian57 commented Apr 7, 2015

Ils sont trop cools les arbres, j'en fait depuis deux heures

@laowantong
Copy link

lol, des aléatoires alors?

@laowantong
Copy link

on attend ta galerie!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment