Instantly share code, notes, and snippets.

Embed
What would you like to do?
A small Christmas' Tree Algorithm in Python.
import turtle
screen = turtle.Screen()
screen.setup(800,600)
circle = turtle.Turtle()
circle.shape('circle')
circle.color('red')
circle.speed('fastest')
circle.up()
square = turtle.Turtle()
square.shape('square')
square.color('green')
square.speed('fastest')
square.up()
circle.goto(0,280)
circle.stamp()
k = 0
for i in range(1, 17):
y = 30*i
for j in range(i-k):
x = 30*j
square.goto(x,-y+280)
square.stamp()
square.goto(-x,-y+280)
square.stamp()
if i % 4 == 0:
x = 30*(j+1)
circle.color('red')
circle.goto(-x,-y+280)
circle.stamp()
circle.goto(x,-y+280)
circle.stamp()
k += 2
if i % 4 == 3:
x = 30*(j+1)
circle.color('yellow')
circle.goto(-x,-y+280)
circle.stamp()
circle.goto(x,-y+280)
circle.stamp()
square.color('brown')
for i in range(17,20):
y = 30*i
for j in range(3):
x = 30*j
square.goto(x,-y+280)
square.stamp()
square.goto(-x,-y+280)
square.stamp()
turtle.exitonclick()
@laowantong

This comment has been minimized.

laowantong commented Dec 19, 2015

Thanks!

@rt5

This comment has been minimized.

rt5 commented Dec 16, 2016

Try this mate

@rt5

This comment has been minimized.

rt5 commented Dec 16, 2016

Sorry
Wrong one

@rt5

This comment has been minimized.

rt5 commented Dec 16, 2016

import turtle
s=turtle.Screen()
t=turtle.Turtle()
t.color("darkgreen")
#one way to draw a tree
t.begin_fill()
points=[ [0,400], [-200,300],[-100,300],[-300,200],[-100,200],
[-400,0],[400,0],[100,200],[300,200],[100,300], [200,300],[0,400]]#first and last points are the same
for each in points:
t.goto(each)
t.end_fill()

t.penup()
t.color("brown")

t.begin_fill()
points=[ [100,0], [-100,0], [-100,-100], [100,-100],[100,0]]#first and last points are the same
for each in points:
t.goto(each)
t.end_fill()

light=turtle.Turtle()
light.shape("circle")
light.color("yellow")
light.penup()
light.goto(-200,300)

light=turtle.Turtle()
light.shape("circle")
light.color("yellow")
light.penup()
light.goto(-300,200)

light=turtle.Turtle()
light.shape("circle")
light.color("yellow")
light.penup()
light.goto(-400,0)

light=turtle.Turtle()
light.shape("circle")
light.color("yellow")
light.penup()
light.goto(400,0)

light=turtle.Turtle()
light.shape("circle")
light.color("yellow")
light.penup()
light.goto(300,200)

light=turtle.Turtle()
light.shape("circle")
light.color("yellow")
light.penup()
light.goto(200,300)

s.mainloop()

@rt5

This comment has been minimized.

rt5 commented Dec 16, 2016

No offence christmastree.py, but mine is much better

@ffiii

This comment has been minimized.

ffiii commented Dec 18, 2017

no offence rt5, but your christmas tree don't work

@smellysket

This comment has been minimized.

smellysket commented Dec 18, 2017

no offence ffiii, but i think you should not be so r00d# data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxISEhMREg8QEhUVDxEVFxcREhUQFRgXFhgWGBYSFRUYKCggGhoxGxYVLTEhJTUrLi4uGSAzODMsNyktLisBCgoKDg0OGxAQGTIlICIxListLysrKzIvLSsvLTUtLTctKzAyLzctLS0tLSstLS4tLTIrLS0uLSs3KysrNystLv/AABEIAPsAyQMBIgACEQEDEQH/xAAcAAEAAgMBAQEAAAAAAAAAAAAABAYBBQcDAgj/xABHEAACAgIBAgMFBAMLCgcAAAABAgADBBESBSEGEzEUIkFRoQcjMmFCcYEVFjM0UmJ0kZOU0SRTVFV1grGytNI1Y3JzhJKz/8QAGgEBAAIDAQAAAAAAAAAAAAAAAAMEAQIFBv/EACwRAQACAgEDAgQGAwEAAAAAAAABAgMRBCExQQUSIlGBkRNSYXGx0QYzQhT/2gAMAwEAAhEDEQA/AO4xEQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBERAREQEREBE1vXOt04lYsucjbBFVVax3c+ldda7Zm/IfmT2BM0b+IM60jyMOqhNn38ywlyBsdser56Hqw1v0kObkYsMbyWiI/VmKzPZbolR9u6n/AJzp39jkf98+X611KrZenp1q/wAr2i3D4/kQyWAj89j9Ur4/U+JknVckS2nHaPC4ROfJ9piqwWzHS33tH9zcgdSK9j3dVVGA2Nenx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l+sTIsWzLybK2pqe5ONljOp5ICFPva97Wj+XeB3Lw54ixctB5GVVcy1oXCMCwJHqy+o7g/tBm6nLvst8C5GLd7Vkjy2FLIlfMWNuwqXZ+O1GuC6AJ3sk69B1GAiIgIiICIiAiIgIiICIiAiIgIiICIiAmDMxA/NX2kvY3UsrzO/DI0hbuyqFQooJ9AAwIA7e/v1Jlaxvu2V0AVlOwV9xge/oy6Yep9CJ3b7Q/s5bPvXIpurqfy1RxapZSELFWUr3B0xB3vel9Nd6rR9i+Xv38zF1/NS3f69bG/wBWx+uBevsk6tbldPV7nZ2W+6sM5LOVRvd5sfxNrtv46l0ml8JeHq8DHGPWzOA7uWfiCWc7J0oAA/IfWbqAiIgIiICIiAiIgIiICIiAiIgIiICJA9ob5/QR7Q3z+ggT4kD2hvn9BHtDfP6CBPiQPaG+f0Ee0N8/oIE+JA9ob5/QR7Q3z+ggT4kD2hvn9BHtDfP6CBPiQPaG+f0Ee0N8/oIE+JA9ob5/QR7Q3z+ggT4kD2hvn9BHtDfP6CBPiQPaG+f0Ee0N8/oIE+JA9ob5/QR7Q3z+ggT4kD2hvn9BHtDfP6CBPiQPaG+f0Ee0N8/oIE+JA9ob5/QR7Q3z+ggf/9k=

@ffiii

This comment has been minimized.

ffiii commented Dec 18, 2017

no offence smelly, but your link don't work. whoops.

@X30nShaun

This comment has been minimized.

X30nShaun commented May 8, 2018

NO OFFENCE GUYS BUT ... WAIT THATS ALL I GOT :(

@PCHL1970

This comment has been minimized.

PCHL1970 commented Aug 22, 2018

Thanks, but your christmas tree don't work!!!

@nonysenpaii

This comment has been minimized.

nonysenpaii commented Nov 3, 2018

No puedo descargarlo hay alguien que me ayude :(?

@zaynemilena

This comment has been minimized.

zaynemilena commented Nov 5, 2018

It works thank you so much. -nonysenpaii download as Download ZIP-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment