| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1366 人关注过本帖
标题: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
快速回复:python程序设计基础
数据加载中...
 
   



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

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