#controlling led with respect to switch (internal pull down resistor)
from machine import Pin
from time import sleep
switchPin=Pin(4,Pin.IN,Pin.PULL_DOWN)
ledPin=Pin(5,Pin.OUT)
while True:
x=switchPin.value()
if x==1:
ledPin.value(1)
else:
ledPin.value(0)