{"id":13191,"date":"2022-12-27T13:59:50","date_gmt":"2022-12-27T05:59:50","guid":{"rendered":"https:\/\/fgchen.com\/wpedu\/?p=13191"},"modified":"2026-03-30T14:32:08","modified_gmt":"2026-03-30T06:32:08","slug":"tqc-%e7%a8%8b%e5%bc%8f%e8%aa%9e%e8%a8%80python-506-%e4%b8%80%e5%85%83%e4%ba%8c%e6%ac%a1%e6%96%b9%e7%a8%8b%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/fgchen.com\/wpedu\/2022\/12\/tqc-%e7%a8%8b%e5%bc%8f%e8%aa%9e%e8%a8%80python-506-%e4%b8%80%e5%85%83%e4%ba%8c%e6%ac%a1%e6%96%b9%e7%a8%8b%e5%bc%8f\/","title":{"rendered":"TQC+ \u7a0b\u5f0f\u8a9e\u8a00Python 506 \u4e00\u5143\u4e8c\u6b21\u65b9\u7a0b\u5f0f"},"content":{"rendered":"1. \u984c\u76ee\u8aaa\u660e:\r\n\u8acb\u958b\u555fPYD506.py\u6a94\u6848\uff0c\u4f9d\u4e0b\u5217\u984c\u610f\u9032\u884c\u4f5c\u7b54\uff0c\u4f9d\u4f7f\u7528\u8005\u8f38\u5165\u7684\u6578\u5b57\u4f5c\u70ba\u53c3\u6578\u50b3\u905e\u9032\u884c\u516c\u5f0f\u8a08\u7b97\uff0c\u4f7f\u8f38\u51fa\u503c\u7b26\u5408\u984c\u610f\u8981\u6c42\u3002\u4f5c\u7b54\u5b8c\u6210\u8acb\u53e6\u5b58\u65b0\u6a94\u70baPYA506.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\u5c07\u4f7f\u7528\u8005\u8f38\u5165\u7684\u4e09\u500b\u6574\u6578\uff08\u4ee3\u8868\u4e00\u5143\u4e8c\u6b21\u65b9\u7a0b\u5f0f \u7684\u4e09\u500b\u4fc2\u6578a\u3001b\u3001c\uff09\u4f5c\u70ba\u53c3\u6578\u50b3\u905e\u7d66\u4e00\u500b\u540d\u70bacompute()\u7684\u51fd\u5f0f\uff0c\u8a72\u51fd\u5f0f\u56de\u50b3\u65b9\u7a0b\u5f0f\u7684\u89e3\uff0c\u5982\u7121\u89e3\u5247\u8f38\u51fa\u3010Your equation has no root.\u3011\r\n\r\n\u63d0\u793a\uff1a\r\n\u8f38\u51fa\u6709\u9806\u5e8f\u6027\r\n\u56de\u50b3\u65b9\u7a0b\u5f0f\u7684\u89e3\uff0c\u7121\u9808\u8003\u616e\u5c0f\u6578\u9ede\u4f4d\u6578\r\n\r\n3. \u8f38\u5165\u8f38\u51fa\uff1a\r\n\u8f38\u5165\u8aaa\u660e\r\n\u4e09\u500b\u6574\u6578\uff0c\u5206\u5225\u70baa\u3001b\u3001c\r\n\r\n\u8f38\u51fa\u8aaa\u660e\r\n\u4ee3\u5165\u4e00\u5143\u4e8c\u6b21\u65b9\u7a0b\u5f0f\uff0c\u56de\u50b3\u65b9\u7a0b\u5f0f\u89e3\uff1b\u5982\u7121\u89e3\u5247\u8f38\u51fa\u3010Your equation has no root.\u3011\r\n\r\n\u7bc4\u4f8b\u8f38\u51651\r\n2\r\n-3\r\n1\r\n\u7bc4\u4f8b\u8f38\u51fa1\r\n1.0, 0.5\r\n\u7bc4\u4f8b\u8f38\u51652\r\n9\r\n9\r\n8\r\n\u7bc4\u4f8b\u8f38\u51fa2\r\nYour equation has no root.\r\n\u7bc4\u4f8b\u8f38\u51653\r\n1\r\n2\r\n1\r\n\u7bc4\u4f8b\u8f38\u51fa3\r\n-1.0\r\n\r\n&nbsp;\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># TODO\r\n\r\n\r\n\r\n\r\n\"\"\"\r\nYour equation has no root.\r\n\"\"\"\r\n\r\nimport math\r\n\r\ndef compute(a, b, c):\r\n    d = (b*b - 4*a*c)\r\n\r\n    if d &gt; 0: \r\n        type = 2\r\n        x1 = (-b + math.sqrt(d) ) \/ (2*a)\r\n        x2 = (-b - math.sqrt(d) ) \/ (2*a)\r\n\r\n    elif d == 0:\r\n        type= 1\r\n        x1 = -b \/ (2*a)\r\n        x2 = x1\r\n        -3\r\n    elif d &lt; 0:\r\n        type = 0\r\n        x1 = 0\r\n        x2 = 0\r\n\r\n    return type, x1, x2\r\n\r\n\r\n\r\na = eval(input())\r\nb = eval(input())\r\nc = eval(input())\r\n\r\nt, x1, x2 = compute(a, b, c)\r\n\r\nif t == 0: \r\n    print('Your equation has no root.')\r\nelif t == 1:\r\n    print(x1)\r\nelif t == 2:\r\n    print(x1, end=', ')\r\n    print(x2)\r\n\r\n<\/pre>\r\n&nbsp;","protected":false},"excerpt":{"rendered":"<p>1. \u984c\u76ee\u8aaa\u660e: \u8acb\u958b\u555fPYD506.py\u6a94\u6848\uff0c\u4f9d\u4e0b\u5217\u984c\u610f\u9032\u884c\u4f5c\u7b54\uff0c\u4f9d\u4f7f\u7528\u8005\u8f38\u5165 &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-13191","post","type-post","status-publish","format-standard","hentry","category-266"],"_links":{"self":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13191","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=13191"}],"version-history":[{"count":2,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13191\/revisions"}],"predecessor-version":[{"id":13836,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13191\/revisions\/13836"}],"wp:attachment":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/media?parent=13191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/categories?post=13191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/tags?post=13191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}