DekGenius.com
PYTHON
how to run turtle in python
#import turtle
import turtle
b=turtle.Pen()
b.speed(50)
for i in range(4):
for i in range(4):
for i in range(4):
for i in range(8):
for i in range(3):
for i in range(6):
b.fd(10)
b.lt(60)
b.lt(120)
b.fd(30)
for i in range(2):
b.lt(90)
b.fd(30)
b.lt(-90)
b.fd(10)
b.lt(90)
b.fd(200)
b.lt(90)
install turtle command
python turtle commands
"""
TURTLE COMMANDS
command shortcut makes the turtle """
goto(x, y) setpos(x, y) # go to x, y coordinates
forward(d) fd(d) # go forward d units
back(d) bk(d) # go backward d units
left(a) lt(a) # rotate left a degrees
right(a) rt(a) # rotate right a degrees
setheading(h) seth(h) # set heading to h degrees
write(text) # write text in the screen
python turtle
import turtle
myTurtle = turtle.Turtle()
myTurtle.forward(100)
myTurtle.right(90)
myTurtle.forward(100)
python turtle tutorial
>>> turtle.position()
(0.00,240.00)
>>> turtle.setx(10)
>>> turtle.position()
(10.00,240.00)
python turtle tutorial
>>> turtle.heading()
22.0
>>> turtle.right(45)
>>> turtle.heading()
337.0
python turtle
import turtle
tina=turtle.Turtle()
#trinket.io specializes in these stuff
python turtle tutorial
>>> turtle.heading()
22.0
>>> turtle.left(45)
>>> turtle.heading()
67.0
python turtle tutorial
>>> turtle.pos()
(440.00,-0.00)
python turtle tutorial
>>> turtle.position()
(0.00,0.00)
>>> turtle.backward(30)
>>> turtle.position()
(-30.00,0.00)
python turtle tutorial
>>> turtle.position()
(0.00,0.00)
>>> turtle.forward(25)
>>> turtle.position()
(25.00,0.00)
>>> turtle.forward(-75)
>>> turtle.position()
(-50.00,0.00)
python turtle tutorial
>>> turtle.position()
(0.00,40.00)
>>> turtle.sety(-10)
>>> turtle.position()
(0.00,-10.00)
python turtle tutorial
>>> turtle.heading()
90.0
>>> turtle.position()
(0.00,-10.00)
>>> turtle.home()
>>> turtle.position()
(0.00,0.00)
>>> turtle.heading()
0.0
python turtle tutorial
>>> turtle.setheading(90)
>>> turtle.heading()
90.0
python turtle tutorial
>>> turtle.color("blue")
>>> turtle.stamp()
11
>>> turtle.fd(50)
python turtle tutorial
>>> turtle.speed()
3
>>> turtle.speed('normal')
>>> turtle.speed()
6
>>> turtle.speed(9)
>>> turtle.speed()
9
python turtle
import turtle
tim = turtle.Pen()
t.shape('turtle')
t.pensize(5)
t.color('blue')
t.speed(1)
python turtle tutorial
>>> turtle.home()
>>> turtle.dot()
>>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50)
>>> turtle.position()
(100.00,-0.00)
>>> turtle.heading()
0.0
python turtle tutorial
>>> for i in range(4):
... turtle.fd(50); turtle.lt(80)
...
>>> for i in range(8):
... turtle.undo()
© 2022 Copyright:
DekGenius.com