PASO 12: Vamos a calcular la pendiente real de la línea. Para hacerlo, necesitaremos la subida (cambio entre las coordenadas y) y la carrera (cambio entre las coordenadas x)

  • Haga clic en la pestaña LÓGICA, luego y arrastre Delta Y .
  • Cambie el nombre de la variable de delta_y a rise .
  • ¡Cambia y2 a nety e y1 a bally para restar las dos coordenadas y y obtener el aumento!

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 = -80 bally = random.randint(-100,100) # sprite = codesters.Sprite("image", x, y) ball = codesters.Sprite("soccerball", ballx, bally) netx = 90 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?"))
  • Run Code
  • Enviar Trabajo
  • Actividad Siguiente
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)