title: Python: round(random.uniform) printing wrong float value on output console but in background its correct value
body: <p>See the following code</p>
  <pre><code>import re
  import random
  s = &quot;~|21|050000|voltage|current|ApparentPower|12345~&quot;
  for _ in range(100):
      vol_val = round(random.uniform(230, 260), 2)
      vol = '{:.2f}'.format(vol_val)
      replaced = re.sub('voltage', vol, s)
  
      def cur(match):
          return str(round(random.uniform(10,30), 2))
      replaced1 = re.sub('current', cur, replaced)
      #print(replaced1)
      spl_vol = replaced1.split(&quot;|&quot;)[3]
      spl_cur = replaced1.split(&quot;|&quot;)[4]
      print(spl_vol,spl_cur)
  
  
      mul = float(spl_vol)*float(spl_cur)
      dc = format(mul, &quot;.2f&quot;)
      mull = str(dc)
      #print(mull)
      txt = replaced1
      replacedapp = re.sub(&quot;ApparentPower&quot;, mull, txt)
      print(replacedapp)
  </code></pre>
  <p>In this code iam Generating two random values at each iteration, and using those random values, i am replacing the actual values at each iteration.</p>
  <p>At each Iteration i am Replacing Three Values
  <strong>voltage</strong> by <strong>first voltage random value</strong>
  current by <strong>first current random value</strong>
  and
  I am Replacing ApparentPower by multiplication result of voltage and current.</p>
  <p>Here my problem is, voltage and current values displaying wrong values as shown in below
  (when i printed those values separately, values are correct at background)</p>
  <p>~|21|050000|231.86|19.67|4560.69|12345~ ---------       printed properly</p>
  <p>236.36 <strong>26.5</strong>  ------------in background current value is correct</p>
  <p>~|21|050000|236.36|<strong>26263.54</strong>|6263.54|12345~  -------- but here current value displayed wrong</p>
  <p><strong>234.59</strong> 21.59------------ here voltage value at background correct</p>
  <p>~|21|050000|<strong>234.59</strong>|21.59|5064.80|12345~ -------------here also printed correct</p>
  <p><strong>236.58</strong> 24.14-------------------here voltage value at background correct</p>
  <p>~|21|050000|<strong>235711.048</strong>|24.14|5711.04|12345~ ------------------- but on console displayed wrong</p>
  <p>please anyone help me</p>
  <p>you can run my code you will get my problem</p>