subject

Complete a Python program that uses a list to store data for the village of Marengo. The village of Marengo conducted a census and collected records that contain household data, including the number of occupants in each household. The exact number of household records has not yet been determined, but you know that Marengo has fewer than 300 households.
The program should allow the user to enter each household size and determine the mean and median household size in Marengo. The program should output the mean and median household size in Marengo. You need to write the code that sorts the household sizes in ascending order using a bubble sort and then prints the mean and median household size in Marengo.
Comments in the code tell you where to write your statements.

Instructions:
Make sure that the file HouseholdSize. py is selected and open.
Write the bubble sort.
Calculate the total of the household size.
Output the mean and median household size in Marengo.
Execute the program by clicking the "Run Code" button and the bottom of the screen.
Enter the following input, and ensure the output is correct. Household sizes: 4, 1, 2, 4, 3, 3, 2, 2, 2, 4, 5, 6 followed by 999 to exit the program.

"
HouseholdSize. py - This program uses a bubble sort to arrange household sizes in descending order and then prints the mean and median household size.
Input: Interactive.
Output: Mean and median household size.
"

# Initialize variables.
householdSizes = [] # Array used to store household sizes.
numSizes = 0
total = 0.0
mean = 0.0
median = 0

# Input household size
householdSizeString = input("Enter household size or 999 to quit: ")
householdSize = int(householdSizeString)
# This is the work done in the fillArray() function
while (householdSize != 999):
# Place value in array.
householdSizes. append(householdSize)
# Calculate total of household sizes

numSizes += 1 # We have one more house
householdSizeString = input("Enter household size or 999 to quit: ")
householdSize = int(householdSizeString)

# Find the mean
# This is the work done in the sortArray() function
# This is the work done in the displayArray() function
# Find the median

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 15:20
In a game with three frames, where will the objects on layer 1 appear? a. next to the play area b. in the middle of the game c. behind everything else d. in front of everything else
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
Why should you evaluate trends when thinking about a career path?
Answers: 1
question
Computers and Technology, 24.06.2019 16:50
Develop the program incrementally: a) start by reading and displaying each line of the input file to make sure you are reading the data set correctly. b) use the split string method to extract information from each line into a list. print the list to prove that this step is working correctly. d) convert the exam scores to type int and calculate the student’s average. display those items to prove this step is working correctly. e) create a tuple containing the six items for each student (name, exam scores, exam mean). display the tuples to prove this step is working correctly. (optionally, you may want to have the exam scores in a list so your tuple is (name, scores_list, f) append each tuple to a list. display the list to prove this step is working correctly. g) use the sort list method to re-order the tuples in the list. display the list to prove this step is working correctly. h) use a for statement to display the contents of the list as a table (with appropriate formatting). i) use a for statement to calculate the average of all scores on exam #1, then display the results. note that you could have calculated this average within the first loop, but we are explicitly requiring you to do this calculation by looping though your list of tuples. j) add the logic to calculate the average of all scores on exam #2, then display the results.
Answers: 2
question
Computers and Technology, 24.06.2019 21:30
How is a wan different than a lan? both connect computers, but only wan users don’t need the same operating system. both are peer-to-peer networks, but only a wan requires networking hardware. both network computers, but only a wan can cover larger geographical ranges. both connect computers to the internet, but only wan connects to the cloud.
Answers: 1
You know the right answer?
Complete a Python program that uses a list to store data for the village of Marengo. The village of...
Questions
question
Mathematics, 17.07.2021 14:00
question
Mathematics, 17.07.2021 14:00
question
Mathematics, 17.07.2021 14:00