{"id":3285,"date":"2023-04-16T11:10:44","date_gmt":"2023-04-16T03:10:44","guid":{"rendered":"http:\/\/192.168.31.200\/?p=3285"},"modified":"2023-04-16T11:10:47","modified_gmt":"2023-04-16T03:10:47","slug":"python%e5%87%bd%e6%95%b0%e3%80%81%e6%96%90%e6%b3%a2%e9%82%a3%e5%a5%91%e6%95%b0%e5%88%97%e3%80%81%e5%88%97%e8%a1%a8%e6%8e%92%e5%ba%8f","status":"publish","type":"post","link":"http:\/\/xnw60rlg.ipyingshe.net:5347\/?p=3285","title":{"rendered":"python\u51fd\u6570\u3001\u6590\u6ce2\u90a3\u5951\u6570\u5217\u3001\u5217\u8868\u6392\u5e8f"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code># This is a sample Python script.\r\n\r\n# Press Shift+F10 to execute it or replace it with your code.\r\n# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.\r\n\r\ndef print_hi(name):\r\n    # Use a breakpoint in the code line below to debug your script.\r\n    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.\r\n    poem = '''\u6e05\u6668\u7684\u9633\u5149\uff0c\u7167\u4eae\u4e86\u5927\u5730\r\n    \u6625\u65e5\u7684\u6c14\u606f\uff0c\u6ee1\u6ea2\u7740\u5929\u5730\r\n    \u4eff\u4f5b\u4e00\u5207\u90fd\u5728\u547c\u5524\u7740\r\n    \u90a3\u4e2a\u8e0f\u5b9e\u7684\u65e9\u6668\r\n    \r\n    \u6668\u5149\u6e10\u660e\uff0c\u81ea\u7136\u7684\u8282\u62cd\r\n    \u751f\u547d\u4e0e\u4e16\u754c\u7ec6\u7ec6\u6d78\u67d3\r\n    \u5b81\u9759\u51dd\u805a\uff0c\u6de1\u5b9a\u7684\u5fc3\u60c5\r\n    \u671f\u5f85\u65e9\u5df2\u94ed\u523b\u7684\u7fc5\u8180\r\n    \r\n    \u5c0f\u9e1f\u8d77\u821e\uff0c\u82b1\u513f\u5410\u8273\r\n    \u6c89\u9759\u7684\u98ce\uff0c\u8f7b\u8f7b\u7684\u5439\u8fc7\r\n    \u65b0\u7684\u4e00\u5929\uff0c\u5728\u8fd9\u6837\u7684\u6c1b\u56f4\u4e2d\r\n    \u5f90\u5f90\u5c55\u5f00\uff0c\u7f8e\u597d\u7684\u672a\u6765\r\n    \r\n    \u613f\u6211\u4eec\u4fdd\u6301\u6e05\u9192\u7684\u5934\u8111\r\n    \u62e5\u6709\u6ee1\u6000\u6fc0\u60c5\u7684\u7cbe\u795e\r\n    \u5728\u65e9\u6668\u7684\u5149\u8292\u4e2d\u8d77\u822a\r\n    \u628a\u81ea\u5df1\u7684\u68a6\u60f3\u9a76\u5411\u672a\u6765'''\r\n    print(poem)\r\ndef fibnachii():\r\n    n = int(input(\"Enter the number of terms: \"))\r\n\r\n    # First two terms of the series\r\n    a = 0\r\n    b = 1\r\n\r\n    # Check if input is valid\r\n    if n &lt;= 0:\r\n        print(\"Please enter a positive integer\")\r\n    elif n == 1:\r\n        print(\"Fibonacci sequence upto\", n, \":\")\r\n        print(a)\r\n    else:\r\n        print(\"Fibonacci sequence:\")\r\n        for i in range(n):\r\n            print(a,end=\" \")\r\n            c = a + b\r\n            # Update values\r\n            a = b\r\n            b = c\r\n\r\ndef quick_sort(arr):\r\n    if len(arr) &lt; 2:\r\n        return arr\r\n    pivot = arr&#91;0]\r\n    less = &#91;x for x in arr&#91;1:] if x &lt;= pivot]\r\n    greater = &#91;x for x in arr&#91;1:] if x > pivot]\r\n    return quick_sort(less) + &#91;pivot] + quick_sort(greater)\r\n\r\narr = &#91;4, 2, 7, 1, 3, 5, 6]\r\n\r\n# Press the green button in the gutter to run the script.\r\nif __name__ == '__main__':\r\n    print_hi('PyCharm')\r\n    fibnachii()\r\n    print(f\"\\nQuick sort method {arr}\\n The Result:\")\r\n    print(quick_sort(arr))\r\n# See PyCharm help at https:\/\/www.jetbrains.com\/help\/pycharm\/\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-3285","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"http:\/\/xnw60rlg.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/xnw60rlg.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xnw60rlg.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xnw60rlg.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xnw60rlg.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3285"}],"version-history":[{"count":1,"href":"http:\/\/xnw60rlg.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3285\/revisions"}],"predecessor-version":[{"id":3286,"href":"http:\/\/xnw60rlg.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3285\/revisions\/3286"}],"wp:attachment":[{"href":"http:\/\/xnw60rlg.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xnw60rlg.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3285"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xnw60rlg.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}