from machine import Pin
import time, random
green = Pin(1, Pin.OUT)
red = Pin(2, Pin.OUT)
while True:
a = random.randint(0,10)
b = random.choice(['+', '-'])
c = random.randint(0,10)
equation = f'{a} {b} {c} = '
temp = input(equation)
ans = eval(str(a) + b + str(c))
if int(temp) == ans:
print('정답입니다!')
green.value(1)
time.sleep(3)
green.value(0)
else:
print(f'오답입니다. 정답은 {ans} 입니다.')
red.value(1)
time.sleep(3)
red.value(0)