turtle python code example
Example 1: how to make a screen in turtle
def turtle_triangle():
window = turtle.Screen()
window.bgcolor("red")
brad = turtle.Turtle()
brad.shape("turtle")
brad.color("yellow")
brad.speed(1)
for _ in range(3):
brad.right(60)
brad.forward(200)
brad.right(60)
window.exitonclick()
Example 2: how to import turtle in python
import turtle
whateverYouWantToCallIt = turtle.Turtle()
whateverYouWantToCallIt.forward(10)
whateverYouWantToCallIt.color("purple")
whateverYouWantToCallIt.left(90)
whateverYouWantToCallIt.right(90)
Example 3: turtle python
from turtle import *
color('red', 'yellow')
begin_fill()
while True:
forward(200)
left(170)
if abs(pos()) < 1:
break
end_fill()
done()
Example 4: how to import turtle in Python
import turtle
win = turtle.Screen()
Example 5: Python turtle setup
import turtle
window_Name = turtle.Sreen()
turtle_Name = turtle.Turtle()
Example 6: turtle python
>>> tp = turtle.pos()
>>> tp
(0.00,0.00)
>>> turtle.setpos(60,30)
>>> turtle.pos()
(60.00,30.00)
>>> turtle.setpos((20,80))
>>> turtle.pos()
(20.00,80.00)
>>> turtle.setpos(tp)
>>> turtle.pos()
(0.00,0.00)