{"id":4367,"date":"2019-12-16T06:34:37","date_gmt":"2019-12-16T05:34:37","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=4367"},"modified":"2019-12-16T06:34:37","modified_gmt":"2019-12-16T05:34:37","slug":"a-function-to-calculate","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/a-function-to-calculate\/","title":{"rendered":"A function to calculate %"},"content":{"rendered":"<p>A little script to calculate percentage:<\/p>\n<pre class=\"lang:default decode:true \">def percent(expression):\r\n    if \"%\" in expression:\r\n        expression = expression.replace(\"%\",\"\/100\")\r\n    return eval(expression)\r\n\r\n&gt;&gt;&gt; percent(\"1500*20%\")\r\n300.0<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"A little script to calculate percentage: def percent(expression): if &#8220;%&#8221; in expression: expression = expression.replace(&#8220;%&#8221;,&#8221;\/100&#8243;) return eval(expression) &gt;&gt;&gt; percent(&#8220;1500*20%&#8221;) 300.0 &nbsp;\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/a-function-to-calculate\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[651],"tags":[],"class_list":["post-4367","post","type-post","status-publish","format-standard","hentry","category-math"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":true,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=4367"}],"version-history":[{"count":1,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4367\/revisions"}],"predecessor-version":[{"id":4368,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/4367\/revisions\/4368"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=4367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=4367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=4367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}