KRITSADA icon

Once the program has run 3

KRITSADA | PRO | 08/22/21 04:07:09 PM UTC | 0 ⭐ | 1531 👁️ | Never ⏰ | []
Python |

530 B

|

None

|

0 👍

/

0 👎

from microbit import *
import random
 
tries = 3
for i in range(tries):
  counter = 0
  sleep_time = random.randint(2000,5000) #creates a random number between 2000 and 5000
  sleep(sleep_time) # does nothing for 2-5 seconds 
  display.show(Image.SKULL) 
  while True:
    counter += 1
    sleep(10)
    if button_a.is_pressed():
      display.scroll(str(counter) + 'hundrethds',60) # prints out reaction time
      break
    
#TASK 2: Once the program has run 3 times print best time with button b and average with button a

Comments