PASO 11: ¡Hora de contar cuánto tiempo ha pasado!

Las variables creadas FUERA de un evento no se pueden cambiar DENTRO de un evento . Usamos la palabra clave global para hacer una excepción a esta regla. global nos permite usar una variable dentro y fuera de un evento.

  • En LÓGICA, haga clic en y arrastre Global Variable DENTRO de su evento de intervalo.
  • Cambie la variable después de global de my_var a time .

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

microbit = codesters.Microbit() microbit.show_string("hello") data = microbit.get_temp() microbit.show_number(data) data_list = [] time_list = [] my_display = codesters.ScatterPlot(time_list, data_list) time = 0 def interval(): data = microbit.get_temp() data_list.append(data) stage.event_interval(interval, 2)
  • Run Code
  • Enviar Trabajo
  • Actividad Siguiente
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)