Pythong Module Turtle Simple usage

Source: Internet
Author: User
# #初始化turtle:
t = Turtle. Turtle () or t = Turtle. Pen ()
# #查询turtle状态
#位置
T.position ()

#箭头朝向, the arrows are oriented clockwise or counterclockwise, depending on the value of Turtle.mode () clockwise or counterclockwise, the default turtle.mode () = Standard, which indicates a counterclockwise direction; logo indicates clockwise

T.heading ()
#初始状态下箭头向右转20度, t.heading () = 340
T.right (20)
T.left (20)
#向前或向后
T.forward (10)
T.backward (10)
#设置turtle位置
T.goto (x, y) = T.setpos (x, y) = T.setposition (x, y)

T.setx (x)
T.sety (y)
#设置turtle方向, specific direction and Turtle.mode, default standard, set to 90 degrees, arrow pointing to True North
T.setheading (90)

#turtle回到初始位置和初始方向
T.home ()
#画圆, the first parameter is a radius, the radius is positive, the default circle is drawn counterclockwise, the radius is negative, and the circle is drawn clockwise.
#t. Circle ( -20,90), clockwise, Radius 20 arc, Radian 90
#t. Circle (20,90,10), the third parameter specifies a total of a few steps to finish, equivalent to a polygon
T.circle (20)

Pythong Module Turtle Simple usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.