Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- registeredUsers=[[{"name":"Jose","age":18,"email":"josebermudez.com","ID":1234,"password":"1234"}],[{"name":"Fidel","age":18,"email":"fidel.com","ID":12345,"password":"1234"}]]
- country = []
- politicalParties =[]
- PresidentialBallot=[]
- provintialVotes=[]
- cantonVotes=[]
- totalVotes=[]
- #Main menu method
- def menu():
- print("Welcome \nWhat do you want to do? ")
- print("1)Sing in \n2)Log in\n3)exit")
- option=int(input("Select an option"))
- if option == 1:
- print("**************")
- menuForAdminOrInvited()
- elif option == 2:
- print("**************")
- logIn()
- else:
- print("Good bye")
- exit()
- #method to register as admin
- def singInUserAdmin():
- newUser = {}
- name=input("Your name.")
- newUser["name"]=name
- age=int(input("Your age."))
- newUser["age"]=age
- email=input("Your email.")
- newUser["email"]=email
- ID=int(input("Your ID."))
- newUser["ID"]=ID
- password =input("Your password.")
- newUser["password"]=password
- # método para verificar si el usuario ya está registrado
- def verfyUserAdmin():
- for user in registeredUsers[0]:
- if user["ID"] != ID:
- registeredUsers[0].append(newUser)
- print(registeredUsers)
- menu()
- else:
- print("**************")
- print("You're already signed in.\nEnter your ID and password")
- logIn()
- verfyUserAdmin()
- #Method to register as a guest
- def singInUserGuest():
- newUser = {}
- name=input("Your name.")
- newUser["name"]=name
- age=int(input("Your age."))
- newUser["age"]=age
- email=input("Your email.")
- newUser["email"]=email
- ID=int(input("Your ID."))
- newUser["ID"]=ID
- password =input("Your password.")
- newUser["password"]=password
- verfyUserGuest()
- # método para verificar si el usuario ya está registrado
- def verfyUserGuest():
- for user in registeredUsers[1]:
- if user["ID"]!=ID:
- registeredUsers[1].append(newUser)
- menu()
- else:
- print("**************")
- print("You're already signed in.\nEnter your ID and password")
- logIn()
- verfyUserGuest()
- #method to choose to be admin or guest
- def menuForAdminOrInvited():
- print("What kind of user do you want to be")
- print("1)Admin \n2)Guest")
- option = int(input("Select an option"))
- if option == 1:
- singInUserAdmin()
- elif option == 2:
- singInUserGuest()
- #Method to login
- def logIn():
- ID = int(input("Type your ID."))
- password = input("Type your password.")
- i = 0
- while i < len(registeredUsers):
- for user in registeredUsers[i]:
- if user["ID"] == ID:
- for user in registeredUsers[i]:
- if user["password"] == password:
- if i == 0:
- adminMenu()
- elif i == 1:
- guestMenu()
- print("Your password is incorrect. Try again.")
- logIn()
- else:
- i += 1
- print("You ID is incorrect. Try again.")
- menu()
- #method of admins menu
- def adminMenu():
- #tratar de compilar con ID
- print("Welcome:")
- print("What do you want to do?\n"
- "1)Territorial distribution.\n"
- "2)Administration of political parties.\n"
- "3)Administration of ballots.\n"
- "4)Results.\n"
- "5)Queries\n"
- "6)Exit")
- option = input("What is your option?: ")
- if option == "1":
- ditribuctionMenu()
- elif option == "2":
- politicalMenu()
- elif option == "3":
- menuBallots()
- elif option == "4":
- menuVotes()
- elif option == "5":
- menuQueriesAdmin()
- elif option == "6":
- print("Good bye.")
- print("**************")
- menu()
- else:
- print("Type a valid option")
- print("**************")
- adminMenu()
- #guest menu method
- def guestMenu ():
- print("Welcome:")
- print("What do you want to do?\n"
- "1)Queries.\n"
- "2)Exit")
- option = input("What is your option?")
- if option == "1":
- menuQueriesGuest()
- elif option == "2":
- print("Good bye.")
- print("**************")
- menu()
- else:
- print("Type a valid option")
- print("**************")
- guestMenu()
- #Territorial distribution menu
- def ditribuctionMenu():
- print("What do you want to do?")
- print("1)Add provinces, cantons or districts.\n"
- "2)Modify provinces, cantons or districts.\n"
- "3)Remove provinces, cantons or districts.\n"
- "4)Exit")
- option = input("Enter your option: ")
- if option =="1":
- creationPCDMenu()
- elif option =="2":
- modifyMenu()
- elif option == "3":
- menuDelete()
- elif option =="4":
- print("**************")
- adminMenu()
- else:
- print("Type a valid option")
- print("**************")
- #Creation method of Province Canton District
- def creationPCDMenu():
- print("What do you want to create?")
- print("1)Province.\n"
- "2)Canton.\n"
- "3)District.\n"
- "4)Exit")
- option = input("Enter your option:")
- if option == "1":
- print("**************")
- createProvince()
- elif option == "2":
- print("**************")
- createCanton()
- elif option == "3":
- print("**************")
- createDistrict()
- elif option == "4":
- print("**************")
- ditribuctionMenu()
- else:
- print("Type a valid option")
- print("**************")
- creationPCDMenu()
- #Territorial distribution methods
- def createProvince():
- newProvince={}
- nameProvince=input("Enter the name of the province: ")
- newProvince["Province"]=nameProvince
- newProvince["Ballots"]=[]
- numberOfDeputies= int(input("Type the number of deputies: "))
- newProvince["Deputies"]=numberOfDeputies
- newProvince["Cantons"] = []
- country.append(newProvince)
- print("The province was created successfully.")
- print("**************")
- ditribuctionMenu()
- #Method to create canton
- def createCanton():
- nameProvince = input("To which province you want to add cantons?")
- for province in country:
- if nameProvince == province["Province"]:
- newCanton={}
- nameCanton=input("Enter the name of the canton")
- newCanton["Name"]=nameCanton
- newCanton["Districts"]= []
- province["Cantons"].append(newCanton)
- print("The canton was created successfully.")
- print("**************")
- print(country)
- ditribuctionMenu()
- print("The province does not exist or its name is misspelled.")
- createCanton()
- #method to create district
- def createDistrict():
- nameProvince = input("To which province you want to add districts?: ")
- for province in country:
- if nameProvince == province["Province"]:
- nameCanton = input("To which canton you want to add districts?: ")
- for canton in province["Cantons"]:
- if nameCanton ==canton["Name"]:
- newDictrict = {}
- newDictrict["VotesPB"]=[]
- newDictrict["VotesLB"] = []
- nameDistrict = input("Enter the name of the district: ")
- newDictrict["Name"] = nameDistrict
- canton["Districts"].append(newDictrict)
- print("The district was created successfully.")
- print("**************")
- print(country)
- ditribuctionMenu()
- print("The canton does not exist or its name is misspelled")
- createDistrict()
- print("The province does not exist or its name is misspelled.")
- createDistrict()
- #Method to modify Cantonese and District Parties
- def modifyMenu():
- print("What do you want do?\n1)Modify Province.\n2)Modify Canton.\n3)Modify District.\n4)Exit.")
- option=input("Enter your option: ")
- if option == "1":
- print("**************")
- modifyProvince()
- elif option == "2":
- print("**************")
- modifyCanton()
- elif option == "3":
- print("**************")
- modifyDistritcs()
- elif option == "4":
- print("**************")
- ditribuctionMenu()
- else:
- print("Type a valid option")
- print("**************")
- modifyMenu()
- #method to modify provinces
- def modifyProvince():
- print("What do you want to modify?\n1)Name.\n2)Number of deputies.\n3)Exit.")
- option = input("Enter your option: ")
- if option == "1":
- province = input("Enter the name of the province you want to modify: ")
- i=0
- while i < len(country):
- if province == country[i]["Province"]:
- newName = input("Enter the new name of the province: ")
- country[i]["Province"] = newName
- print("The name of the province was successfully changed.")
- print("**************")
- modifyMenu()
- i+=1
- print("**************")
- print("The name of the province is incorrect or not exist.Try again.")
- modifyProvince()
- elif option == "2":
- province = input("Enter the name of the province you want to modify: ")
- i=0
- while i < len(country):
- if province == country[i]["Province"]:
- numberDeputies = int(input("Enter the new number of deputies."))
- country[i]["Deputies"] = numberDeputies
- print("The number of deputies was successfully changed.")
- print("**************")
- modifyMenu()
- i+=1
- print("**************")
- print("The name of the canton is incorrect or not exist.Try again.")
- modifyProvince()
- elif option == "3":
- print("Good bye.")
- print("**************")
- modifyMenu()
- else:
- print("Type a valid option")
- print("**************")
- modifyProvince()
- #method to modify cantons
- def modifyCanton():
- province=input("To which province does the canton you wish to modify belong?: ")
- i = 0
- while i < len(country):
- if province == country[i]["Province"]:
- canton = input("Enter the name of the canton: ")
- j=0
- while j < len(country[i]["Cantons"]):
- if canton == country[i]["Cantons"][j]["Name"]:
- nameCanton = input("Enter the new name of the canton: ")
- country[i]["Cantons"][j]["Name"] = nameCanton
- print(country)
- print("The name of the canton was successfully changed.")
- print("**************")
- modifyMenu()
- j+=1
- print("**************")
- print("The name of the canton is incorrect or not exist.Try again.")
- modifyMenu()
- i += 1
- print("**************")
- print("The name of the province is incorrect or not exist.Try again.")
- modifyMenu()
- #method to modify district
- def modifyDistritcs():
- nameProvince = input("To which province does the district you wish to modify belong?: ")
- for province in country:
- if province["Province"] == nameProvince:
- nameCanton = input("To which canton does the district you wish to modify belong?: ")
- for canton in province["Cantons"]:
- if nameCanton == canton["Name"]:
- nameDistrict = input(" Type the name of the district you want to modify: ")
- for district in canton["Districts"]:
- if nameDistrict == district["Name"]:
- newName= input("Enter the new name of the district: ")
- district["Name"] = newName
- print(country)
- print("The name of the district was successfully changed.")
- print("**************")
- modifyMenu()
- print("**************")
- print("The name of the district is incorrect or not exist.Try again.")
- modifyMenu()
- print("**************")
- print("The name of the canton is incorrect or not exist.Try again.")
- modifyMenu()
- print("**************")
- print("The name of the province is incorrect or not exist.Try again.")
- modifyMenu()
- #Delete Menu
- def menuDelete():
- print(" What do you want to delete?\n1)Province\n2)Canton\n3)District\n4)exit ")
- option=input("Enter your opcion: ")
- if option == "1":
- deleteProvince()
- elif option =="2":
- deleteCanton()
- elif option=="3":
- deleteDistricts()
- elif option =="4":
- ditribuctionMenu()
- else:
- print("Your option is in valid\nTry again")
- menuDelete()
- #Method that eliminates the provinces
- def deleteProvince():
- nameProvince=input("Enter the name of the province you want to delete: ")
- i=0
- while i < len(country):
- if nameProvince== country[i]["Province"]:
- country.remove(country[i])
- print("**************")
- print("His province was successfully eliminated")
- i+=1
- print("Your province does not exist")
- menuDelete()
- #Method to eliminate the cantons
- def deleteCanton():
- nameProvince = input("Enter the name of the province where the canton you want to delete is located: ")
- for province in country:
- if province["Province"] == nameProvince:
- nameCanton = input("Enter the name of the canton you want to delete: ")
- for canton in province["Cantons"]:
- if canton["Name"] == nameCanton:
- province["Cantons"].remove(canton)
- print("**************")
- print("The name of the canton is incorrect or not exist.Try again.")
- menuDelete()
- print("**************")
- print("The name of the province is incorrect or not exist.Try again.")
- menuDelete()
- #method to eliminate districts
- def deleteDistricts():
- nameProvince = input("Enter the name of the province where the canton you want to delete is located: ")
- for province in country:
- if province["Province"] == nameProvince:
- nameCanton = input("Enter the name of the canton where the canton you want to delete is located: ")
- for canton in province["Cantons"]:
- if canton["Name"] == nameCanton:
- nameDistrict = input("Enter the name of the district you want to delete: ")
- for district in canton["Districts"]:
- if nameDistrict == district["Name"]:
- canton["Districts"].remove(district)
- print(country)
- print("**************")
- print("The name of the district is incorrect or not exist.Try again.")
- menuDelete()
- print("**************")
- print("The name of the canton is incorrect or not exist.Try again.")
- menuDelete()
- print("**************")
- print("The name of the province is incorrect or not exist.Try again.")
- menuDelete()
- #method of menu of political parties
- def politicalMenu ():
- print("**************")
- print("What do you want to do?\n1)Create a Political Party.\n2)Modify a Political Paty.\n3)Delete a Political Party.\n4)Exit")
- option = input("Enter your option: ")
- if option =="1":
- createPoliticalParty()
- elif option == "2":
- menuModifyPP()
- elif option == "3":
- deletePP()
- elif option == "4":
- print("**************")
- adminMenu()
- else:
- print("Type a valid option")
- print("**************")
- politicalMenu()
- #method to create political parties
- def createPoliticalParty():
- politicalP={}
- namePoliticalP=input("Write the name of the political party you want to create: ")
- for name in politicalParties:
- if namePoliticalP == name["Name"]:
- print("There is already a political party with that name")
- createPoliticalParty()
- politicalP["Name"]=namePoliticalP
- yearF=input("Enter the year of creating the political party: ")
- politicalP["Foundation"]=yearF
- colors=input("Enter the all colors of the political party: ")
- politicalP["Colors"]=colors
- ideology=input("What is the ideology of the political party?: ")
- politicalP["Idelogy"]=ideology
- politicalParties.append(politicalP)
- print(politicalParties)
- print("Your political party was created successfully")
- print("**************")
- print("Want to create another Political Party\n1)Yes\n2)No")
- option=input("Enter your option")
- if option=="1":
- print("**************")
- createPoliticalParty()
- elif option=="2":
- politicalMenu()
- else:
- print("Invalid option will be sent to the previous menu")
- politicalMenu()
- #Method that modifies political partiess
- def menuModifyPP():
- if len(politicalParties) > 0:
- print("**************")
- print(" What do you want to do: ")
- print("1) Modify name of political Party\n2) Modify the year of foundation\n3) Modify the colors of the political party\n4) Modify the ideology of the political party\n5) Exit")
- option=input("Enter you option: ")
- if option=="1":
- modifyNamePoliticalParty()
- elif option=="2":
- modifyFPoliticalParty()
- elif option=="3":
- modifyColorsPoliticalParty()
- elif option=="4":
- modifyIdeologyPoliticalParty()
- elif option=="5":
- print("**************")
- politicalMenu()
- else:
- print("Type a valid option")
- print("**************")
- menuModifyPP()
- print("**************")
- print("The list is empty. You must add political parties.")
- politicalMenu()
- #Method that changes the name of the political party
- def modifyNamePoliticalParty():
- namePP=input("Enter the name of the political party you want to modify: ")
- i=0
- while i < len(politicalParties):
- if namePP==politicalParties[i]["Name"]:
- newNamePP=input("Enter the new name of the political party: ")
- politicalParties[i]["Name"]=newNamePP
- print("The name was successfully changed")
- print("**************")
- print("You want to change the name of another political party\n1)Yes\n2)No")
- option=input("Enter your option")
- if option=="1":
- modifyNamePoliticalParty()
- elif option =="2":
- print("**************")
- menuModifyPP()
- i+=1
- print("**************")
- print("The political party that you introduced does not exist or is badly written, try again")
- modifyNamePoliticalParty()
- #method that changes the foundation of the political party
- def modifyFPoliticalParty():
- namePP=input("Enter the name of the political party that wants to change the foundation: ")
- i=0
- while i < len(politicalParties):
- if namePP==politicalParties[i]["Name"]:
- newNameFPP=input("Enter the new year of foudation: ")
- politicalParties[i]["Foundation"]=newNameFPP
- print("Foudation was successfully changed")
- print("**************")
- print("Want to change the foundation of another political party\n1)Yes\n2)No")
- option=input("Enter your option")
- if option=="1":
- modifyFPoliticalParty()
- elif option =="2":
- print("**************")
- menuModifyPP()
- i+=1
- print("**************")
- print("The political party that you introduced does not exist or is badly written, try again")
- modifyFPoliticalParty()
- #Method that changes the colors of the political party
- def modifyColorsPoliticalParty():
- namePP=input("Enter the name of the political party that wants to change the colors: ")
- i=0
- while i < len(politicalParties):
- if namePP==politicalParties[i]["Name"]:
- newNameColorsPP=input("Enter the new colors of political party: ")
- politicalParties[i]["Colors"]=newNameColorsPP
- print("The colors was successfully changed")
- print("**************")
- print("Want to change the colors of another political party\n1)Yes\n2)No")
- option=input("Enter your option")
- if option=="1":
- modifyColorsPoliticalParty()
- elif option =="2":
- print("**************")
- menuModifyPP()
- i+=1
- print("**************")
- print("The political party that you introduced does not exist or is badly written, try again")
- modifyColorsPoliticalParty()
- #method that changes the ideology of the political party
- def modifyIdeologyPoliticalParty():
- if len(politicalParties) > 0:
- namePP=input("Enter the political party that wishes to change the ideology: ")
- i=0
- while i < len(politicalParties):
- if namePP==politicalParties[i]["Name"]:
- newNameIdeologyPP=input("Enter the new ideology of political party: ")
- politicalParties[i]["Ideology"]=newNameIdeologyPP
- print("The ideology was successfully changed")
- print("**************")
- print("Want to change the ideology of another political party?\n1)Yes\n2)No")
- option=input("Enter your option")
- if option=="1":
- modifyIdeologyPoliticalParty()
- elif option =="2":
- print("**************")
- menuModifyPP()
- i+=1
- print("**************")
- print("The political party that you introduced does not exist or is badly written, try again")
- modifyIdeologyPoliticalParty()
- print("**************")
- print("The list is empty. You must add political parties.")
- politicalMenu()
- #method to eliminate political parties
- def deletePP():
- if len(politicalParties) > 0:
- namePP = input("Enter the name of the political party you want to delete: ")
- i = 0
- while i < len(politicalParties):
- if namePP == politicalParties[i]["Name"]:
- politicalParties.remove(politicalParties[i])
- print("The political party was successfully eliminated.")
- print("**************")
- print("Do you want to eliminate another political party?\n1)Yes\n2)No")
- option = input("Enter your option")
- if option == "1":
- deletePP()
- elif option == "2":
- print("**************")
- menuModifyPP()
- i += 1
- print("The name of the political party is badly written or does not exist. Try again.")
- print("**************")
- deletePP()
- print("**************")
- print("The list is empty. You must add political parties.")
- politicalMenu()
- #Ballot menu
- def menuBallots():
- print("**************")
- print("What would you like to do")
- print("1)Create ballot\n2)Modify ballot\n3)Delete a ballot\n4)exit")
- option=input("Enter your option")
- if option=="1":
- menuCreateBallots()
- elif option=="2":
- menuModifyBallots()
- elif option=="3":
- menuDeleteBallots()
- elif option=="4":
- adminMenu()
- else:
- print("Your option is invalid\nTry again")
- menuBallots()
- #ballot creation menu
- def menuCreateBallots():
- print("**************")
- print("What would you like to do?")
- print("1)Create presidential ballot\n2)Create legislative ballot\n3)Exit")
- option=input("Enter your option")
- if option=="1":
- ballotPresidentialCreate()
- elif option=="2":
- requeritProvince()
- elif option=="3":
- menuBallots()
- else:
- print("Your option is invalid.\n Try again ")
- menuCreateBallots()
- #Method to print list of matches
- def PrintList():
- print("**************")
- print("List of political parties")
- i=0
- while i < len(politicalParties):
- print("Name:"+politicalParties[i]["Name"])
- i+=1
- #Method that creates the presidential ballot
- def ballotPresidentialCreate():
- PrintList()
- print("**************")
- name = input("Enter one by one the political parties that you want to add: ")
- for ballot in politicalParties:
- if name == ballot["Name"]:
- PresidentialBallot.append(ballot)
- print("Want to add another political party\n1)Yes\n2)No")
- option=input("Enter your Option: ")
- if option=="1":
- ballotPresidentialCreate()
- elif option=="2":
- menuCreateBallots()
- else:
- print("Option invalid\nYou will be sent to the previous menu")
- menuCreateBallots()
- else:
- print("The political party does not exist\nYou want to create it\n1)Yes\n2)No")
- option=input("Enter your option")
- if option=="1":
- createPoliticalParty()
- elif option=="2":
- menuCreateBallots()
- else:
- print("Your option is invalid\nIt will be sent to the previous menu")
- menuCreateBallots()
- #Method to request a province
- def requeritProvince():
- namePro = input("Enter the name of the province to which you want to add the ballot: ")
- ballotLegislativeCreate(namePro)
- #Method to create legislative paper
- def ballotLegislativeCreate(namePro):
- for province in country:
- if namePro in province["Province"]:
- if province["Ballots"]==[]:
- addNewPP(namePro)
- print("The ballot already exists, you can only modify it\nIt will be sent to the previous menu")
- menuCreateBallots()
- print("The name of the province is incorrect or not exist.Try again.")
- menuCreateBallots()
- # metodo para añadir ms de un partido a la papeleta legislativa
- def addNewPP(namePro):
- PrintList()
- for province in country:
- if namePro == province["Province"]:
- nameParty = input("Enter the name of the political party you want to add to the ballot: ")
- if province["Ballots"] == []:
- for party in politicalParties:
- if nameParty == party["Name"]:
- province["Ballots"].append(party)
- print(province)
- print("Political party successfully added\nWant to add another political party\n1)Yes\n2)No")
- option = input("Enter your option: ")
- if option == "1":
- addNewPP(namePro)
- elif option == "2":
- menuCreateBallots()
- else:
- print("Your option is invalid\nIt will be sent to the previous menu")
- menuCreateBallots()
- print("The name of political party is incorrect.")
- menuCreateBallots()
- else:
- for pp in province["Ballots"]:
- if nameParty == pp["Name"]:
- print("You can not add the political party because it already exists on the ballot.\nThe only thing you can do is modify the ballot.")
- print("Do you want to add another political party?\n1)Yes\n2)No")
- option = input("Enter your option: ")
- if option == "1":
- addNewPP(namePro)
- elif option =="2":
- menuCreateBallots()
- else:
- print("Your option is invalid\nIt will be sent to the previous menu")
- menuCreateBallots()
- for party in politicalParties:
- if nameParty == party["Name"]:
- province["Ballots"].append(party)
- print(province)
- print("Political party successfully added\nWant to add another political party\n1)Yes\n2)No")
- option = input("Enter your option: ")
- if option == "1":
- addNewPP(namePro)
- elif option == "2":
- menuCreateBallots()
- else:
- print("Your option is invalid\nIt will be sent to the previous menu")
- menuCreateBallots()
- print("The name of political party is incoerrect.")
- menuCreateBallots()
- #Method that modifies the ballot, first the ecnuentra in the ballot that is indicated, the ballot is positioned in a key and this in turn is in the province the part to modify will be to add a match to the pepleta created
- def menuModifyBallots():
- print(" What do you want to do ?")
- print("1)Modify presidential ballot\n2)Modify legislative ballot.\n3)Exit")
- option= input("Enter your option")
- if option=="1":
- modifyPresidentialBallot()
- elif option=="2":
- requeritModifyBallots()
- elif option =="3":
- menuBallots()
- else:
- print("Invalid option\nwill be sent to the previous menu")
- menuBallots()
- #This method sends the name of the province where the created ballot is located
- def requeritModifyBallots():
- namePro=input("Enter the name of the province where the created ballot is located: ")
- for province in country:
- if namePro == province["Province"]:
- print("What would you like to do\n1)Remove Political Party in ballot\n2)Modify political party in ballot.\n3)Exit")
- option=input("Enter your option")
- if option=="1":
- modifyBallotsLegislativeRemove(namePro)
- elif option=="2":
- modifyBallotlegislative(namePro)
- elif option =="3":
- menuModifyBallots()
- else:
- print("Option invalid\nWill be sent to the previous menu")
- menuModifyBallots()
- print("Province incorrect")
- menuModifyBallots()
- #This method removes the political party that was admitted, which is on the legislative ballot
- def modifyBallotsLegislativeRemove(namePro):
- for province in country:
- if namePro==province["Province"]:
- for ballots in province["Ballots"]:
- printLB(namePro)
- nameParty=input("Enter the political party you want to modify")
- if nameParty==ballots["Name"]:
- province["Ballots"].remove(ballots)
- print("The political party has been successfully removed")
- print("want to remove some other political party\n1)Yes\n2)No")
- option2=input("Enter Your Option")
- if option2=="1":
- modifyBallotsLegislativeRemove(namePro)
- elif option2=="2":
- menuModifyBallots()
- print("Province that is incorrect")
- menuModifyBallots()
- #This method changes a political party of the pepeleta by the political party typed by the user
- def modifyBallotlegislative(namePro):
- for province in country:
- if namePro==province["Province"]:
- for ballots in province["Ballots"]:
- printLB(namePro)
- nameParty=input("Enter the political party you want to modify: ")
- if nameParty==ballots["Name"]:
- PrintList()
- newParty=input("Enter the new political party you want to add")
- for party in politicalParties:
- if newParty==party["Name"]:
- province["Ballots"].append(party)
- print("The political party has been successfully added")
- print("want to add another political party\n1)Yes\n1)No")
- option =input("Enter your option: ")
- if option == "1":
- modifyBallotlegislative(namePro)
- elif option == "2":
- menuModifyBallots()
- else:
- print("The province does not exist, or is badly written.")
- menuModifyBallots()
- #MENU MODIFY THE PRESIDENTIAL PAPER
- def modifyPresidentialBallot():
- print("What would you like to do\n1)Add a new political party\n2)Eliminate a political party\n3)Exit")
- option=input("Enter your option: ")
- if option=="1":
- modifyPresidentialBallotADD()
- elif option=="2":
- removePartyPB()
- elif option=="3":
- menuModifyBallots()
- else:
- print("Invalid option\nwill be sent to the previous menu")
- modifyPresidentialBallot()
- #method that adds a political party to the presidential ballot
- def modifyPresidentialBallotADD():
- PrintList()
- nameParty=input("Enter the name of political party you want to add: ")
- for Party in politicalParties:
- if nameParty == Party["Name"]:
- if len(PresidentialBallot) == []:
- for Party4 in politicalParties:
- if nameParty == Party4["Name"]:
- PresidentialBallot.append(Party4)
- print("The name of political party is incoerrect or not exist.")
- modifyPresidentialBallotADD()
- else:
- for Party2 in PresidentialBallot:
- if nameParty==Party2["Name"]:
- print("The political party is already on the ballot")
- print("Do you want to add some other political party?\n1) Yes\n2)No")
- option=input("Enter your option: ")
- if option=="1":
- modifyPresidentialBallotADD()
- elif option=="2":
- modifyPresidentialBallot()
- else:
- print("Your option is invalid\nYou will be sent to the previous menu")
- modifyPresidentialBallot()
- for Party3 in politicalParties:
- if nameParty == Party3["Name"]:
- PresidentialBallot.append(Party3)
- print("The political party has been successfully added")
- print("Do you want to add some other political party?\n1)Yes\n2)No")
- option = input("Enter your option: ")
- if option == "1":
- modifyPresidentialBallotADD()
- elif option == "2":
- modifyPresidentialBallot()
- else:
- print("Your option is invalid\nYou will be sent to the previous menu")
- modifyPresidentialBallot()
- print("The name of political party is incoerrect or not exist.")
- modifyPresidentialBallotADD()
- print("The political party entered does not exist")
- modifyPresidentialBallot()
- #method to print the matches of the ballots
- def printLB(namePro):
- for province in country:
- if namePro == province["Province"]:
- for ballot in province["Ballots"]:
- print("Name: "+ballot["Name"])
- #method menu to choose which ballot to remove one or more political parties
- def menuRemovePartyBallot():
- print("What do you like to do?\n1)Remove Party in Predidencial Ballot.\n2)Remove Party in Legislative Ballot.\n3)Exit")
- option = input("Enter your option: ")
- if option == "1":
- removePartyPB()
- elif option == "2":
- removePartyLB()
- elif option == "3":
- menuBallots()
- else:
- print("Invalid option\nwill be sent to the previous menu")
- menuBallots()
- #method to remove a political party from the presidential ballot
- def removePartyPB():
- if len(PresidentialBallot) != 0:
- printListPB()
- nameParty = input("Enter the name of the political party you wish to eliminate from the ballot: ")
- for party in PresidentialBallot:
- if nameParty == party["Name"]:
- PresidentialBallot.remove(party)
- print("The political party was eliminated correctly.")
- print("Do you want to eliminate another political party?\n1)Yes\n2)No")
- option = input("Enter your option : ")
- if option == "1":
- removePartyPB()
- elif option == "2":
- menuRemovePartyBallot()
- else:
- print("Invalid option\nwill be sent to the previous menu")
- menuBallots()
- print("The political party entered does not exist")
- menuRemovePartyBallot()
- print("The ballot does not contain any political party.\nDo you want to add political parties to the ballot?\nYes\nNo")
- option2 = input("Enter your option: ")
- if option2 == "1":
- ballotPresidentialCreate()
- elif option2 == "2":
- menuRemovePartyBallot()
- else:
- print("Invalid option\nwill be sent to the previous menu")
- menuRemovePartyBallot()
- #method to print the list of the 'parties of the presidential ballot
- def printListPB():
- for party in PresidentialBallot:
- print("Name: "+party["Name"])
- #method to eliminate one or more political parties from the legislative ballot
- def removePartyLB():
- if len(country) != 0:
- namePro = input("Enter the name of the province where the political party you want to eliminate is located: ")
- for province in country:
- if namePro == province["Province"]:
- if len(province["Ballots"]) != 0:
- printLB(namePro)
- nameParty = input("Enter the name of the political party you want to eliminate: ")
- for party in province["Ballots"]:
- if nameParty == party["Name"]:
- province["Ballots"].remove(party)
- print("The political party was successfully eliminated.\nDo you want to eliminate another political party?\n1)Yes\n2)No")
- option = input("Enter your option: ")
- if option == "1":
- removePartyLB()
- elif option == "2":
- menuRemovePartyBallot()
- else:
- print("Invalid option\nwill be sent to the previous menu")
- menuRemovePartyBallot()
- print("The political party does not exist, or is badly written.")
- menuRemovePartyBallot()
- print("There are no political parties on the ballot.\nDo you want to add political parties to the ballot?\n1)Yes\n2)No")
- option2 = input("Enter your option: ")
- if option2 == "1":
- requeritProvince()
- elif option2 == "2":
- menuRemovePartyBallot()
- else:
- print("Invalid option\nwill be sent to the previous menu")
- menuRemovePartyBallot()
- print("The province does not exist, or is badly written.")
- menuRemovePartyBallot()
- print("There are no provinces.\nDo you want to create provinces?\n1)Yes\n2)No")
- option3 = input("Enter your option: ")
- if option3 == "1":
- createProvince()
- elif option3 == "2":
- menuRemovePartyBallot()
- else:
- print("Invalid option\nwill be sent to the previous menu")
- menuRemovePartyBallot()
- #elimination menu of ballots
- def menuDeleteBallots():
- print("What do you like to do?\n1)Delete Presidential Ballot.\n2)Delete Legislative Ballot.\n3)Exit")
- option = input("Enter your option: ")
- if option == "1":
- deletePresidentialBallot()
- elif option == "2":
- deleteLegislativeBallot()
- elif option == "3":
- menuBallots()
- else:
- print("Type a valid option.")
- menuDeleteBallots()
- #method to eliminate the presidential ballot
- def deletePresidentialBallot():
- if len(PresidentialBallot) == 0:
- print("There is no ballot to be deleted")
- menuDelete()
- i =0
- while i < len(PresidentialBallot):
- PresidentialBallot.remove(PresidentialBallot[i])
- print("The ballot has been eliminated")
- print(PresidentialBallot)
- menuDeleteBallots()
- #method to eliminate the legislative ballot
- def deleteLegislativeBallot():
- if len(country) != 0:
- namePro = input("Enter the name of the province where the ballot you want to delete is located: ")
- i = 0
- while i < len(country):
- if country[i]["Province"] == namePro:
- if len(country[i]["Ballots"]) != 0:
- j = 0
- while j < len(country[i]["Ballots"]):
- country[i]["Ballots"].remove(country[i]["Ballots"][j])
- print("The ballot has been eliminated")
- print(country)
- print("Do you want to eliminate another legislative ballot?\n1)Yes\n2)No")
- option = input("Enter your option: ")
- if option == "1":
- deleteLegislativeBallot()
- elif option == "2":
- menuBallots()
- else:
- print("Type a valid option.")
- menuDelete()
- print("There is no ballot to be deleted")
- menuDeleteBallots()
- i += 1
- print("The province does not exist, or is badly written.")
- menuDeleteBallots()
- print("There are no provinces.\nDo you want to create provinces?\n1)Yes\n2)No")
- option2 = input("Enter your option: ")
- if option2 == "1":
- createProvince()
- elif option2 == "2":
- menuDeleteBallots()
- else:
- print("Invalid option\nwill be sent to the previous menu")
- menuDeleteBallots()
- #results menu
- def menuVotes():
- print("What do you like to do?\n1)Enter Presidential results.\n2)Enter Legislative results\n3)Exit")
- option = input("Enter your option: ")
- if option == "1":
- presidentialVotes()
- elif option == "2":
- legislativeVotes()
- elif option == "3":
- adminMenu()
- else:
- print("Type a valid option")
- menuVotes()
- #Method to specify to which way to add the votes (presidential ballot)
- def presidentialVotes():
- for province in country:
- for canton in province["Cantons"]:
- for district in canton["Districts"]:
- print(district["Name"])
- PrintList()
- addVotesPresidential(district)
- print("The votes were added successfully.")
- menuVotes()
- #Method to add votes in the presidential ballot
- def addVotesPresidential(district):
- for party in PresidentialBallot:
- newResults={}
- newResults["Name"]=party["Name"]
- newResults["Votes"]= int(input("How many votes for "+party["Name"]+"?"))
- district["VotesPB"].append(newResults)
- #method to specify in which district to add the votes (legislative ballot)
- def legislativeVotes():
- for province in country:
- for canton in province["Cantons"]:
- for district in canton["Districts"]:
- print("District to which the votes will be added:")
- print(district["Name"])
- printLB(province)
- addVotesLegislative(district)
- print("The votes were added successfully.")
- menuVotes()
- # method to add votes on the legislative ballot
- def addVotesLegislative(district):
- for province in country:
- for party in province["Ballots"]:
- newResults = {}
- newResults["Name"] = party["Name"]
- newResults["Votes"] = int(input("How many votes for " + party["Name"] + "?"))
- district["VotesLB"].append(newResults)
- #query menu for administrators
- def menuQueriesAdmin():
- print("What do you like to do?\n1)National Results\n2)Provincial Results\n3)Canton Results\n4)Districts Results\n5)Know Assembly Conformation\n6)Exit")
- option = input("What is your option?: ")
- if option == "1":
- addPartiesVotes()
- elif option == "2":
- provintialResults()
- elif option == "3":
- print("Could not complete")
- menuQueriesAdmin()
- elif option == "4":
- resultsDistricts()
- elif option == "5":
- print("Could not complete")
- menuQueriesAdmin()
- elif option == "6":
- print("Good bye.")
- print("**************")
- adminMenu()
- else:
- print("Type a valid option")
- print("**************")
- menuQueriesAdmin()
- #Guest consultation menu
- def menuQueriesGuest():
- print(
- "What do you like to do?\n1)National Results\n2)Provincial Results\n3)Canton Results\n4)Districts Results\n5)Know Assembly Conformation\n6)Exit")
- option = input("What is your option?: ")
- if option == "1":
- addPartiesVotes()
- elif option == "2":
- provintialResults()
- elif option == "3":
- print("Could not complete")
- menuQueriesAdmin()
- elif option == "4":
- resultsDistricts()
- elif option == "5":
- print("Could not complete")
- menuQueriesAdmin()
- elif option == "6":
- print("Good bye.")
- print("**************")
- guestMenu()
- else:
- print("Type a valid option")
- print("**************")
- menuQueriesAdmin()
- # Method that adds the presidential parties to which later the votes would be added
- def addPartiesVotes():
- for province in country:
- vote={}
- vote["Province"]=province["Province"]
- vote["Parties"]=[]
- for party in PresidentialBallot:
- newParty={}
- newParty["Name"]=party["Name"]
- newParty["Votes"]=0
- vote["Parties"].append(newParty)
- provintialVotes.append(vote)
- for province in provintialVotes:
- addVotes(province)
- totalVotesNational()
- #method that adds the votes to the presidential political parties
- def addVotes(province2):
- for province in country:
- for canton in province["Cantons"]:
- for district in canton["Districts"]:
- for party in district["VotesPB"]:
- for nameParty in province2["Parties"]:
- if nameParty["Name"] == party["Name"]:
- nameParty["Votes"]+= party["Votes"]
- return (provintialVotes)
- #Method that adds the presidential parties to which the total of votes would be added later
- def totalVotesNational():
- vote={}
- vote["Parties"]=[]
- for party in PresidentialBallot:
- newParty={}
- newParty["Name"]=party["Name"]
- newParty["TotalVotes"]=0
- vote=newParty
- totalVotes.append(vote)
- getTotalPartyVotesProvintial()
- #method that adds the total votes to the political parties, based on the provinces
- def getTotalPartyVotesProvintial():
- for province in provintialVotes:
- for parties in province["Parties"]:
- for party in totalVotes:
- if party["Name"]==parties["Name"]:
- party["TotalVotes"]+=parties["Votes"]
- nationalResults()
- #method to know the national results
- def nationalResults():
- print("******************")
- total=0
- if len(totalVotes)!=0:
- for party in totalVotes:
- total+=party["TotalVotes"]
- for party in totalVotes:
- porcentTotal= 100*party["TotalVotes"]/total
- print(party["Name"],":",porcentTotal,"%"," ","Votes: ",party["TotalVotes"])
- else:
- print("No votes assigned to political parties")
- #method to know the results by province
- def provintialResults():
- provintialVotes = 0
- namePro = input("Enter the name of the province from which you want to know the results: ")
- for province in provintialVotes:
- if namePro == province["Province"]:
- for party in province["Parties"]:
- provintialVotes += party["Votes"]
- for province in provintialVotes:
- if namePro == province["Province"]:
- for party in province["Parties"]:
- percentProvince = party["Votes"]*100/provintialVotes
- print(party["Name"],":",percentProvince,"%"," ","Votes:",party["Votes"])
- #method to know the results by district
- def resultsDistricts():
- nameDistrict=input("Enter the name of the district: ")
- for province in country:
- for canton in province["Cantons"]:
- for district in canton["Districts"]:
- if nameDistrict==district["Name"]:
- assistantResultsDstricts(district)
- #auxiliary method of the "resultsDistricts" method
- def assistantResultsDstricts(district):
- totalVotes=0
- for party in district["VotesPB"]:
- totalVotes+= party["Votes"]
- for party in district["VotesPB"]:
- percentProvince = party["Votes"] * 100 / totalVotes
- print(party["Name"], ":", percentProvince, "%", " ", "Votes:", party["Votes"])
- menu()
Add Comment
Please, Sign In to add comment