{"id":13154,"date":"2022-12-13T15:34:40","date_gmt":"2022-12-13T07:34:40","guid":{"rendered":"https:\/\/fgchen.com\/wpedu\/?p=13154"},"modified":"2026-03-30T14:32:33","modified_gmt":"2026-03-30T06:32:33","slug":"tqc-%e7%a8%8b%e5%bc%8f%e8%aa%9e%e8%a8%80python-409-%e5%be%97%e7%a5%a8%e6%95%b8%e8%a8%88%e7%ae%97","status":"publish","type":"post","link":"https:\/\/fgchen.com\/wpedu\/2022\/12\/tqc-%e7%a8%8b%e5%bc%8f%e8%aa%9e%e8%a8%80python-409-%e5%be%97%e7%a5%a8%e6%95%b8%e8%a8%88%e7%ae%97\/","title":{"rendered":"TQC+ \u7a0b\u5f0f\u8a9e\u8a00Python 409 \u5f97\u7968\u6578\u8a08\u7b97"},"content":{"rendered":"1. \u984c\u76ee\u8aaa\u660e:\r\n\u8acb\u958b\u555fPYD409.py\u6a94\u6848\uff0c\u4f9d\u4e0b\u5217\u984c\u610f\u9032\u884c\u4f5c\u7b54\uff0c\u4f7f\u8f38\u51fa\u503c\u7b26\u5408\u984c\u610f\u8981\u6c42\u3002\u4f5c\u7b54\u5b8c\u6210\u8acb\u53e6\u5b58\u65b0\u6a94\u70baPYA409.py\u518d\u9032\u884c\u8a55\u5206\u3002\r\n\r\n2. \u8a2d\u8a08\u8aaa\u660e\uff1a\r\n\u67d0\u6b21\u9078\u8209\u6709\u5169\u4f4d\u5019\u9078\u4eba\uff0c\u5206\u5225\u662fNo.1: Nami\u3001No.2: Chopper\u3002\u8acb\u64b0\u5beb\u4e00\u7a0b\u5f0f\uff0c\u8f38\u5165\u4e94\u5f35\u9078\u7968\uff0c\u8f38\u5165\u503c\u5982\u70ba1\u5373\u8868\u793a\u91dd\u5c0d1\u865f\u5019\u9078\u4eba\u6295\u7968\uff1b\u8f38\u5165\u503c\u5982\u70ba2\u5373\u8868\u793a\u91dd\u5c0d2\u865f\u5019\u9078\u4eba\u6295\u7968\uff0c\u5982\u8f38\u5165\u5176\u4ed6\u503c\u5247\u8996\u70ba\u5ee2\u7968\u3002\u6bcf\u6b21\u6295\u5b8c\u5f8c\u9700\u5370\u51fa\u76ee\u524d\u6bcf\u4f4d\u5019\u9078\u4eba\u7684\u5f97\u7968\u6578\uff0c\u6700\u5f8c\u5370\u51fa\u6700\u9ad8\u7968\u8005\u70ba\u7576\u9078\u4eba\uff1b\u5982\u6700\u7d42\u8a08\u7b97\u6709\u76f8\u540c\u7684\u6700\u9ad8\u7968\u6578\u8005\u6216\u7121\u6cd5\u9078\u51fa\u6700\u9ad8\u7968\u8005\uff0c\u986f\u793a\u3010=&gt; No one won the election.\u3011\u3002\r\n\r\n3. \u8f38\u5165\u8f38\u51fa\uff1a\r\n\u8f38\u5165\u8aaa\u660e\r\n\u4e94\u500b\u6b63\u6574\u6578\uff081\u30012\u6216\u5176\u4ed6\uff09\r\n\r\n\u8f38\u51fa\u8aaa\u660e\r\n\u6bcf\u6b21\u6295\u5b8c\u5f8c\u9700\u5370\u51fa\u76ee\u524d\u6bcf\u4f4d\u5019\u9078\u4eba\u7684\u5f97\u7968\u6578\r\n\u4e94\u5f35\u9078\u7968\u6295\u7968\u5b8c\u6210\uff0c\u6700\u5f8c\u5370\u51fa\u6700\u9ad8\u7968\u8005\u70ba\u7576\u9078\u4eba\r\n\r\n\u8f38\u5165\u8207\u8f38\u51fa\u6703\u4ea4\u96dc\u5982\u4e0b\uff0c\u8f38\u51fa\u7684\u90e8\u4efd\u4ee5\u7c97\u9ad4\u5b57\u8868\u793a\r\n2\r\nTotal votes of No.1: Nami = 0\r\nTotal votes of No.2: Chopper = 1\r\nTotal null votes = 0\r\n1\r\nTotal votes of No.1: Nami = 1\r\nTotal votes of No.2: Chopper = 1\r\nTotal null votes = 0\r\n8\r\nTotal votes of No.1: Nami = 1\r\nTotal votes of No.2: Chopper = 1\r\nTotal null votes = 1\r\n2\r\nTotal votes of No.1: Nami = 1\r\nTotal votes of No.2: Chopper = 2\r\nTotal null votes = 1\r\n2\r\nTotal votes of No.1: Nami = 1\r\nTotal votes of No.2: Chopper = 3\r\nTotal null votes = 1\r\n=&gt; No.2 Chopper won the election.\r\n\r\n&nbsp;\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># TODO\r\n\r\nn1 = 0\r\nn2 = 0\r\nno = 0\r\n\r\nfor i in range(1, 6):\r\n    a = eval(input())\r\n\r\n    if a == 1:\r\n        n1 += 1\r\n    elif a == 2:\r\n        n2 += 1\r\n    else:\r\n        no += 1\r\n    print('Total votes of No.1: Nami = ',n1)\r\n    print('Total votes of No.2: Chopper = ', n2)\r\n    print('Total null votes = ', no)\r\n \r\nif n1 &gt; n2:\r\n    print('=&gt; No.1 Nami won the election.')\r\nelif n2 &gt; n1:\r\n    print('=&gt; No.2 Chopper won the election.')\r\nelse:\r\n    print('=&gt; No one won the election.')\r\n<\/pre>\r\n&nbsp;","protected":false},"excerpt":{"rendered":"<p>1. \u984c\u76ee\u8aaa\u660e: \u8acb\u958b\u555fPYD409.py\u6a94\u6848\uff0c\u4f9d\u4e0b\u5217\u984c\u610f\u9032\u884c\u4f5c\u7b54\uff0c\u4f7f\u8f38\u51fa\u503c\u7b26\u5408 &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[266],"tags":[],"class_list":["post-13154","post","type-post","status-publish","format-standard","hentry","category-266"],"_links":{"self":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/comments?post=13154"}],"version-history":[{"count":2,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13154\/revisions"}],"predecessor-version":[{"id":13689,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13154\/revisions\/13689"}],"wp:attachment":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/media?parent=13154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/categories?post=13154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/tags?post=13154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}