{"id":584,"date":"2020-11-17T04:12:10","date_gmt":"2020-11-16T20:12:10","guid":{"rendered":"https:\/\/byy3.com\/?p=584"},"modified":"2021-01-09T10:08:04","modified_gmt":"2021-01-09T02:08:04","slug":"python%e5%85%a5%e9%97%a8%e5%ae%9e%e4%be%8b%e7%ae%80%e5%8d%95%e8%ae%a1%e7%ae%97%e9%95%bf%e6%96%b9%e5%bd%a2%e5%92%8c%e4%b8%89%e8%a7%92%e5%bd%a2%e5%92%8c%e5%9c%86%e5%bd%a2%e7%9a%84%e9%9d%a2%e7%a7%af","status":"publish","type":"post","link":"https:\/\/byy3.com\/?p=584","title":{"rendered":"python\u5165\u95e8\u5b9e\u4f8b\u7b80\u5355\u8ba1\u7b97\u957f\u65b9\u5f62\u548c\u4e09\u89d2\u5f62\u548c\u5706\u5f62\u7684\u9762\u79ef\u548c\u7b80\u5355\u8ba1\u7b97"},"content":{"rendered":"<pre>#\u5b9a\u4e49\u957f\u65b9\u5f62\u3001\u4e09\u89d2\u5f62\u3001\u5706\u5f62\u7684\u9762\u79ef\u8ba1\u7b97\u65b9\u6cd5\r\ndef changfangxing(a,b): #\u957f\u548c\u5bbd\r\n \u00a0 s=a*b #\u957f\u4e58\u4ee5\u5bbd \u5f97\u5230\u9762\u79ef\r\n return s\r\ndef sanjiaoxing(d,h):\r\n s=(d*h)\/2\r\n return s\r\ndef yuanxing(r):\r\n s=2*3.14*r\r\n return s<\/pre>\n<pre># \u51fd\u6570\u8d4b\u503c \u63a5\u53d7\u7528\u6237\u8f93\u5165\u6570\u636e\r\na = int(input('\u8bf7\u8f93\u5165\u957f\u65b9\u5f62\u7684\u957f'))\r\nb = int(input('\u8bf7\u8f93\u5165\u957f\u65b9\u5f62\u7684\u5bbd'))\r\ncfx = changfangxing(a,b)\r\nsjx = sanjiaoxing(2,5)\r\nyx = yuanxing(4)\r\nprint ('\u957f\u65b9\u5f62\u7684\u9762\u79ef\u662f%f'%cfx)\r\nprint ('\u4e09\u89d2\u5f62\u7684\u9762\u79ef\u662f%f'%sjx)\r\nprint ('\u5706\u5f62\u7684\u9762\u79ef\u662f%f'%yx)<\/pre>\n<p>&nbsp;<\/p>\n<p>out: #\u8f93\u51fa\u7ed3\u679c<\/p>\n<pre>\u8bf7\u8f93\u5165\u957f\u65b9\u5f62\u7684\u957f4\r\n\u8bf7\u8f93\u5165\u957f\u65b9\u5f62\u7684\u5bbd4\r\n\u957f\u65b9\u5f62\u7684\u9762\u79ef\u662f16.000000\r\n\u4e09\u89d2\u5f62\u7684\u9762\u79ef\u662f5.000000\r\n\u5706\u5f62\u7684\u9762\u79ef\u662f25.120000\r\n\r\n\u770b\u6548\u679c\uff1a\r\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-587\" data-original=\"https:\/\/byy3.com\/wp-content\/uploads\/2020\/11\/2020111715535556.png\" src=\"https:\/\/byy3.com\/wp-content\/themes\/MNews%20V2.4\/images\/post-loading.gif\" width=\"1140\" height=\"691\" title=\"python\u5165\u95e8\u5b9e\u4f8b\u7b80\u5355\u8ba1\u7b97\u957f\u65b9\u5f62\u548c\u4e09\u89d2\u5f62\u548c\u5706\u5f62\u7684\u9762\u79ef\u548c\u7b80\u5355\u8ba1\u7b97\u63d2\u56fe\" alt=\"python\u5165\u95e8\u5b9e\u4f8b\u7b80\u5355\u8ba1\u7b97\u957f\u65b9\u5f62\u548c\u4e09\u89d2\u5f62\u548c\u5706\u5f62\u7684\u9762\u79ef\u548c\u7b80\u5355\u8ba1\u7b97\u63d2\u56fe\" \/>\r\n\r\n<\/pre>\n<h1 id=\"python\u4e24\u4e2a\u968f\u673a\u6570\u76f8\u52a0\">Python\u4e24\u4e2a\u968f\u673a\u6570\u76f8\u52a0<\/h1>\n<pre class=\"prettyprint\"><code class=\"hljs rsl has-numbering\">import <span class=\"hljs-built_in\">random<\/span> <span class=\"hljs-preprocessor\">#\u5f15\u5165\u968f\u673a\u6570\u7684\u6a21\u5757 <\/span>\r\n\r\n<span class=\"hljs-preprocessor\"># \u4ea7\u751f\u4e24\u4e2a\u968f\u673a\u6574\u6570\uff080-9\uff09<\/span>\r\nnumber1 = <span class=\"hljs-built_in\">random<\/span>.randint(<span class=\"hljs-number\">0<\/span>, <span class=\"hljs-number\">9<\/span>)\r\nnumber2 = <span class=\"hljs-built_in\">random<\/span>.randint(<span class=\"hljs-number\">0<\/span>, <span class=\"hljs-number\">9<\/span>)\r\n\r\n<span class=\"hljs-preprocessor\"># \u8f93\u5165\u7b54\u6848<\/span>\r\nanswer = eval(input(<span class=\"hljs-string\">\"What is \"<\/span> + str(number1) + <span class=\"hljs-string\">\" + \"<\/span> \r\n + str(number2) + <span class=\"hljs-string\">\"? \"<\/span>))\r\n\r\n<span class=\"hljs-preprocessor\"># \u663e\u793a\u7ed3\u679c <\/span>\r\nprint(number1, <span class=\"hljs-string\">\"+\"<\/span>, number2, <span class=\"hljs-string\">\"=\"<\/span>, answer, \r\n <span class=\"hljs-string\">\"is\"<\/span>, number1 + number2 == answer)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#\u5b9a\u4e49\u957f\u65b9\u5f62\u3001\u4e09\u89d2\u5f62\u3001\u5706\u5f62\u7684\u9762\u79ef\u8ba1\u7b97\u65b9\u6cd5 def changfangxing(a,b): #\u957f\u548c\u5bbd \u00a0 s=a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":587,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[33,60,59,352,35],"class_list":["post-584","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python"],"_links":{"self":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts\/584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=584"}],"version-history":[{"count":0,"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/media\/587"}],"wp:attachment":[{"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}