Let's have the ball go to a random position on the stage.

  • Click on the Python tab. Then, go to and drag Random Integer into your program.
  • Change the variable name (before the equals sign) to x.
  • Change the numbers to (-100, 150).

This command picks a random x-coordinate between -100 and 150. The coordinate is stored in the variable named x.

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

stage.set_background("halfcourt") sprite = codesters.Sprite("player4") sprite.go_to(215, -175) net = codesters.Sprite("basketballnet") net.go_to(215, 175) ball = codesters.Sprite("basketball")
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)