Tree / Another Python code

in #python5 years ago

Hey, so today I wanted to share with you a little easy Python code, what makes tree.
Im at the moment learning Python in school and in home, to develop bigger things in future.
So here´s the code, enjoy!

import turtle
import random

mel = turtle.Turtle()
mel.shape("turtle")
mel.speed(1)

#1 Esimene kolmnurk (First Triangle)
mel.penup()
mel.goto(0,0)
mel.color("black")
mel.begin_fill()
mel.fillcolor("green")
mel.pensize(8)
mel.pendown()
mel.goto(100,0)
mel.penup()
mel.end_fill()

#2 Teine kolmnurk (Second triangle)
mel.goto(100,0)
mel.pendown()
mel.color("black")
mel.begin_fill()
mel.fillcolor("green")
mel.goto(0,75)
mel.goto(-100,0)
mel.forward(100)
mel.goto(125,-65)
mel.goto(-125,-65)
mel.goto(0,0)
mel.penup()
mel.end_fill()

#3 Kolmas kolmnurk (Third Triangle)
mel.goto(0,75)
mel.pendown()
mel.color("black")
mel.begin_fill()
mel.fillcolor("green")
mel.goto(50,75)
mel.goto(0,120)
mel.goto(-50,75)
mel.goto(0,75)
mel.penup()
mel.end_fill()

#4 Känd
mel.goto(0,-90)
mel.pendown()
mel.color("brown")
mel.begin_fill()
mel.fillcolor("brown")
mel.goto(20,-90)
mel.left(90)
mel.forward(20)
mel.left(90)
mel.forward(40)
mel.left(90)
mel.forward(20)
mel.left(90)
mel.forward(20)
mel.penup()
mel.end_fill()

for i in range(18):
mel.penup()
x = random.randint(-75, 75)
y = random.randint(-65, 120)
size = random.randint(1, 10)
colors = (random.choice(ornament_list))
mel.goto(x, y)
mel.pendown()
draw_circle(mel, colors, size, x, y)
mel.penup()

mel.goto(250, -250)

done ()


I added also a little picture of this project.

Coin Marketplace

STEEM 0.19
TRX 0.25
JST 0.038
BTC 97262.35
ETH 3392.76
USDT 1.00
SBD 3.02