 <p>Try the following:</p> <pre><code>return int(float(value) / float(total) * 100.0) </code></pre> <p>to ensure that both value and total are float. This way strings could be passed in and still get a proper answer.</p>