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, 21.06.2019 20:00
If you embed a word table into powerpoint, what happens when you make edits to the embedded data? a. edits made to embedded data change the data in the source file; however, edits made to the source file will not be reflected in the embedded data. b. edits made to embedded data don't change the data in the source file; however, edits made to the source file will be reflected in the embedded data. c. edits made to embedded data don't change the data in the source file, nor will edits made to the source file be reflected in the embedded data. d. edits made to embedded data will change the data in the source file, and edits made to the source file will be reflected in the embedded data.
Answers: 1
question
Computers and Technology, 21.06.2019 23:10
Write a method that accepts a string object as an argument and returns the number of words it contains. for instance, if the argument is "four score and seven years ago", the method should return the number 6. demonstrate the method in a program that asks the user to input a string and then passes that string into the method, printing out whatever the method returns.
Answers: 3
question
Computers and Technology, 24.06.2019 13:30
Type the correct answer in the box. spell all words correctly. what is the default margin width on all four sides of a document? by default, the document has a margin on all four sides.
Answers: 1
question
Computers and Technology, 24.06.2019 14:30
When workers demonstrate patience, are able to manage there emotions, and get along with other employees, which skills are being displayed?
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
Social Studies, 08.04.2020 19:08
question
Mathematics, 08.04.2020 19:08
question
Mathematics, 08.04.2020 19:09
question
Mathematics, 08.04.2020 19:09
question
Mathematics, 08.04.2020 19:09
question
Mathematics, 08.04.2020 19:09
Questions on the website: 13722360