{"id":13202,"date":"2022-12-27T15:46:57","date_gmt":"2022-12-27T07:46:57","guid":{"rendered":"https:\/\/fgchen.com\/wpedu\/?p=13202"},"modified":"2026-03-30T14:31:56","modified_gmt":"2026-03-30T06:31:56","slug":"tqc-%e7%a8%8b%e5%bc%8f%e8%aa%9e%e8%a8%80python-510-%e8%b2%bb%e6%b0%8f%e6%95%b8%e5%88%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-510-%e8%b2%bb%e6%b0%8f%e6%95%b8%e5%88%97\/","title":{"rendered":"TQC+ \u7a0b\u5f0f\u8a9e\u8a00Python 510 \u8cbb\u6c0f\u6578\u5217"},"content":{"rendered":"1. \u984c\u76ee\u8aaa\u660e:\r\n\u8acb\u958b\u555fPYD510.py\u6a94\u6848\uff0c\u4f9d\u4e0b\u5217\u984c\u610f\u9032\u884c\u4f5c\u7b54\uff0c\u8a08\u7b97\u8cbb\u6c0f\u6578\u5217\uff0c\u4e26\u4f9d\u8f38\u5165\u7684\u6b63\u6574\u6578\u56de\u50b3\u8cbb\u6c0f\u6578\u5217\u524dn\u500b\u6578\u503c\uff0c\u4f7f\u8f38\u51fa\u503c\u7b26\u5408\u984c\u610f\u8981\u6c42\u3002\u4f5c\u7b54\u5b8c\u6210\u8acb\u53e6\u5b58\u65b0\u6a94\u70baPYA510.py\u518d\u9032\u884c\u8a55\u5206\u3002\r\n\r\n2. \u8a2d\u8a08\u8aaa\u660e\uff1a\r\n\u8acb\u64b0\u5beb\u4e00\u7a0b\u5f0f\uff0c\u8a08\u7b97\u8cbb\u6c0f\u6578\u5217\uff08Fibonacci numbers\uff09\uff0c\u4f7f\u7528\u8005\u8f38\u5165\u4e00\u6b63\u6574\u6578num (num&gt;=2)\uff0c\u4e26\u5c07\u5b83\u50b3\u905e\u7d66\u540d\u70bacompute()\u7684\u51fd\u5f0f\uff0c\u6b64\u51fd\u5f0f\u5c07\u8f38\u51fa\u8cbb\u6c0f\u6578\u5217\u524dnum\u500b\u7684\u6578\u503c\u3002\r\n\r\n\u63d0\u793a\uff1a\u8cbb\u6c0f\u6578\u5217\u7684\u67d0\u4e00\u9805\u6578\u5b57\u662f\u5176\u524d\u5169\u9805\u7684\u548c\uff0c\u800c\u4e14\u7b2c0\u9805\u70ba0\uff0c\u7b2c\u4e00\u9805\u70ba1\uff0c\u8868\u793a\u65b9\u5f0f\u5982\u4e0b\uff1a\r\n\r\n3. \u8f38\u5165\u8f38\u51fa\uff1a\r\n\u8f38\u5165\u8aaa\u660e\r\n\u4e00\u500b\u6b63\u6574\u6578num (num&gt;=2)\r\n\r\n\u8f38\u51fa\u8aaa\u660e\r\n\u4f9d\u8f38\u5165\u503cnum\uff0c\u8f38\u51fa\u8cbb\u6c0f\u6578\u5217\u524dnum\u500b\u7684\u6578\u503c\uff08\u6bcf\u500b\u6578\u503c\u5f8c\u65b9\u70ba\u4e00\u500b\u534a\u5f62\u7a7a\u683c\uff09\r\n\r\n\u7bc4\u4f8b\u8f38\u51651\r\n10\r\n\u7bc4\u4f8b\u8f38\u51fa1\r\n0 1 1 2 3 5 8 13 21 34\r\n\u7bc4\u4f8b\u8f38\u51652\r\n20\r\n\u7bc4\u4f8b\u8f38\u51fa2\r\n0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">def compute(n):\r\n    if (n == 0 or n ==1):        \r\n        return n    \r\n    \r\n    return compute(n-1) + compute(n-2)\r\n\r\nn = eval(input())\r\n\r\nfor i in range(0, n):\r\n    f = compute(i)\r\n    print(f, end=' ')\r\n\r\n<\/pre>\r\n&nbsp;\r\n\r\n&nbsp;","protected":false},"excerpt":{"rendered":"<p>1. \u984c\u76ee\u8aaa\u660e: \u8acb\u958b\u555fPYD510.py\u6a94\u6848\uff0c\u4f9d\u4e0b\u5217\u984c\u610f\u9032\u884c\u4f5c\u7b54\uff0c\u8a08\u7b97\u8cbb\u6c0f\u6578\u5217 &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-13202","post","type-post","status-publish","format-standard","hentry","category-266"],"_links":{"self":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13202","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=13202"}],"version-history":[{"count":2,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13202\/revisions"}],"predecessor-version":[{"id":13493,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13202\/revisions\/13493"}],"wp:attachment":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/media?parent=13202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/categories?post=13202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/tags?post=13202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}