덧셈뺄셈 클래스 만들기 class add_sub: def __init__(self,first,second): #생성자: 객체가 생성될 때 자동으로 호출되는 메서드 self.first=first self.second=second def add(self): result=self.first+self.second return result def sub(self): result=self.first-self.second return result a=add_sub(5,2) #add_sub 클래스를 사용하여 a 객체 생성 print(a.add()) #5+2=7 반환 2. 클래스의 상속 class fourcal(add_sub): #add_sub 클래스를 상속받아 mul(), div() 메서드를 추가하여 fourcal 클래스 생성 def mul(self): result=self.first*self.second return result def div(self): result=self.first/self...
원문 링크 : 클래스 (Class)