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.

Post your answers below and remember to use spoiler tags!

Here are the answers to the challenge for you to check your answers:

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 Like

Here is how I solved it:

  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[0]
    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[0]) / list[0]) * 100  
    print("total change from " + str(list[0]) + " 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

1st to 2nd game => +12.5%
2nd to 3rd game => -3.3%
1st to 3rd game => +8.75%

The player’s rating increases by 12.5% after their first game.
It then decreases by 3.33% after the second game.
In total, the player’s rating increased by 8.75%.

1st Game: 159/1200=1.25%
2nd Game: -45/1350= -3.3% (repeating) or -1/30
3rd Game: 105/1200=8.75%=(1+1.25%)*(1-3.3%)-1

100 * 150/1200 = 12.5%
100 * -45/1200 = -3.75%
100 * 105/1200 = 8.75%

Table3

After the first game:
(150/1200) * 100 = 12.5%
After the second game:
(-45/1350) * 100 = -3.33%
After both games:
(105/1200) * 100 = 8.75%

I did it through lua code.

local function CalculatePercentage(newnumber: number, oldNumber: number)
local Increase = (newnumber / oldNumber - 1) * 100
return Increase
end

print("Round 1: "…CalculatePercentage(1350, 1200))
print("Round 2 "…CalculatePercentage(1305, 1350 ))

print("Entire game: "… CalculatePercentage(1305, 1200))

Round 1: 12.5
Round 2 -3.33
Entire game: 8.75

Privacy & Terms