演示 1 函数是一个经过定义的代码区块,具有特定的任务。

函数需要被调用才会运行。 定义函数之后,你可以在代码的任何位置调用函数。

  • 点击 运行 以查看函数的各个部分。
  • 点击控制台上的 下一步,查看每一行的作用。
  • 点击 提交 下一步,回答下一步中关于函数的问题。

To navigate the page using the TAB key, first press ESC to exit the code editor.

def tour(): sprite = codesters.Sprite("person1", -150, -60) sprite.say("I can take you on a tour") sprite.move_forward(550) tour()
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)