 # Math - Percentages

In this lecture we looked at how to find a percentage of a number.
We also looked at how to apply the percentage increase and decrease so that we could compare the relative change between two values.

For our challenge, we were tracking a players rating across the first 3 games of a tournament. And we wanted to find out the percentage increase/decrease between each round.

Dataset:
1: 1200
2: 1350
3: 1305

The player increases their rating by 12.5% after the first game.

They lost their second game and their rating decreased by 3.3…%.

From the first to third game, they increased their rating by a total of 8.75%

1. +12.5%
2. -3.33…%
3. +8.75% over all

1200
1350 + 11.11%
1305 - 3.33%
from 1200 to 1305+ 8.75%

You’ve made a slight error on the first one but the others look good (although you wrote 1350 for the last one instead of 1305).
Remember to divide by the old value rather than the new value.

1 Like

Thank you!

I have just written a Python 2 function, just for fun

``````def diff_in_percentage(list):
old_value = list
print(list)
for i in range(1, len(list)):
new_value = list[i]
diff_in_perc = ((new_value - old_value) / old_value) * 100
old_value = new_value
if diff_in_perc >= 0:
print("change from " + str(old_value) + " to " + str(new_value) + " in percentage: +" + "{:.2f}".format(diff_in_perc))
else:
print("change from " + str(old_value) + " to " + str(new_value) + " in percentage: " + "{:.2f}".format(diff_in_perc))
total_change = ((new_value - list) / list) * 100
print("total change from " + str(list) + " to " + str(new_value) + " in percentage: " + "{:.2f}".format(diff_in_perc))

diff_in_percentage([1200, 1350, 1305])
``````
1 Like

12.5 up
3.33 down
8.75 up

1 Like