Wednesday, January 1, 2020

The easiest XMAS tree in Python

# Python application for drawing of a model of XMAS tree - using Turtle

import turtle
from turtle import *

# MANUAL with commands:
# https://docs.python.org/3.3/library/turtle.html

window=turtle.Screen()
window.bgcolor("white")

color('blue', 'green')
begin_fill()

for n in range(3):

    forward(200)
    left(120)

end_fill()

forward(200)
left(120)
forward(90)
turtle.pendown()
turtle.pencolor('yellow')
turtle.pensize(20)
turtle.circle(10)
turtle.penup()

left(70)
forward(50)
turtle.pendown()
turtle.pencolor('blue')
turtle.pensize(20)
turtle.circle(10)
turtle.penup()

forward(50)
turtle.pendown()
turtle.pencolor('red')
turtle.pensize(20)
turtle.circle(10)
turtle.penup()

right(120)
forward(100)
right(60)
forward(15)
turtle.pendown()
turtle.pencolor('yellow')
turtle.pensize(20)
turtle.circle(10)
turtle.penup()

right(105)
forward(45)
turtle.pendown()
turtle.pencolor('violet')
turtle.pensize(20)
turtle.circle(10)
turtle.penup()

done()