To activate turtle from Python Interpreter enter:
from turtle import *
# This imports Turtle and all of its commands.
turtle commands:
forward(distance)
- Moves the turtle forward by the specified distance, in the direction the turtle is headed.
- Move the turtle backward by distance, opposite to the direction the turtle is headed. Does not change the turtle’s heading.
right(angle) - Turn turtle right by angle units. (Units are by default degrees)
left(angle)
- Turn turtle left by angle units. (Units are by default degrees)
goto (x,y)
or
setposition (x,y)
- Moves the turtle to coordinates (x,y) and if the pen is down, draw a line.
home( )
- Moves the turtle back to (0,0)
circle (radius, extent)
- Draws a circle with radius.
- extent refers to the number of degrees (e.g. 180 = semicircle)
undo( )
- Undo (repeatedly) the last turtle action. speed(speed)
- Sets how fast the turtle will draw (1-10 arbitrary units)
position( )
- Returns the (x,y) coordinates of the turtle.
pendown( )
- Puts the pen down so it draws when the turtle moves.
penup( )
- Puts the pen up so it does not draw when the turtle moves.
pencolor(colorstring)
- if colorstring == a color like "green" it will draw the line in that color.
reset( )
- Delete everything and set turtle back to 0
clear()
- Delete drawings but keeps turtle where it is.
No comments:
Post a Comment