Created
April 7, 2015 18:50
-
-
Save fabian57/20c30926686899169f39 to your computer and use it in GitHub Desktop.
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
| 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
on attend ta galerie!