import Calculator;
cal1 = Calculator.Calculator();
print(cal1.Add(3, 2)); |
class Calculator: def __init__(self): self.result = 0;
def Add(self, number1, number2): result = 0; try: #Error Create #raise();
if(type(number1) != int or type(number2) != int): raise(); else: result = number1 + number2;
except Exception as e: return -1;
return result;
def Sub(self, number1, number2): return number1 - number2; |
'Python' 카테고리의 다른 글
python all (0) | 2019.09.06 |
---|---|
python exception2 (0) | 2019.09.06 |
python class2 (0) | 2019.09.06 |
python class (0) | 2019.09.04 |
python file 입출력 (0) | 2019.09.03 |