{"id":204554,"date":"2025-05-29T08:33:24","date_gmt":"2025-05-29T00:33:24","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204554\/"},"modified":"2025-05-29T08:33:24","modified_gmt":"2025-05-29T00:33:24","slug":"pta-python-%e4%bb%a3%e7%a0%81%e9%97%ae%e9%a2%98%ef%bc%9a%e5%ad%a6%e7%94%9f%e6%88%90%e7%bb%a9%e5%88%86%e6%9e%90%e4%bb%a3%e7%a0%81%e4%b8%ba%e4%bd%95%e6%97%a0%e6%b3%95%e9%80%9a%e8%bf%87%e6%89%80%e6%9c%89","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204554\/","title":{"rendered":"PTA Python \u4ee3\u7801\u95ee\u9898\uff1a\u5b66\u751f\u6210\u7ee9\u5206\u6790\u4ee3\u7801\u4e3a\u4f55\u65e0\u6cd5\u901a\u8fc7\u6240\u6709\u6d4b\u8bd5\u70b9\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>PTA Python \u4ee3\u7801\u95ee\u9898\uff1a\u5b66\u751f\u6210\u7ee9\u5206\u6790\u4ee3\u7801\u4e3a\u4f55\u65e0\u6cd5\u901a\u8fc7\u6240\u6709\u6d4b\u8bd5\u70b9\uff1f<\/h1>\n<p>\u4eca\u5929\u7ed9\u5927\u5bb6\u5e26\u6765\u4e86\uff0c\u5176\u4e2d\u6d89\u53ca\u5230\u7684\u77e5\u8bc6\u70b9\u5305\u62ec<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u65e0\u8bba\u4f60\u662f\u5c0f\u767d\u8fd8\u662f\u8001\u624b\uff0c\u90fd\u9002\u5408\u770b\u4e00\u770b\u54e6~\u6709\u597d\u7684\u5efa\u8bae\u4e5f\u6b22\u8fce\u5927\u5bb6\u5728\u8bc4\u8bba\u7559\u8a00\uff0c\u82e5\u662f\u770b\u5b8c\u6709\u6240\u6536\u83b7\uff0c\u4e5f\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u70b9\u8d5e\u652f\u6301\u5440\uff01\u4e00\u8d77\u52a0\u6cb9\u5b66\u4e60~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241110\/173122636467306afc8f894.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>pta \u4e0a\u7684 python \u4ee3\u7801\u95ee\u9898<\/strong><\/p>\n<p>\u4e00\u540d\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u4ee3\u7801\uff0c\u5e0c\u671b\u5b9e\u73b0\u5b66\u751f\u6210\u7ee9\u5206\u6790\u7684\u529f\u80fd\uff1a<\/p>\n<pre>...<\/pre>\n<p>\u6d4b\u8bd5\u8f93\u5165\u5982\u4e0b\uff1a<\/p>\n<pre>jack tom jim\n95 84 32\n90 75 45\n85 90 67<\/pre>\n<p>\u7136\u800c\uff0c\u4ee3\u7801\u53ea\u901a\u8fc7\u4e86\u90e8\u5206\u6d4b\u8bd5\u70b9\u3002\u95ee\u9898\u51fa\u5728\u54ea\u91cc\u5462\uff1f<\/p>\n<p><strong>\u5206\u6790<\/strong><\/p>\n<p>\u8be5\u4ee3\u7801\u6709\u4e24\u4e2a\u4e3b\u8981\u95ee\u9898\uff1a<\/p>\n<ol>\n<li><strong>get_sum \u65b9\u6cd5\u4e2d\u7684\u5206\u6570\u7d2f\u52a0\u9519\u8bef<\/strong>\uff1a\u5728 get_sum \u65b9\u6cd5\u4e2d\uff0cself.sum_score \u672a\u521d\u59cb\u5316\u4e3a 0\uff0c\u5bfc\u81f4\u6bcf\u6b21\u904d\u5386\u90fd\u4f1a\u7d2f\u52a0\u524d\u4e00\u6b21\u904d\u5386\u7684\u6240\u6709\u5206\u6570\u3002\u6b63\u786e\u7684\u505a\u6cd5\u662f\u6bcf\u6b21\u904d\u5386\u65f6\u8ba1\u7b97\u8be5\u5b66\u751f\u7684\u603b\u5206\u5e76\u7d2f\u52a0\u5230 list_score1 \u5217\u8868\u4e2d\u3002<\/li>\n<li><strong>list_score1 \u548c list_score2 \u6307\u5411\u540c\u4e00\u5217\u8868<\/strong>\uff1a\u5f00\u53d1\u8005\u521b\u5efa\u4e86\u4e00\u4e2a\u7a7a\u5217\u8868 list_score2\uff0c\u5e76\u5c06\u5176\u8d4b\u503c\u7ed9 list_score1\u3002\u8fd9\u5bfc\u81f4\u8fd9\u4e24\u4e2a\u53d8\u91cf\u6307\u5411\u540c\u4e00\u4e2a\u5217\u8868\u5bf9\u8c61\u3002\u5728\u5bf9 list_score1 \u8fdb\u884c\u6392\u5e8f\u540e\uff0clist_score2 \u7684\u5143\u7d20\u4e5f\u4f1a\u968f\u4e4b\u6539\u53d8\u3002\u89e3\u51b3\u65b9\u6cd5\u662f\u521b\u5efa\u53e6\u4e00\u4e2a\u5217\u8868\u5bf9\u8c61\uff0c\u7528\u4e8e\u5b58\u50a8\u6392\u5e8f\u540e\u7684\u5206\u6570\u5217\u8868\u3002<\/li>\n<\/ol>\n<p><strong>\u6539\u8fdb\u7684\u4ee3\u7801<\/strong><\/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        for i in range(len(self.s_name)):\n            self.sum_score += self.m_score[i] + self.c_score[i] + self.e_score[i]\n            list_score1.append(self.sum_score)\n\n    def get_best(self):\n        list_score2 = sorted(list_score1)\n        for k in range(len(list_score2)):\n            if list_score2[k] == list_score1[0]:\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>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300aPTA Python \u4ee3\u7801\u95ee\u9898\uff1a\u5b66\u751f\u6210\u7ee9\u5206\u6790\u4ee3\u7801\u4e3a\u4f55\u65e0\u6cd5\u901a\u8fc7\u6240\u6709\u6d4b\u8bd5\u70b9\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PTA Python \u4ee3\u7801\u95ee\u9898\uff1a&#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-204554","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204554","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=204554"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204554\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}