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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 23:30, kenken2583
Jaina and tomas are being considered as new tenants in an apartment. the landlord looks at their creditworthiness because he wants to be sure his new tenant pays the rent on time and in full. the table below summarizes the information that was on their applications. application information questions jaina tomas how many years have you had your job? 5 2 what is your monthly salary? $1,850 $2,500 how many credit cards do you have? 4 1 how much debt do you have? $13,000 $7,000 how many times were you late with payments on credit cards in the past year? 5 1 who will the landlord decide to be more creditworthy and why? tomas because the ratio of his debt to income is less. jaina because she has had her job longer, which makes her look more stable. jaina because she has more credit cards available to her. tomas because he makes more money per month.
Answers: 2
image
Computers and Technology, 23.06.2019 06:00, hilarydodard7099
Which statistical function in a spreadsheet you to see how far each number varies, on average, from the average value of the list?
Answers: 2
image
Computers and Technology, 23.06.2019 14:00, ava5015
What is html ? give a small description about html
Answers: 2
image
Computers and Technology, 23.06.2019 15:00, Siris420
Plz ( which is an example of a good url?
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 in other subjects: