Python Syntax: Medical Insurance Project

Ok, so I’m having a difficult time understanding what step #9 is trying to explain in the DS path, particularily dealing with “Python Syntax: Medical Insurance Project”

the question goes:
Now let’s find out how a change in BMI affects insurance costs. Our next steps are pretty much the same as we have done before when looking at age .

  1. Below the line where bmi was increased by 3.1 , rewrite the insurance cost formula and assign it to the variable name new_insurance_cost .
  2. Save the difference between new_insurance_cost and insurance_cost in a variable called change_in_insurance_cost
  3. Display the following string in the output terminal, where XXX is replaced by the value of change_in_insurance_cost :
The change in estimated insurance cost after increasing BMI by 3.1 is XXX dollars.

You can leave the code above it as is, including the print statements.

So my confusion comes from why I would have to re-ad the insurance costs after already changing the BMI?
ive already calculated the BMI and now its asking to to ad those same variables again, even though (to my clearly untrained eyes) nothing has changed?

The BMI variable has changed bmi += 3.1 and that would affect the change in the insurance cost.
Goes back to the original definition of that insurance_cost variable’s formula:

insurance_cost = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 12500

Any time the age, sex, bmi, num_of_children, smoker status changes, that affects the cost.

I understand that, although I guess what I’m having a hard time with is this:
I’ve already set up all of the variables, and now that I’ve changed the BMI (refer to pic) I’m not sure what I should be doing in part 9 to show the difference.
The way I’m reading this is that it wants me to keep the variable names from the previous example, while re-using them to get a different output? although if I keep the same names nothing will have changed? Yet it still wants me to keep the same names?
The only way I can think to make this work is to change the names and create a new variable like “change_in_bmi_cost” or something like that?

not only that, but for whatever reason even when I do the:
age+=4 it only works when i place it right under the original age variable? it doesnt seem to change the cost if i place the updated var anywhere else in the editor?

Yea, you’re just creating new variables based on the changes w/age, bmi, etc.

like you stated: change_in_insurance_cost = new_insurance_cost - insurance_cost

If I recall correctly, you’re changing the age in a couple steps (5&8?)

So, every time you reassign a value to that variable (age, or whatever), you’re going to get a diff. result for new_insurance_cost b/c the value change affects the original formula.
insurance_cost = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 12500
(so you have to re-run the code.)

1 Like

omg i feel like such a goof lol Thank you so much lisa!!

1 Like

YW. Sometimes it just takes a second set of eyes. :slightly_smiling_face:

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.