{"id":352,"date":"2025-10-10T15:45:40","date_gmt":"2025-10-10T07:45:40","guid":{"rendered":"http:\/\/www.pyteam.cn\/?p=352"},"modified":"2025-10-14T14:33:22","modified_gmt":"2025-10-14T06:33:22","slug":"%e7%bb%83%e4%b9%a02%ef%bc%9a%e5%ae%9e%e9%99%85%e9%97%ae%e9%a2%98%e5%ba%94%e7%94%a8-14-6","status":"publish","type":"post","link":"http:\/\/www.pyteam.cn\/index.php\/2025\/10\/10\/%e7%bb%83%e4%b9%a02%ef%bc%9a%e5%ae%9e%e9%99%85%e9%97%ae%e9%a2%98%e5%ba%94%e7%94%a8-14-6\/","title":{"rendered":"\u7ec3\u4e602\uff1a\u5b9e\u9645\u95ee\u9898\u5e94\u7528 14.6"},"content":{"rendered":"\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:clamp(18px, 1.125rem, 27px);font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#90A4AE;--cbp-line-number-width:calc(2 * 0.6 * 1.125rem);line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#ededed;color:#8198a3\">Python<\/span><span role=\"button\" tabindex=\"0\" style=\"color:#90A4AE;display:none\" aria-label=\"\u590d\u5236\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># \u5b9e\u9645\u95ee\u9898\uff1a\u8d2d\u7269\u95ee\u9898\ndef shopping_problem():\n    \"\"\"\u8d2d\u7269\u95ee\u9898\u6c42\u89e3\"\"\"\n    print(\"\u8d2d\u7269\u95ee\u9898\uff1a\")\n    print(\"\u5c0f\u660e\u4e703\u4e2a\u82f9\u679c\u548c2\u4e2a\u68a8\u5171\u82b118\u5143\")\n    print(\"\u5c0f\u7ea2\u4e702\u4e2a\u82f9\u679c\u548c1\u4e2a\u68a8\u5171\u82b111\u5143\")\n    print(\"\u6c42\u82f9\u679c\u548c\u68a8\u7684\u5355\u4ef7\u5404\u662f\u591a\u5c11\uff1f\")\n    \n    # \u8bbe\u82f9\u679c\u5355\u4ef7x\uff0c\u68a8\u5355\u4ef7y\n    # 3x + 2y = 18\n    # 2x + y = 11\n    \n    result = solve_linear_equation(3, 2, 18, 2, 1, 11)\n    print(result)\n\nshopping_problem()<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki material-theme-lighter\" style=\"background-color: #FAFAFA\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #90A4AE; font-style: italic\"># \u5b9e\u9645\u95ee\u9898\uff1a\u8d2d\u7269\u95ee\u9898<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9C3EDA\">def<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #6182B8\">shopping_problem<\/span><span style=\"color: #39ADB5\">():<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #39ADB5; font-style: italic\">&quot;&quot;&quot;<\/span><span style=\"color: #90A4AE; font-style: italic\">\u8d2d\u7269\u95ee\u9898\u6c42\u89e3<\/span><span style=\"color: #39ADB5; font-style: italic\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #6182B8\">print<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #91B859\">\u8d2d\u7269\u95ee\u9898\uff1a<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #39ADB5\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #6182B8\">print<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #91B859\">\u5c0f\u660e\u4e703\u4e2a\u82f9\u679c\u548c2\u4e2a\u68a8\u5171\u82b118\u5143<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #39ADB5\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #6182B8\">print<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #91B859\">\u5c0f\u7ea2\u4e702\u4e2a\u82f9\u679c\u548c1\u4e2a\u68a8\u5171\u82b111\u5143<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #39ADB5\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #6182B8\">print<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #91B859\">\u6c42\u82f9\u679c\u548c\u68a8\u7684\u5355\u4ef7\u5404\u662f\u591a\u5c11\uff1f<\/span><span style=\"color: #39ADB5\">&quot;<\/span><span style=\"color: #39ADB5\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #90A4AE; font-style: italic\"># \u8bbe\u82f9\u679c\u5355\u4ef7x\uff0c\u68a8\u5355\u4ef7y<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #90A4AE; font-style: italic\"># 3x + 2y = 18<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #90A4AE; font-style: italic\"># 2x + y = 11<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    result <\/span><span style=\"color: #39ADB5\">=<\/span><span style=\"color: #90A4AE\"> <\/span><span style=\"color: #6182B8\">solve_linear_equation<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #F76D47\">3<\/span><span style=\"color: #39ADB5\">,<\/span><span style=\"color: #6182B8\"> <\/span><span style=\"color: #F76D47\">2<\/span><span style=\"color: #39ADB5\">,<\/span><span style=\"color: #6182B8\"> <\/span><span style=\"color: #F76D47\">18<\/span><span style=\"color: #39ADB5\">,<\/span><span style=\"color: #6182B8\"> <\/span><span style=\"color: #F76D47\">2<\/span><span style=\"color: #39ADB5\">,<\/span><span style=\"color: #6182B8\"> <\/span><span style=\"color: #F76D47\">1<\/span><span style=\"color: #39ADB5\">,<\/span><span style=\"color: #6182B8\"> <\/span><span style=\"color: #F76D47\">11<\/span><span style=\"color: #39ADB5\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #90A4AE\">    <\/span><span style=\"color: #6182B8\">print<\/span><span style=\"color: #39ADB5\">(<\/span><span style=\"color: #6182B8\">result<\/span><span style=\"color: #39ADB5\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6182B8\">shopping_problem<\/span><span style=\"color: #39ADB5\">()<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":388,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,5],"tags":[],"class_list":["post-352","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-23","category-5"],"views":311,"_links":{"self":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/comments?post=352"}],"version-history":[{"count":1,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/352\/revisions"}],"predecessor-version":[{"id":353,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/352\/revisions\/353"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media\/388"}],"wp:attachment":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media?parent=352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/categories?post=352"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/tags?post=352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}