turtle python code code example

Example 1: how to import turtle in python

import turtle # imports it
whateverYouWantToCallIt = turtle.Turtle() # adds it to the project
#code
whateverYouWantToCallIt.forward(10) # moves whateverYouWantToCallIt forward
whateverYouWantToCallIt.color("purple") # color
whateverYouWantToCallIt.left(90) # turns him 90 degrees
whateverYouWantToCallIt.right(90) # turns him 90 degrees the other direction

Example 2: python turtle tutorial

>>> turtle.pos()
(440.00,-0.00)

Example 3: python turtle tutorial

>>> s = turtle.getscreen()

Example 4: turtle module python

>>> player_one = turtle.Turtle()
>>> player_one.color("green")
>>> player_one.shape("turtle")
>>> player_one.penup()
>>> player_one.goto(-200,100)
>>> player_two = player_one.clone()
>>> player_two.color("blue")
>>> player_two.penup()
>>> player_two.goto(-200,-100)

Example 5: python turtle tutorial

>>> turtle.heading()
22.0
>>> turtle.right(45)
>>> turtle.heading()
337.0

Example 6: python turtle tutorial

>>> turtle.position()
(0.00,40.00)
>>> turtle.sety(-10)
>>> turtle.position()
(0.00,-10.00)