预览:今天您将学习精灵,包括循环遍历列表以将精灵放置在舞台上。

  • 点击跑去看看你今天要设计的壁画的例子!
  • 此代码使用循环,即重复一定次数或列表中每个值的代码行。
  • 你认为这段代码中的循环重复了多少次?
  • 点击提交接下来每个活动结束时继续前进

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

stage.set_background_color("lightblue") # sprite = codesters.Rectangle(x, y, width, height, "color") sprite = codesters.Rectangle(0, 0, 700, 100, "gold") sprite.turn_left(45) # sprite = codesters.Rectangle(x, y, width, height, "color") sprite = codesters.Rectangle(0, 0, 100, 700, "gold") sprite.turn_left(45) sprite = codesters.Sprite("earth") people_sprites = ['person1', 'person2', 'person3', 'person4', 'person5', 'person6', 'person7', 'person8','person9', 'person10', 'person11', 'person12'] rotate = 90 for value in people_sprites: # add code here sprite = codesters.Sprite(value) stage.wait(0.5) sprite.set_size(0.3) sprite.set_speed(5) sprite.move_forward(120) sprite.turn_right(90) sprite.rotate_origin(rotate) rotate += 30 # sprite = codesters.Text("text", x, y) sprite = codesters.Text("STRENGTH IN DIVERSITY", 0, 200)
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)