Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. parties_dict = {}
  2. votes_sum = 0
  3. vacancies_amt = 450
  4. with open('input.txt', 'r', encoding='utf8') as f:
  5.     for line in f.readlines():
  6.         line.split()
  7.         line = line.split()
  8.         party_name = ' '.join(line[:-1])
  9.         party_votes = int(line[-1])
  10.         parties_dict[party_name] = party_votes
  11.         votes_sum += party_votes
  12. first_electoral_quotient = votes_sum / vacancies_amt
  13. for party in parties_dict:
  14.     vacancies = parties_dict[party] / first_electoral_quotient
  15.     parties_dict[party] = vacancies
  16.     vacancies_amt -= int(vacancies)
  17. if vacancies_amt > 0:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement