Hello Everyone! I am currently on the Medical Insurance Estimates VS Costs Python project and I am questioning the output of my code. I am currently doing the project on Jupyter and I have also have gotten the same result each time. The link to the project is:
This is my current standing code:
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]
total_cost = 0
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]
for insurance_cost in actual_insurance_costs:
total_cost += insurance_cost
average_cost = total_cost / len(actual_insurance_costs)
print(‘Average Insurance Cost: ’ + str(average_cost) + ’ dollars.’)
for i in range(len(names)):
name = names[i]
insuance_cost = actual_insurance_costs[i]
print(‘The insurance cost for ’ + name + ’ is ’ + str(insurance_cost) + ’ dollars.’)
My problem surrounds task # 6 which states:
Inside of the for
loop, do the following:
- Create a variable
name
, which storesnames[i]
. - Create a variable
insurance_cost
, which storesactual_insurance_costs[i]
. - Print out the insurance cost for each individual, with the following message:
The insurance cost for <name> is <insurance_cost> dollars.
The solution I came up with is:
for i in range(len(names)):
name = names[i]
insuance_cost = actual_insurance_costs[i]
print(‘The insurance cost for ’ + name + ’ is ’ + str(insurance_cost) + ’ dollars.’)
My output is:
The insurance cost for Judith is 7700.0 dollars.
The insurance cost for Abel is 7700.0 dollars.
The insurance cost for Tyson is 7700.0 dollars.
The insurance cost for Martha is 7700.0 dollars.
The insurance cost for Beverley is 7700.0 dollars.
The insurance cost for David is 7700.0 dollars.
The insurance cost for Anabel is 7700.0 dollars
This output does not seem right to me, Can someone confirm that I am performing this task correctly, or if I have done something wrong.
Thank you!