언어/Python
성적입력받아 최대값과 최소값 차이 구하기
power-girl0-0
2020. 12. 2. 09:59
728x90
class Score:
def __init__(self):
self.jumsu=[]
def input_gap(self):
for i in range(0, 10):
num = int(input("성적 입력 : "))
self.jumsu.append(num)
def high_score(self):
high = 0
for base in self.jumsu:
if high < base:
high = base
return high
def low_score(self):
low = self.high_score()
for base in self.jumsu:
if low > base:
low = base
return low
def gap_score(self):
gap = self.high_score() - self.low_score()
return gap
s = Score()
s.input_gap()
print("==> 최대값: %d 최소값: %d 차이값: %d"%(s.high_score(),s.low_score(),s.gap_score()))
728x90