python turtle 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: python turtle square
import turtle
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
Example 3: how to import turtle in python
import turtle
whateverYouWantToCallIt = turtle.Turtle()
whateverYouWantToCallIt.forward(10)
whateverYouWantToCallIt.color("purple")
whateverYouWantToCallIt.left(90)
whateverYouWantToCallIt.right(90)
Example 4: how to import turtle in Python
import turtle
win = turtle.Screen()
Example 5: python turtle
from turtle import *
color('red', 'yellow')
begin_fill()
while True:
forward(200)
left(170)
if abs(pos()) < 1:
break
end_fill()
done()
Example 6: python turtle
import Turtle
t = turtle.Turtle()