Hi everyone, this is the second project post on forums. Any advice is welcome.
names = ["Judith", "Abel", "Tyson", "Martha", "Beverley", "David", "Anabel"]
estimated_insurance_costs = [1000.0, 2000.0, 3000.0, 4000.0, 5000.0, 6000.0, 7000.0]
actual_insurance_costs = [1100.0, 2200.0, 3300.0, 4400.0, 5500.0, 6600.0, 7700.0]
actual_insurance_costs_copy = [1100.0, 2200.0, 3300.0, 4400.0, 5500.0, 6600.0, 7700.0]
# Add your code here
total_cost = 0
#[for loop]:
#for cost_a in actual_insurance_costs:
#total_cost += cost_a
#To use [while loop] and function .pop add up total_cost, have to use the actual_insurance_costs's copy, or the rest of code can't literate an empty list.
while len(actual_insurance_costs_copy) > 0:
a_cost = actual_insurance_costs_copy.pop()
total_cost += a_cost
print(total_cost)
average_cost = total_cost / len(actual_insurance_costs)
print('Average Insurance Cost: {0} dollars.'.format(average_cost))
for i in range(len(names)):
name = names[i]
insurance_cost = actual_insurance_costs[i]
print('The insurance cost for {0} is {1} dollars.'.format(name, insurance_cost))
average_actual_cost = sum(actual_insurance_costs) / len(actual_insurance_costs)
if insurance_cost > average_actual_cost:
upper_different = insurance_cost - average_actual_cost
print('The insurance for {0} is ${1} costly than average.'.format(name, upper_different))
elif insurance_cost < average_actual_cost:
lower_different = average_actual_cost - insurance_cost
print('The insurance for {0} is ${1} cheaper than average.'.format(name, lower_different))
else:
print('The insurance cost for {0} is equal to the average.'.format(name))
updated_estimated_costs = [up_cost * 11 / 10 for up_cost in estimated_insurance_costs]
print(updated_estimated_costs)