Raspberry Pi - gpiozero Library
You want to create a program that blinks two LEDs on pins 17 and 27 alternately every 0.5 seconds for 5 seconds total. Which code snippet correctly implements this using the LED class?
from gpiozero import LED
from time import sleep
led1 = LED(17)
led2 = LED(27)
start = 0
while start < 5:
led1.on()
led2.off()
sleep(0.5)
led1.off()
led2.on()
sleep(0.5)
start += 1
led1.off()
led2.off()
led1.close()
led2.close()