파이썬 Thread 만들어 봤는데 정상인가요?

조회수 789회

python3 Thread를 사용하여 사칙연산 계산해봤는데 깔끔하게 정리해주실 수 있을까요?

from threading import Thread

a=0
b=0

def inputData():
    print("예) a+b=c")
    global a, b
    a = int(input("1_숫자를 입력하세요. >>"))
    b = int(input("2_숫자를 입력하세요. >>"))
    return a,b

def add(a,b):
    return a + b

def substract(a,b):
    return a - b

def divide(a,b):
    return a / b

def rest(a,b):
    return a * b


def arithmetic(a,b):
    print("\n add : %.1f \n substract : %.1f \n divide : %.1f \n rest %.1f"
          %(add(a,b),substract(a,b),divide(a,b),rest(a,b)))
    return


inputData()
th1 = Thread(target=arithmetic, args=(a,b))

th1.start()
  • (•́ ✖ •̀)
    알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)