apportionment/examples/simple.py

22 wiersze
438 B
Python

2020-01-31 14:16:37 +00:00
import apportionment.methods as app
2019-09-01 15:00:23 +00:00
2020-02-03 19:22:25 +00:00
votes = [1, 3, 6, 7, 78]
seats = 20
2019-06-14 14:05:02 +00:00
print("votes", "." * (25 - len("votes")), votes, "\n")
2019-06-14 14:05:02 +00:00
2019-09-01 15:00:23 +00:00
print(seats, "seats", "\n")
2019-06-14 14:05:02 +00:00
2019-09-01 15:00:23 +00:00
print("apportionment results:")
for method in [
"quota",
"largest_remainder",
"dhondt",
"saintelague",
"huntington",
"adams",
"dean",
]:
2020-01-31 14:16:37 +00:00
result = app.compute(method, votes, seats, verbose=False)
print(method, "." * (25 - len(method)), result)