Python Turtle - Tree | How to Make Tree Using Python


LET'S DROW A TREE  :

  • Copy this code to the right-top corner and past your python compiler.
  • Then past in your file.py.
  • Run code
  • See Magic 

Code to Draw Tree  : 


import turtle as CodeBurner
 
CodeBurner.speed("fastest") 
CodeBurner.bgcolor("black") 
CodeBurner.pensize(3)

def tree(branchLen,t): 
    if branchLen > 4: 
        CodeBurner.forward(branchLen) 
        CodeBurner.right(20) 
        tree(branchLen-15,t) 
        CodeBurner.left(40) 
        tree(branchLen-15,t) 
        CodeBurner.right(20) 
        CodeBurner.backward(branchLen) 
#20 step right
def main():
 myWin = CodeBurner.Screen()
 CodeBurner.left(90) 
 CodeBurner.up()
 CodeBurner.backward(200)
 CodeBurner.down()
 CodeBurner.color("green") 
 tree(105,CodeBurner)
 myWin.exitonclick()

main()

OUTPUT: 

2021-07-08-3

For More Amazing Content Subscribe to Our youtube channel:    subscribe

How to draw shin chan in python turtle:     Watch Video