EXTEND:我们添加了代码,以向用户提供更多关于他们的猜测准确度的反馈!

  • 点击运行并猜测斜率。你的猜测有多准确?
  • 继续尝试!用游戏来练习。
  • 当您准备好继续前进时,请单击提交下一个。

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

stage.set_axis(100) stage.create_grid_overlay(10, "grey") stage.set_background("soccerfield") ballx = -90 bally = random.randint(-100,100) # sprite = codesters.Sprite("image", x, y) ball = codesters.Sprite("soccerball", ballx, bally) netx = 80 nety = random.randint(-100,100) # sprite = codesters.Sprite("image", x, y) net = codesters.Sprite("soccernet", netx, nety) net.flip_right_left() #sprite = codesters.Line(x-start, y-start, x-end, y-end, "color") line = codesters.Line(ballx, bally, netx, nety, "blue") slopeguess = float(line.ask("What is the slope of this line?")) rise = nety - bally run = netx - ballx slope = rise / run # sprite = codesters.Text("text", x, y) sprite = codesters.Text(slope, 0, 30) newrise = slopeguess*run end_y = newrise + bally ball.set_color("red") ball.pen_down() ball.glide_to(netx, end_y)
  • Run Code
  • 提交作品
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)