opensw-project / Calculator

GNU General Public License v2.0
3 stars 6 forks source link

일반 계산기에 공학용 계산기 기능 추가 #20

Closed kyeong98 closed 1 year ago

kyeong98 commented 1 year ago

4) 공학용 계산기 제작

class scientific_calculator(calculator): def squared(self, inp1, inp2): print(inp1 * inp2) def factorial(self, inp1): for i in range(inp1-1, 0, -1): inp1 = inp1 i print(inp1) 5) 인스턴스 생성

new_cal = scientific_calculator() 6) 확인 (1) 일반 계산기 확인

new_cal.add(1, 2) new_cal.sub(1, 2) new_cal.mul(2, 3) new_cal.div(4, 2)

3 -1 6 2.0 (2) 추가 기능 확인

new_cal.squared(2, 4) new_cal.factorial(3)

출처 https://pbj0812.tistory.com/256

kyeong98 commented 1 year ago

제곱 기능, 팩토리얼 기능 추가 코드입니다