{"id":13066,"date":"2022-10-11T14:52:11","date_gmt":"2022-10-11T06:52:11","guid":{"rendered":"https:\/\/fgchen.com\/wpedu\/?p=13066"},"modified":"2026-03-30T14:33:14","modified_gmt":"2026-03-30T06:33:14","slug":"python%e7%ac%ac%e4%ba%8c%e7%ab%a0%e8%aa%b2%e6%9c%ac%e7%bf%92%e9%a1%8c%e5%8f%83%e8%80%83","status":"publish","type":"post","link":"https:\/\/fgchen.com\/wpedu\/2022\/10\/python%e7%ac%ac%e4%ba%8c%e7%ab%a0%e8%aa%b2%e6%9c%ac%e7%bf%92%e9%a1%8c%e5%8f%83%e8%80%83\/","title":{"rendered":"Python\u7b2c\u4e8c\u7ae0\u8ab2\u672c\u7fd2\u984c\u53c3\u8003"},"content":{"rendered":"\u7b2c\u4e00\u984c\r\n\r\n\u4e00\u5143\u4e8c\u6b21\u65b9\u7a0b\u5f0f\u7684\u516c\u5f0f\u89e3 (a !=0)\uff1a\r\n\r\n<img decoding=\"async\" src=\"https:\/\/wikimedia.org\/api\/rest_v1\/media\/math\/render\/svg\/41ec504e72005c70da117bc058b8550ac8fb2122\" alt=\"{\\displaystyle x_{1,2}={\\frac {-b\\pm {\\sqrt {b^{2}-4ac\\ }}}{2a}}}\" \/>\r\n\r\n&nbsp;\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import math\r\na, b, c = eval(input('Input a, b, and c:'))\r\ndeter = b*b - 4*a*c\r\nif deter &gt; 0:\r\n    answer1 = (-b + math.sqrt(deter)) \/ (2*a)\r\n    answer2 = (-b - math.sqrt(deter)) \/ (2*a)\r\n    print('The solution are %f and %f' %(answer1, answer2))\r\nelif deter == 0:\r\n    answer = -b \/(2*a)\r\n    print('The solution is %f' %(answer))\r\nelse:\r\n    print('No solution!')<\/pre>\r\n&nbsp;\r\n\r\n2nd\r\n\r\n\u5beb\u4e00\u7a0b\u5f0f\uff0c\u8f38\u5165\u4e00\u500b\u9ede\u7684\u5ea7\u6a19(x, y)\uff0c\u8f38\u51fa\u9019\u500b\u9ede\u662f\u5426\u5728\u5713\u5fc3(0,0)\uff0c\u534a\u5f918\u7684\u5713\u7684\u5167\u90e8\u6216\u5916\u90e8\u3002\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import math\r\nx, y = eval(input('Input x and y :'))\r\nd = math.sqrt(x**2 + y**2)\r\nif d &lt; 8:\r\n    print('The point (%d, %d) is inside of the circle' %(x,y))\r\nelse:\r\n    print('The point (%d, %d) is not inside of the circle' %(x,y))\r\n<\/pre>\r\n&nbsp;\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import random\r\nr = random.randint(1, 100)\r\nr3 = r % 3\r\nr5 = r % 5\r\nif r3 == 0 and r5 == 0 :\r\n    print('%d \u662f 3 \u800c\u4e14 \u4e5f\u662f 5 \u7684\u500d\u6578' %(r))\r\nelif r3 != 0 and r5 != 0 :\r\n    print('%d \u4e0d\u662f 3 \u800c\u4e14 \u4e5f\u4e0d\u662f 5 \u7684\u500d\u6578' %(r))\r\nelif r3 == 0:\r\n    print('%d \u662f 3 \u7684\u500d\u6578' %(r))\r\nelif r5 == 0:\r\n    print('%d \u662f 5 \u7684\u500d\u6578' %(r))<\/pre>\r\n&nbsp;\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># \u5c07\u4f7f\u7528\u8005\u8f38\u5165\u7684\u5341\u516d\u9032\u4f4d\u7684\u5b57\u5143\u8f49\u63db\u70ba\u5176\u5341\u9032\u4f4d\u6240\u5c0d\u61c9\u7684\u6578\u503c\r\nc = input('\u8acb\u8f38\u5165\u4e00\u500b\u5b57\u5143\uff1a')\r\nif c &gt;= '0' and c &lt;= '9':\r\n    print('\u5c0d\u61c9\u7684\u5341\u9032\u4f4d\u503c\u662f %d' %(ord(c) - ord('0')))\r\nelif c &gt;= 'A' and c &lt;= 'F':\r\n    print('\u5c0d\u61c9\u7684\u5341\u9032\u4f4d\u503c\u662f %d' %(ord(c) - ord('A') + 10))\r\nelif c &gt;= 'a' and c &lt;= 'f':\r\n    print('\u5c0d\u61c9\u7684\u5341\u9032\u4f4d\u503c\u662f %d' %(ord(c) - ord('a') + 10))<\/pre>\r\n&nbsp;","protected":false},"excerpt":{"rendered":"<p>\u7b2c\u4e00\u984c \u4e00\u5143\u4e8c\u6b21\u65b9\u7a0b\u5f0f\u7684\u516c\u5f0f\u89e3 (a !=0)\uff1a &nbsp; import m &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-13066","post","type-post","status-publish","format-standard","hentry","category-266"],"_links":{"self":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13066","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=13066"}],"version-history":[{"count":5,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13066\/revisions"}],"predecessor-version":[{"id":13950,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/13066\/revisions\/13950"}],"wp:attachment":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/media?parent=13066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/categories?post=13066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/tags?post=13066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}