furas.pl
# prywatne notatki - Python, Linux, Machine Learning, etc.

Rysowanie w Turtle - Schodki

WERSJA ROBOCZA WPISU
import turtle

turtle.tracer(2)#False)

def up():
    for _ in range(10):
        turtle.forward(10)
        turtle.left(90)
        turtle.forward(10)
        turtle.left(-90)

def down():
    for _ in range(10):
        turtle.forward(10)
        turtle.left(-90)
        turtle.forward(10)
        turtle.left(90)

def example1():
    for _ in range(2):
        up()
        down()
        turtle.left(180)

def example2():
    for _ in range(4):
        up()
        turtle.right(90)

def example3():
    for _ in range(4):
        turtle.right(-90)
        up()

#example1()
#example2()
example3()

for _ in range(12):
    example3()
    turtle.right(30)

turtle.update()
turtle.mainloop()
import turtle

turtle.tracer(4)#False)

def up():
    for _ in range(10):
        turtle.forward(10)
        turtle.left(90)
        turtle.forward(10)
        turtle.left(-90)

def down():
    for _ in range(10):
        turtle.forward(10)
        turtle.left(-90)
        turtle.forward(10)
        turtle.left(90)

def example1(*args):
    turtle.onscreenclick(None)
    for _ in range(2):
        up()
        down()
        turtle.left(180)
    turtle.onscreenclick(example2)

def example2(*args):
    turtle.onscreenclick(None)
    for _ in range(4):
        up()
        turtle.right(90)
    turtle.onscreenclick(example3)

def example3(*args):
    turtle.onscreenclick(None)
    for _ in range(4):
        turtle.right(-90)
        up()
    turtle.onscreenclick(example4)

def example4(*args):
    turtle.onscreenclick(None)
    for _ in range(12):
        example3()
        turtle.right(30)
    turtle.onscreenclick(None)
    turtle.onscreenclick(lambda x,y:turtle.bye())

example4()
#example2()
#example3()

turtle.update()
turtle.mainloop()
Książki: python-dla-kazdego-podstawy-programowania python-wprowadzenie python-leksykon-kieszonkowy python-receptury python-programuj-szybko-i-wydajnie python-projekty-do-wykorzystania black-hat-python-jezyk-python-dla-hackerow-i-pentesterow efektywny-python-59-sposobow-na-lepszy-kod tdd-w-praktyce-niezawodny-kod-w-jezyku-python aplikacje-internetowe-z-django-najlepsze-receptury