from turtle import Turtle
timmy_the_turtle = Turtle()
screen = Screen()
screen.exitonclick()
turtle - Turtle graphics - Python 3.10.3 documentation
colors manual page - Tk Built-In Commands
from turtle import Turtle
timmy_the_turtle = Turtle()
timmy_the_turtle.shape("turtle") #烏龜形狀
timmy_the_turtle.color("red") #烏龜顏色
timmy_the_turtle.forward(100) #烏龜前進
timmy_the_turtle.right(90) #向右轉
screen = Screen()
screen.exitonclick()
Challenge 1 Draw a Square
timmmy_the_turtle.forward(100)
timmy_the_turtle.right(90)
timmmy_the_turtle.forward(100)
timmy_the_turtle.right(90)
timmmy_the_turtle.forward(100)
timmy_the_turtle.right(90)
timmmy_the_turtle.forward(100)
timmy_the_turtle.right(90)
or
for _ in range(4):
timmmy_the_turtle.forward(100)
timmy_the_turtle.right(90)
語法1:import [module]
# Import 整個 `random` module
import random
# 使用 `random` module 底下的 `randint` function
print(random.randint(0, 5))