본문 바로가기
Python

python class2

by NaHyungMin 2019. 9. 6.

import Calculator;

 

cal1 = Calculator.Calculator();

cal2 = Calculator.Calculator();

 

print(cal1.Add(12));

print(cal1.Sub(12));

 

print(cal2.Add(22));

print(cal2.Sub(22));

 

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