回复 楼主 Zizr
新手上路,请多指教class ChengJiBiao():
"""about one's scores"""
def __init__(self, yu, shu, ying):
"""get one's scores"""
self.chengji = {}
self.chengji["yuwen"] = yu
self.chengji["shuxue"] = shu
self.chengji["yingyu"] = ying
def gekechengji(self):
"""show one's scores"""
for k, v in self.chengji.items():
print(k.upper() + ": " + str(v) + "\n")
def qiuhe(self):
"""get one's total score"""
he = sum(self.chengji.values())
print("Total Score: " + str(he) + "\n")
def pingjunzhi(self):
"""get one's average score"""
he = sum(self.chengji.values())
kemu = len(self.chengji)
print("Average Score: " + str(he/kemu) + "\n")
def zuigaofen(self):
"""get one's max score"""
fenshu = max(self.chengji.values())
print("Max Score: " + str(fenshu) + "\n")
def zuidifen(self):
"""get one's min socre"""
fenshu = min(self.chengji.values())
print("Min Score: " + str(fenshu) + "\n")
def zongpingfen(self):
"""get one's grade"""
yu_ping = self.chengji["yuwen"]*0.5
shu_ping = self.chengji["shuxue"]*0.3
ying_ping = self.chengji["yingyu"]*0.2
zong_ping = yu_ping + shu_ping + ying_ping
print("Total Grade: " + str(zong_ping) + "\n")
yu = int(input("yuwen chenji: "))
shu = int(input("shuxue chenji: "))
ying = int(input("yingyu chenji: "))
chengji = ChengJiBiao(yu, shu, ying)
chengji.gekechengji()
chengji.qiuhe()
chengji.pingjunzhi()
chengji.zuigaofen()
chengji.zuidifen()
chengji.zongpingfen()