{"id":205024,"date":"2025-05-29T17:42:18","date_gmt":"2025-05-29T09:42:18","guid":{"rendered":"https:\/\/server.hk\/cnblog\/205024\/"},"modified":"2025-05-29T17:42:18","modified_gmt":"2025-05-29T09:42:18","slug":"python-student-%e7%b1%bb%e4%bb%a3%e7%a0%81%e9%94%99%e8%af%af%e5%88%86%e6%9e%90%ef%bc%9a%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%e6%80%bb%e5%88%86%e8%ae%a1%e7%ae%97%e5%92%8c%e6%9c%80%e9%ab%98%e5%88%86","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/205024\/","title":{"rendered":"Python Student \u7c7b\u4ee3\u7801\u9519\u8bef\u5206\u6790\uff1a\u5982\u4f55\u89e3\u51b3\u603b\u5206\u8ba1\u7b97\u548c\u6700\u9ad8\u5206\u67e5\u627e\u95ee\u9898\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python Student \u7c7b\u4ee3\u7801\u9519\u8bef\u5206\u6790\uff1a\u5982\u4f55\u89e3\u51b3\u603b\u5206\u8ba1\u7b97\u548c\u6700\u9ad8\u5206\u67e5\u627e\u95ee\u9898\uff1f<\/h1>\n<p>\u5c0f\u4f19\u4f34\u4eec\u5bf9\u6587\u7ae0\u7f16\u7a0b\u611f\u5174\u8da3\u5417\uff1f\u662f\u5426\u6b63\u5728\u5b66\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff1f\u5982\u679c\u662f\uff0c\u90a3\u4e48\u672c\u6587\u300aPython Student \u7c7b\u4ee3\u7801\u9519\u8bef\u5206\u6790\uff1a\u5982\u4f55\u89e3\u51b3\u603b\u5206\u8ba1\u7b97\u548c\u6700\u9ad8\u5206\u67e5\u627e\u95ee\u9898\uff1f\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff0c\u672c\u7bc7\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\u3002\u5728\u4e4b\u540e\u7684\u6587\u7ae0\u4e2d\u4e5f\u4f1a\u591a\u591a\u5206\u4eab\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241121\/1732195319673f33f7c7163.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u7406\u89e3 python \u4ee3\u7801\u4e2d\u7684 student \u7c7b<\/strong><\/p>\n<p>\u5728\u8fd9\u4e2a\u95ee\u9898\u4e2d\uff0c\u4f60\u9047\u5230\u4e86\u4f7f\u7528 python \u5b9a\u4e49 student \u7c7b\u7684\u4ee3\u7801\u90e8\u5206\u9519\u8bef\uff0c\u4ee3\u7801\u65e0\u6cd5\u901a\u8fc7\u6240\u6709\u6d4b\u8bd5\u70b9\u3002\u4e0b\u9762\u6211\u4eec\u5206\u6790\u4ee3\u7801\uff0c\u627e\u5230\u95ee\u9898\u7684\u6240\u5728\u3002<\/p>\n<p>\u9996\u5148\uff0c\u4ee3\u7801\u5b9a\u4e49\u4e86\u4e00\u4e2a student \u7c7b\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u4ee5\u4e0b\u5c5e\u6027\uff1a<\/p>\n<ul>\n<li><strong>student \u59d3\u540d\uff1a<\/strong>s_name<\/li>\n<li><strong>\u6570\u5b66\u5206\u6570\uff1a<\/strong>m_score<\/li>\n<li><strong>\u8bed\u6587\u5206\u6570\uff1a<\/strong>c_score<\/li>\n<li><strong>\u82f1\u8bed\u5206\u6570\uff1a<\/strong>e_score<\/li>\n<li><strong>\u603b\u5206\uff1a<\/strong>sum_score\uff08\u6700\u521d\u4e3a 0\uff09<\/li>\n<\/ul>\n<p><strong>get_sum \u65b9\u6cd5<\/strong><\/p>\n<p>get_sum \u65b9\u6cd5\u8d1f\u8d23\u8ba1\u7b97\u6bcf\u4e2a\u5b66\u751f\u7684\u603b\u5206\u5e76\u5b58\u50a8\u5728 list_score1 \u4e2d\u3002\u7136\u800c\uff0c\u5728\u4f60\u7684\u4ee3\u7801\u4e2d\uff0cself.sum_score \u6bcf\u6b21\u904d\u5386\u65f6\u90fd\u4f1a\u7d2f\u52a0\uff0c\u5bfc\u81f4\u6700\u7ec8\u7684\u603b\u5206\u4e0d\u6b63\u786e\u3002\u4fee\u6b63\u540e\u7684\u4ee3\u7801\u5e94\u8be5\u521d\u59cb\u5316 self.sum_score \u4e3a 0\uff0c\u7136\u540e\u9010\u4e2a\u5b66\u751f\u8fdb\u884c\u5206\u6570\u7d2f\u52a0\u3002<\/p>\n<p><strong>get_best \u65b9\u6cd5<\/strong><\/p>\n<p>get_best \u65b9\u6cd5\u8d1f\u8d23\u627e\u51fa\u603b\u5206\u6700\u9ad8\u7684 student \u5e76\u6253\u5370\u5176\u8be6\u7ec6\u4fe1\u606f\u3002\u5728\u4f60\u7684\u4ee3\u7801\u4e2d\uff0c\u4f60\u4f7f\u7528 list_score2 \u5b58\u50a8\u6392\u5e8f\u540e\u7684\u5206\u6570\u5217\u8868\uff0c\u4f46\u5b9e\u9645\u4e0a\u5b83\u6307\u5411\u540c\u4e00\u4e2a\u5217\u8868\u5bf9\u8c61 list_score1\u3002\u5f53 list_score1 \u88ab\u6392\u5e8f\u65f6\uff0clist_score2 \u4e5f\u968f\u4e4b\u6539\u53d8\u3002\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u5728 get_best \u65b9\u6cd5\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5217\u8868\u5bf9\u8c61\u5b58\u50a8\u6392\u5e8f\u540e\u7684\u5206\u6570\u5217\u8868\u3002<\/p>\n<p>\u4fee\u6b63\u540e\u6b63\u786e\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>class Student:\n    sum_score = 0\n\n    def __init__(self, s_name, m_score, c_score, e_score):\n        self.s_name = s_name\n        self.m_score = m_score\n        self.c_score = c_score\n        self.e_score = e_score\n\n    def get_sum(self):\n        self.sum_score = 0  # \u521d\u59cb\u5316\u603b\u5206\u4e3a 0\n        for i in range(0, list_len):\n            self.sum_score += self.m_score[i] + self.c_score[i] + self.e_score[i]\n            list_score1.append(self.sum_score)  # \u5b58\u50a8\u5355\u4e2a\u5b66\u751f\u7684\u603b\u5206\n\n    def get_best(self):\n        list_score1.sort()\n        sorted_scores = list(list_score1)  # \u521b\u5efa\u6392\u5e8f\u540e\u7684\u5206\u6570\u5217\u8868\u7684\u526f\u672c\n        for k in range(0, list_len):\n            if sorted_scores[0] == list_score1[k]:\n                best_name = self.s_name[k]\n                print(f'{best_name} {self.m_score[k]} {self.c_score[k]} {self.e_score[k]}', end='')<\/pre>\n<p>\u7406\u8bba\u8981\u638c\u63e1\uff0c\u5b9e\u64cd\u4e0d\u80fd\u843d\uff01\u4ee5\u4e0a\u5173\u4e8e\u300aPython Student \u7c7b\u4ee3\u7801\u9519\u8bef\u5206\u6790\uff1a\u5982\u4f55\u89e3\u51b3\u603b\u5206\u8ba1\u7b97\u548c\u6700\u9ad8\u5206\u67e5\u627e\u95ee\u9898\uff1f\u300b\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u5927\u5bb6\u90fd\u638c\u63e1\u4e86\u5427\uff01\u5982\u679c\u60f3\u8981\u7ee7\u7eed\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\uff0c\u90a3\u4e48\u5c31\u6765\u5173\u6ce8\u516c\u4f17\u53f7\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python Student \u7c7b&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-205024","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=205024"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/205024\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=205024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=205024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=205024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}