Communities Program 07222024
Communities Program 07222024
StatsPopulation = []
StatsLiveBirths = []
StatsDeaths = []
StatsInfant = []
StatsMaternal = []
StatsFetal = []
StatsFemale = []
def mainMenuDisplay():
print()
print(" WELCOME TO VITAL STATISTICS INFORMATION SYSTEM ")
print("---------------------------------------------------------")
print("PRESS FROM THE FOLLOWING OPTION:")
print("Press 1. TO DISPLAY THE DEFINITION OF HEALTH INDICES.")
print("Press 2. TO ADD HEALTH INDICES INFORMATION.")
print("Press 3. TO DELETE HEALTH INDICES INFORMATION.")
print("Press 4. TO UPDATE HEALTH INDICES INFORMATION.")
print("Press 5. TO DISPLAY HEALTH INDICES INFORMATION.")
print("Press 6. TO DISPLAY VITAL HEALTH INDICATORS.")
print("Press 7. TO EXIT SYSTEM.")
def mainMenu(choiceMenu):
mainMenuDisplay()
while True:
try:
choiceMenu = int(input("Enter your option (1-7): "))
if 0 <= choiceMenu <= 7:
mainMenuEngine(choiceMenu)
else:
print("ERROR: Invalid input. Please enter a value between 1 and 7.")
except ValueError:
print("ERROR: Invalid input. Please enter a number.")
def get_valid_number(prompt):
while True:
try:
return int(input(prompt))
except ValueError:
print("Invalid input. Please enter a valid number.")
Communities.append(communityInput)
StatsPopulation.append(populationInput)
StatsLiveBirths.append(livebirthsInput)
StatsDeaths.append(deathsInput)
StatsInfant.append(infantdeathsInput)
StatsMaternal.append(maternaldeathsInput)
StatsFetal.append(fetaldeathInput)
StatsFemale.append(femalepopInput)
while True:
while True:
more = input("\nDo you want to add more communities? (yes/no):
").strip().lower()
if more in ("yes", "no"):
break
else:
print("Please only answer yes/no")
if more == 'yes':
healthIndices_add()
else:
break
break
x=1
print("--------------------------------------------------------")
for Comm in Communities:
print(x, '.', Comm)
x+=1
print(x,'. Remove All.')
print(x+1, '. Cancel')
#remove_info = int(input('Enter a number to delete: '))
while True:
try:
remove_info = get_valid_number("Enter a number to delete: ")
if 0 < remove_info < len(Communities)+2:
if remove_info == x:
clearALL()
return
if remove_info == x + 1:
return
remove = Communities[remove_info -1]
Communities.pop(remove_info-1)
StatsPopulation.pop(remove_info - 1)
StatsLiveBirths.pop(remove_info - 1)
StatsDeaths.pop(remove_info - 1)
StatsInfant.pop(remove_info - 1)
StatsMaternal.pop(remove_info - 1)
StatsFetal.pop(remove_info - 1)
StatsFemale.pop(remove_info - 1)
print(remove, 'has been deleted from the directory.')
return
else:
print('ERROR: Invalid input. Please enter a value between 1 and ',
len(Communities)+2)
except ValueError:
print('ERROR: Invalid input. Please enter a number.')
def clearALL():
Communities.clear()
StatsPopulation.clear()
StatsLiveBirths.clear()
StatsDeaths.clear()
StatsInfant.clear()
StatsMaternal.clear()
StatsFetal.clear()
StatsFemale.clear()
print('\nHealth Indices Information have been deleted in the directory.')
def update_HealthIndices(update_healthindices):
print("--------------------------------------------------------")
update_healthindices2 = get_valid_number('PICK INFORMATION TO UPDATE: \n 1.
Total Population \n 2. Total Live Births \n 3. Total Deaths \n 4. Infant Deaths \n
5. Maternal Deaths \n 6. Fetal Deaths \n 7. Female Population \n 8. Cancel:\n ')
if update_healthindices2 == 1:
newPopulation = get_valid_number("Enter new Total Population: ")
StatsPopulation[update_healthindices - 1] = newPopulation
print("Total Population of ", Communities[update_healthindices-1], "is
updated.")
return
elif update_healthindices2 == 2:
newLiveBirths = get_valid_number ("Enter new Total Live Births: ")
StatsLiveBirths [update_healthindices - 1] = newLiveBirths
print("Total Live Births of ", Communities[update_healthindices-1], "is
updated.")
return
elif update_healthindices2 == 3:
newDeaths = get_valid_number("Enter new Total Death: ")
StatsDeaths [update_healthindices - 1] = newDeaths
print("Total Death of ", Communities[update_healthindices-1], "is
updated.")
return
elif update_healthindices2 == 4:
newInfant = get_valid_number("Enter new Infant Deaths: ")
StatsInfant [update_healthindices - 1] = newInfant
print("Infant Deaths of ", Communities[update_healthindices-1], "is
updated.")
return
elif update_healthindices2 == 5:
newMaternal = get_valid_number("Enter new Maternal Deaths: ")
StatsMaternal [update_healthindices - 1] = newMaternal
print("Maternal Deaths of ", Communities[update_healthindices-1], "is
updated.")
return
elif update_healthindices2 == 6:
newFetal = get_valid_number("Enter new Fetal Death: ")
StatsFetal [update_healthindices - 1] = newFetal
print("Fetal Death of ", Communities[update_healthindices-1], "is
updated.")
return
elif update_healthindices2 == 7:
newFemale = get_valid_number("Enter new Female Population (15 - 49 years
old): ")
StatsFemale [update_healthindices - 1] = newFemale
print("Female Population (15 - 49 years old) of ",
Communities[update_healthindices-1], "is updated.")
return
elif update_healthindices2 == 8:
return
# Print headers
print("Health Indices".ljust(max_key_len), end="")
for community in communities:
print(community.ljust(max_val_len), end="")
print()
# Print headers
print("Health Indices".ljust(max_key_len), end="")
for community in communities:
print(community.ljust(max_val_len), end="")
print()
#option 7, exit
def exitProgram():
print("--------------------------------------------------------")
print("YOU HAVE SUCCESSFULLY EXITED THE SYSTEM.")
exit()
def mainMenuEngine(choice):
if choice == 1:
display_definitions()
mainMenu(0)
elif choice == 2:
healthIndices_add()
mainMenu(0)
elif choice == 3:
healthindices_delete()
mainMenu(0)
elif choice == 4:
health_indices_Update()
mainMenu(0)
elif choice == 5:
HIinfo_list()
mainMenu(0)
elif choice == 6:
calculate_vital_health_indicators()
mainMenu(0)
elif choice == 7:
exitProgram()
else:
return
mainMenu(0)