第9步:我们也希望程序根据 y 坐标选择一条随机的道路。

我们有4条特定的 y 值道路。当函数运行时,我们想要一辆汽车出现在其中一条道路上。

  • 在名为 road_list 的函数中创建一个 List of Integers ,它的值为 [-150, -50, 50, 150]。
  • 将另一个 Random Choice 拖动到函数内部,并将其命名为 rand_y
  • random中的.choice() 参数更改为 road_list

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

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)