Answers for "python turtle change the position"

2

get position of turtle python

import turtle
t = turtle.Turtle()

turtles_position = t.pos() # Will return a tuple that includes both X and Y
# coordinates of the turtle named t respectively, E.G (200,600).

turtles_positionX = t.xcor() # Will return a float value of the turtle's
# X position.

turtles_positionY = t.ycor() # Will return a float value of the turtle's
# Y position.

###############################################################
# Make sure to round the last 2 method's numbers as without   #
# rounding you can get numbers like 299.99999999999994.       #
# (You can round with the round(integer) function)			  #
###############################################################
Posted by: Guest on September-13-2021
0

python turtle set direction

>>> turtle.setheading(90)
>>> turtle.heading()
90.0
#Set the number in set heading to the direction you want the turtle to face.
Posted by: Guest on March-11-2021

Code answers related to "python turtle change the position"

Python Answers by Framework

Browse Popular Code Answers by Language