{"id":184105,"date":"2022-04-17T21:48:14","date_gmt":"2022-04-17T13:48:14","guid":{"rendered":"http:\/\/www.idc.net\/help\/184105\/"},"modified":"2022-04-17T21:48:14","modified_gmt":"2022-04-17T13:48:14","slug":"python-%e7%a8%8b%e5%ba%8f%ef%bc%9a%e8%ae%a1%e7%ae%97%e7%94%b5%e8%b4%b9","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/184105\/","title":{"rendered":"Python \u7a0b\u5e8f\uff1a\u8ba1\u7b97\u7535\u8d39"},"content":{"rendered":"<p>\u540e\u6d6a\u4e91Python\u6559\u7a0b\uff1a<\/p>\n<p>\u7528\u5b9e\u4f8b\u7f16\u5199 Python \u7a0b\u5e8f\u8ba1\u7b97\u7535\u8d39\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u4f7f\u7528\u4e86 Elif \u8bed\u53e5\u3002<\/p>\n<h2>\u8ba1\u7b97\u7535\u8d39\u7684 Python \u7a0b\u5e8f\u793a\u4f8b 1<\/h2>\n<p>\u8fd9\u4e2a python \u7a0b\u5e8f\u5141\u8bb8\u7528\u6237\u8f93\u5165\u7528\u6237\u6d88\u8017\u7684\u5355\u4f4d\u3002\u63a5\u4e0b\u6765\uff0cPython \u8ba1\u7b97\u603b\u7535\u8d39\u3002\u5982\u679c\u7535\u529b\u5c40\u5bf9\u4e0d\u540c\u7684\u8bbe\u5907\u6536\u53d6\u4e0d\u540c\u7684\u8d39\u7528\uff0c\u8fd9\u79cd\u65b9\u6cd5\u662f\u6709\u7528\u7684\u3002\u5bf9\u4e8e\u8fd9\u4e2a\u4f8b\u5b50\uff0c\u6211\u4eec\u4f7f\u7528\u7684\u662f Elif \u8bed\u53e5\u3002<\/p>\n<pre><code># Python Program to Calculate Electricity Bill\n\nunits = int(input(\" Please enter Number of Units you Consumed : \"))\n\nif(units &lt; 50):\n    amount = units * 2.60\n    surcharge = 25\nelif(units &lt;= 100):\n    amount = 130 + ((units - 50) * 3.25)\n    surcharge = 35\nelif(units &lt;= 200):\n    amount = 130 + 162.50 + ((units - 100) * 5.26)\n    surcharge = 45\nelse:\n    amount = 130 + 162.50 + 526 + ((units - 200) * 8.45)\n    surcharge = 75\n\ntotal = amount + surcharge\nprint(\"\\nElectricity Bill = %.2f\"  %total)<\/code><\/pre>\n<\/p>\n<h2>Python \u7a0b\u5e8f\u67e5\u627e\u7535\u8d39\u793a\u4f8b 2<\/h2>\n<p>\u5982\u679c\u7535\u8def\u677f\u5177\u6709\u7edf\u4e00\u7684\u901f\u7387\uff0c\u5219\u8be5 Python \u4ee3\u7801\u975e\u5e38\u6709\u7528\u3002\u7c7b\u4f3c\u4e8e:\u5982\u679c\u4f60\u6d88\u8017 300 \u5230 500 \u4e2a\u5355\u4f4d\uff0c\u90a3\u4e48\u5355\u4f4d\u56fa\u5b9a\u4e3a 7.75 \u5362\u6bd4\uff0c\u7b49\u7b49\u3002\u8ba9\u6211\u4eec\u770b\u770b python \u7a0b\u5e8f<\/p>\n<p>\u63d0\u793a: Elif \u8bed\u53e5\u5148\u68c0\u67e5\u87d2\u7684\u60c5\u51b5\u3002\u5982\u679c\u4e3a\u771f\uff0c\u5219\u6267\u884c\u8be5\u5757\u4e2d\u7684\u8bed\u53e5\u3002\u5982\u679c\u6761\u4ef6\u4e3a\u5047\uff0c\u5219 python \u7a0b\u5e8f\u68c0\u67e5\u4e0b\u4e00\u4e2a\u6761\u4ef6(Elif \u6761\u4ef6)\u7b49\u7b49\u3002<\/p>\n<pre><code># Python Program to Calculate Electricity Bill\n\nunits = int(input(\" Please enter Number of Units you Consumed : \"))\n\nif(units &gt; 500):\n    amount = units * 9.65\n    surcharge = 85\nelif(units &gt;= 300):\n    amount = units * 7.75\n    surcharge = 75\nelif(units &gt;= 200):\n    amount = units * 5.26\n    surcharge = 55\nelif(units &gt;= 100):\n    amount = units * 3.76\n    surcharge = 35\nelse:\n    amount = units * 2.25\n    surcharge = 25\n\ntotal = amount + surcharge\nprint(\"\\nElectricity Bill = %.2f\"  %total)<\/code><\/pre>\n<p>\u87d2\u7535\u7a0b\u5e8f\u8f93\u51fa<\/p>\n<pre><code> Please enter Number of Units you Consumed : 450\n\nElectricity Bill = 3562.50\n&gt;&gt;&gt; \n Please enter Number of Units you Consumed : 750\n\nElectricity Bill = 7322.50\n&gt;&gt;&gt; \n Please enter Number of Units you Consumed : 250\n\nElectricity Bill = 1370.00\n&gt;&gt;&gt; \n Please enter Number of Units you Consumed : 150\n\nElectricity Bill = 599.00\n&gt;&gt;&gt; \n Please enter Number of Units you Consumed : 50\n\nElectricity Bill = 137.50<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u540e\u6d6a\u4e91Python\u6559\u7a0b\uff1a \u7528\u5b9e\u4f8b\u7f16\u5199 Python \u7a0b\u5e8f\u8ba1\u7b97\u7535\u8d39\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u4f7f\u7528\u4e86 Elif \u8bed\u53e5\u3002 \u8ba1\u7b97\u7535\u8d39 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182397],"tags":[],"class_list":["post-184105","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/184105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=184105"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/184105\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=184105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=184105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=184105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}