I gave my class a second test on variables. It involved some simple maths ie addition and subtraction with one simple division 36/3 = 12. Only 30% of the class got the correct answer. Quite a lot of the working indicated an understanding of what the program was doing, however, subtraction such as 16-23 resulted in several incorrect answers ie +7, 8 and 6 indicating quite a low level of numeracy skills. The test is provided below, students were given the example above.
Next time I will change the test to be 23-16.
Variables test: The sequel
Recall that Python evaluates the right hand side first when completing an assignment statement ie Python evaluates everything on the right before it assigns the result to the left hand side variable.
By hand, work through the following sequence of statements 1-17 in order. The program calculates total and average goal differences. Write down what is printed at the end of the program execution (ie when it is “run”).
Take a piece of paper and draw a box for each variable you encounter. When the variable is assigned a value, enter it in the box. If it is replaced by a subsequent assignment, cross out and replace with the assigned value.
1. goaldif = 0
2. goaldiftotal = 0
3. scoregf = 32
4. scorega = 24
5. goaldif = scoregf – scorega
6. goaldiftotal = goaldiftotal + goaldif
7. scoregf = 45
8. scorega = 10
9. goaldif = scoregf – scorega
10. goaldiftotal = goaldiftotal + goaldif
11. scoregf = 16
12. scorega = 23
13. goaldif = scoregf – scorega
14. goaldiftotal = goaldiftotal + goaldif
15. goaldifave = goaldiftotal/3
16. print(“The goal difference is:”, goaldiftotal)
17. print(“The goal difference average is:”, goaldifave)
Hand in your working notes and answers.