Simulating Election Votes

Aleksandr Popov
alexpoov99 at


CS0 and CS1 courses are increasingly integral to various social science programs, such as sociology and political science. This assignment is part of the Basics of Programming in Python course for undergraduate political science students. It aims to prepare students for programming exam while train to apply computational thinking to political science problems. By linking these fields, students learn to overcome coding challenges and explore computational social science methods for both academic and career advancement.

This project seeks such a connection between subjects of political science major as Comparative Electoral Systems and Quantitative Methods of Political Research, and concepts of computer science. In this assignment, students:

As the result, this assignment promotes multiple ways of comprehension, a crucial aspect of universal design for learning. It enhances students' programming skills while facilitating connections between complex topics through analogies and metaphors. Moreover, the assessment framework allows flexibility in task descriptions and possibility of reflective work, promoting multiple ways of engagement and relevance in the learning process.


Summary Aggregating, calculating and comparing the results of simulated elections using different vote counting approaches.
Audience Most suitable for CS1-CS2 non-STEM majors courses.
  • Algorithms and data structures, simulations, data aggregation, conditional programming and control flows.
  • Automated electoral systems, voter behaviour modelling.
Difficulty The assignment is designed as a form of homework / midterm assessment (1-3 weeks); however, it can be shortened at will (see Variants section)
  • Bridging political science problems with coding to empower student's interdisciplinary understanding of both programming and computational social science methods.
  • The chain of world problems within one scenario provides better opportunity to build connections with prior knowledge, empowering comprehension.
  • Linking to major course materials creates authentic and relevant tasks that reinforces engagement.
  • The high adaptability of the task in the context of data generation and the conditions of voting systems to the specificities of the electoral systems of individual countries makes the task even more realistic and engaging.
  • Wrapping electoral systems into a code is a complicated task for students with no programming background.
    • Part of the logic should be assisted by instructor/course teacher. We have done this with the scaffolding; although, as one reviewer pointed out, it blurs other computer thinking skills like code formatting, method selection, etc. Other, non-self-regulated approaches need to be considered as well.
    • Complexity of this task also raises concerns about it implementation as mid-term evaluation. Structure of the assignment should be picked carefully.
  • The need to check the correctness of the code rather than the answers makes it difficult to write a universal autograder and requires a fair amount of man hours to check all the work.
  • Code within the assignment mostly embrase procedural approach to programming, which might be not the best way in terms of pure vote counting logic.
Dependencies Basic knowledge of Python: variables, data structures, control flows and a bit of functional programming.
  • The assignment exist in 3-module structure: ballot aggregation and spoiled ballots detection, voter counting approaches algorithmisation, and analysis+discussion. Although this structure gives a more coherent view of the different stages of problem-solving approach, the first and the third parts of the assignment could be dropped to save time (counting methods could be discussed during the pre-class).
  • The degree of an assistance within electoral systems algorithms can vary depending on the students background, the length of the course and the possibility of additional consultations during the assignment period.
  • Electoral systems encompass more than just counting methods, incorporating rules of voting and ballot structures. We integrated this complexity into our data generation process, enabling simulation of fictional elections based on real-world country rules. Alternatively, students can dive deeper by describing entire electoral systems, beginning with ballot structures. Note that this advanced variant of the assignment is suitable for CS1 courses and experienced students.



I would like to thank: