标题:python程序设计基础
只看楼主
Zizr
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-3-13
 问题点数:0 回复次数:1 
python程序设计基础

有没有大佬们会哒!球球了,程序设计鲨我。
搜索更多相关主题的帖子: 基础 程序设计 python 
2020-03-13 12:09
X月黑风高
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-3-7
得分:0 
回复 楼主 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()
2020-03-14 15:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-499745-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.342137 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved