Answer:
Previous question is not given.
I'll assume that the test statistic is calculated as thus;
(Expected Proportion - Actual Proportion) * 100
The function goes as follows.
#function is written in Python Programming Language.
def test _statistic(expected, actual)
return 100 * abs(expected - actual)
The first line of the program defines the function test_statistic along with two parameters.
The parameters are expected and actual.
expected represents expected proportion whole actual represents actual proportion
The second line calculates the value of the test_statistic.
First the absolute value is calculated to remove all negative signs. Since the results is needed in percentage, it's then multiplied by 100.