# Christmas tree on Python
import turtle
def line(x1, y1, x2, y2):
turtle.penup()
turtle.goto(x1, y1)
turtle.pendown()
turtle.goto(x2, y2)
screen = turtle.Screen()
screen.title("Christmas Fir tree")
screen.setup(500, 500)
# To turn the drawing upside down
screen.setworldcoordinates(0, screen.window_height(), screen.window_width(), 0)
turtle.pencolor('green')
line(200,210,220,230)
line(220,230,180,230)
line(180,230,200,210)
line(200,230,230,250)
line(230,250,170,250)
line(170,250,200,230)
line(200,250,250,270)
line(250,270,150,270)
line(150,270,200,250)
line(200,270,270,290)
line(270,290,130,290)
line(130,290,200,270)
line(200,290,290,310)
line(290,310,110,310)
line(110,310,200,290)
turtle.hideturtle()
turtle.exitonclick()
This simple code example was intentionally made similar to Christmas tree on Pascal on Android
The Christmas tree on Python on Turtle is available in My Github Repository

No comments:
Post a Comment