<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calculate percentage then round in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86260#M6775</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm no python expert by any means but have you looked at the round() method?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/17470883/how-to-round-to-two-decimal-places-in-python-2-7" title="http://stackoverflow.com/questions/17470883/how-to-round-to-two-decimal-places-in-python-2-7"&gt;http://stackoverflow.com/questions/17470883/how-to-round-to-two-decimal-places-in-python-2-7&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Jan 2016 17:19:00 GMT</pubDate>
    <dc:creator>JoeBorgione</dc:creator>
    <dc:date>2016-01-18T17:19:00Z</dc:date>
    <item>
      <title>Calculate percentage then round</title>
      <link>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86259#M6774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am very new to Python but need to write a script to add 20% to a field and then round that number with the 20% to the next 50. I have figured out the calculations but for the life of me can't figure out how to put them together to get it into one function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried this in the code block:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def boom_length(boom):
&amp;nbsp;&amp;nbsp;&amp;nbsp; twenty_percent = ((!LENGTH_FT!) * 0.2) + !LENGTH_FT!)
&amp;nbsp;&amp;nbsp;&amp;nbsp; math.ceil(twenty_percent + (50 - twenty_percent) % 50)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return twenty_percent&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then in the expression:&lt;/P&gt;&lt;P&gt;boom_length(!BOOM_LEN!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for the help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:18:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86259#M6774</guid>
      <dc:creator>JudsonCrouch1</dc:creator>
      <dc:date>2021-12-10T23:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage then round</title>
      <link>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86260#M6775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm no python expert by any means but have you looked at the round() method?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/17470883/how-to-round-to-two-decimal-places-in-python-2-7" title="http://stackoverflow.com/questions/17470883/how-to-round-to-two-decimal-places-in-python-2-7"&gt;http://stackoverflow.com/questions/17470883/how-to-round-to-two-decimal-places-in-python-2-7&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jan 2016 17:19:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86260#M6775</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2016-01-18T17:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage then round</title>
      <link>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86261#M6776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def boom_length(boom):
&amp;nbsp;&amp;nbsp;&amp;nbsp; import math
&amp;nbsp;&amp;nbsp;&amp;nbsp; twenty_percent = boom * 0.2 + boom
&amp;nbsp;&amp;nbsp;&amp;nbsp; twenty_percent = math.ceil(twenty_percent + (50 - twenty_percent) % 50)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return twenty_percent&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:18:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86261#M6776</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-10T23:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage then round</title>
      <link>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86262#M6777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;...and to explain the reason for these changes:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;you have to import math to be able to use it (I think)&lt;/LI&gt;&lt;LI&gt;The function will have no knowledge of the field !LENGTH_FT!, so you have to use the parameter "boom" instead&lt;/LI&gt;&lt;LI&gt;There were some problems with unpaired brackets&lt;/LI&gt;&lt;LI&gt;You have to assign the result of the math.ceiling to the variable you return or simply say:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14531382941681168" data-renderedposition="147.984375_8_912_16" jivemacro_uid="_14531382941681168"&gt;&lt;P&gt;return math.ceil(twenty_percent + (50 - twenty_percent) % 50)&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jan 2016 17:32:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86262#M6777</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-01-18T17:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage then round</title>
      <link>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86263#M6778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this is on the right track but it does not pull the value to add 20% to from the field "LENGTH_FT". My mistake...I should have mentioned that in the original post. I need it to pull a value from the field "LENGTH_FT", add 20% to it, then round that number up to the nearest 50 and store it in the field "BOOM_LEN"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jan 2016 17:36:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86263#M6778</guid>
      <dc:creator>JudsonCrouch1</dc:creator>
      <dc:date>2016-01-18T17:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage then round</title>
      <link>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86264#M6779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assign the ouput to the field &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;!BOOM_LEN!, but use the field !LENGTH_FT! as parameter in the expression:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;in the expression:&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;boom_length(!LENGTH_FT!)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jan 2016 17:50:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86264#M6779</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-01-18T17:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate percentage then round</title>
      <link>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86265#M6780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the help! I was thinking too much about it...simple solution. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jan 2016 18:55:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-percentage-then-round/m-p/86265#M6780</guid>
      <dc:creator>JudsonCrouch1</dc:creator>
      <dc:date>2016-01-18T18:55:38Z</dc:date>
    </item>
  </channel>
</rss>

