Python - Rounding floating integers defined as variables and displaying them <p>I am trying to get this to calculate a number based on user input. While displaying it I want it to round to 2 digits. It refuses too! So confused. Any advice?</p> <pre><code>def calc(user_id): numbers = {'A': 4, 'B': 3, 'C': 2, 'D': 1, 'F': 0} user = User.objects.get(pk=user_id) user_profile = UserProfile.objects.get(user=user) outs = Out.objects.filter(user=user) counter = 0 total_number = 0 for out in outs: if out.data['type'] != 'panel': continue else: print out.data total_number += numbers[out.data['level']] counter += 1 x = round(float(total_number/float(counter)), 2) user_profile.average = x user_profile.save() </code></pre>