python [계산기]
언어/python2016. 2. 12. 15:12
class Calculation:
# [1] -------------------------------------------------------------
def __init__(self):
self.value1 = 0
self.value2 = 0
# [2] -------------------------------------------------------------
def summation(self):
print("{0:d} + {1:d} = {2:d}"\
.format(self.value1, self.value2, self.value1+self.value2))
# [3] -------------------------------------------------------------
def subraction(self):
print("{0:d} - {1:d} = {2:d}"\
.format(self.value1, self.value2, self.value1+self.value2))
# [4] -------------------------------------------------------------
def multiplication(self):
print("{0:d} x {1:d} = {2:d}"\
.format(self.value1, self.value2, self.value1*self.value2))
# [5] -------------------------------------------------------------
def dividen(self):
print("{0:d} / {1:d} = {2:.1f}"\
.format(self.value1, self.value2, float(self.value1)/self.value2))
# [6]-------------------------------------------------------------
def remainder(self):
print("{0:d} % {1:d} = {2:d}"\
.format(self.value1, self.value2, self.value1 % self.value2))
def main():
study = Calculation
study.value1 = int(input("study.value1 >> "))
study.value2 = int(input("study.value2 >> "))
study.summation(study)
study.subraction(study)
study.multiplication(study)
study.dividen(study)
study.remainder(study)
if __name__ == "__main__":
main()
'언어 > python' 카테고리의 다른 글
암호 ver3.0 (0) | 2016.02.15 |
---|---|
암호 ver2 (0) | 2016.02.15 |
python [ 구구단 ] (0) | 2016.02.11 |
python random (0) | 2016.02.11 |
시저 한글 ,영어(대, 소문자) 제어 버전 (0) | 2016.02.11 |