Thursday, 8 March 2018

Vote-counting Programs

The Election task has been completed, and four students opted to try the programming question. To recap, these were the instructions:

5. Write a program in Scratch to calculate the outcome of an election from the preferences of voters, by the plurality method. Then try to use the Borda count method (see below). Run your program many times, comparing the fairness of the results by the two systems. Extension: try to add the elimination method into your program.

I provided a starter program which casts random votes and puts them into a list.

https://scratch.mit.edu/projects/197219936/

The students had to write a script to parse the list and add up the votes. This involves creating and incrementing variables, followed by some if-else logic, and was achieved by all. Applying the Borda count method is quite a bit more difficult, and students asked me for help. I had to teach a double-loop algorithm, whereby elements of a list are looped over while the list itself is looped through. Following this, Borda count was successfully achieved.

One student who was absent came back with a working program written with Dad, which was nice to see! Another student hadn't realised there was a starter program, and wrote everything from scratch, and very well, too! The programs are below:

Reflection

This task was quite challenging, but was well-received by students, and I was impressed by their interest and perseverance. While writing a model answer, I noticed that the elimination method is much harder to implement, and I will drop this from a future version.

It occurred to me that this would also be a good spreadsheet task, and next time I might offer that as an alternative among the optional questions. It is of concern to me that students coming up to IB diploma Chemistry don't have much experience of using spreadsheets since we switched to MYP Design, with most of it taught by English and Art teachers.