import Calculator;
cal1 = Calculator.Calculator(); cal2 = Calculator.Calculator();
print(cal1.Add(1, 2)); print(cal1.Sub(1, 2));
print(cal2.Add(2, 2)); print(cal2.Sub(2, 2)); |
class Calculator: def __init__(self): self.result = 0;
def Add(self, number1, number2): return number1 + number2;
def Sub(self, number1, number2): return number1 - number2; |
3
-1
4
0
'Python' 카테고리의 다른 글
python exception2 (0) | 2019.09.06 |
---|---|
python exception (0) | 2019.09.06 |
python class (0) | 2019.09.04 |
python file 입출력 (0) | 2019.09.03 |
python input, print (0) | 2019.09.02 |