Python Program to Draw Life of Tree Using Turtle
# Draw Life of Tree in Python Using Turtle
import turtle as tu
roo = tu.Turtle() #Turtle object
wn = tu.Screen() #Screen Object
wn.bgcolor("black") #Screen Bg color
roo.left(90) #moving the turtle 90 degrees towards left
roo.speed(20) #setting the speed of the turtle
#recursive function taking length 'l' as argument
def draw(l):
if(l<10):
return
else:
roo.pensize(2) #Setting Pensize
roo.pencolor("yellow") #Setting Pencolor as yellow
roo.forward(l) #moving turtle forward by 'l'
roo.left(30) #moving the turtle 30 degrees towards left
draw(3*l/4) #drawing a fractal on the left of the turtle object 'roo' with 3/4th of its length
roo.right(60) #moving the turtle 60 degrees towards right
draw(3*l/4) #drawing a fractal on the right of the turtle object 'roo' with 3/4th of its length
roo.left(30) #moving the turtle 30 degrees towards left
roo.pensize(2)
roo.backward(l) #returning the turtle back to its original psition
draw (20) # drawing 20 times
roo.right(90)
roo.speed(2000)
#recursion
def draw(l):
if(l<10):
return
else:
roo.pensize(2)
roo.pencolor("magenta") #magenta
roo.forward(l)
roo.left(30)
draw(3*l/4)
roo.right(60)
draw(3*l/4)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw (20)
roo.left(270)
roo.speed(2000)
#recursion
def draw(l):
if(l<10):
return
else:
roo.pensize(2)
roo.pencolor("red") #red
roo.forward(l)
roo.left(30)
draw(3*l/4)
roo.right(60)
draw(3*l/4)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw (20)
roo.right(90)
roo.speed(2000)
#recursion
def draw(l):
if(l<10):
return
else:
roo.pensize(2)
roo.pencolor('#FFF8DC') #white
roo.forward(l)
roo.left(30)
draw(3*l/4)
roo.right(60)
draw(3*l/4)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw(20)
########################################################
def draw(l):
if(l<10):
return
else:
roo.pensize(3)
roo.pencolor("lightgreen") #lightgreen
roo.forward(l)
roo.left(30)
draw(4*l/5)
roo.right(60)
draw(4*l/5)
roo.left(30)
roo.pensize(3)
roo.backward(l)
draw (40)
roo.right(90)
roo.speed(2000)
#recursion
def draw(l):
if(l<10):
return
else:
roo.pensize(3)
roo.pencolor("red") #red
roo.forward(l)
roo.left(30)
draw(4*l/5)
roo.right(60)
draw(4*l/5)
roo.left(30)
roo.pensize(3)
roo.backward(l)
draw (40)
roo.left(270)
roo.speed(2000)
#recursion
def draw(l):
if(l<10):
return
else:
roo.pensize(3)
roo.pencolor("yellow") #yellow
roo.forward(l)
roo.left(30)
draw(4*l/5)
roo.right(60)
draw(4*l/5)
roo.left(30)
roo.pensize(3)
roo.backward(l)
draw (40)
roo.right(90)
roo.speed(2000)
#recursion
def draw(l):
if(l<10):
return
else:
roo.pensize(3)
roo.pencolor('#FFF8DC') #white
roo.forward(l)
roo.left(30)
draw(4*l/5)
roo.right(60)
draw(4*l/5)
roo.left(30)
roo.pensize(3)
roo.backward(l)
draw (40)
########################################################
def draw(l):
if(l<10):
return
else:
roo.pensize(2)
roo.pencolor("cyan") #cyan
roo.forward(l)
roo.left(30)
draw(6*l/7)
roo.right(60)
draw(6*l/7)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw (60)
roo.right(90)
roo.speed(2000)
#recursion
def draw(l):
if(l<10):
return
else:
roo.pensize(2)
roo.pencolor("yellow") #yellow
roo.forward(l)
roo.left(30)
draw(6*l/7)
roo.right(60)
draw(6*l/7)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw (60)
roo.left(270)
roo.speed(2000)
#recursion
def draw(l):
if(l<10):
return
else:
roo.pensize(2)
roo.pencolor("magenta") #magenta
roo.forward(l)
roo.left(30)
draw(6*l/7)
roo.right(60)
draw(6*l/7)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw (60)
roo.right(90)
roo.speed(2000)
#recursion
def draw(l):
if(l<10):
return
else:
roo.pensize(2)
roo.pencolor('#FFF8DC') #white
roo.forward(l)
roo.left(30)
draw(6*l/7)
roo.right(60)
draw(6*l/7)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw(60)
wn.exitonclick()
Output:
About The Author
Shailendra Bramhvanshi, Founder at Techaroha Solutions Private Limited and CEO at Newtum Solutions Private Limited. BlockChain Experts with 12 years of IT Experience in of all aspects of running Organization and Project Management. I have created different coins to help the business to bring more trust. Recently deployed a stable coin in India TrueINR and working on few cryptocurrency exchanges. My Team is being rated as a top 10 blockchain service provider in India by Silicon India