Thanks for the previous help by the community. It really gave me the confidence to continue. My confidence was shot a bit with the struggle to get the code to work.
I am trying to complete task 5 and 6.
Now that we have changed our age value, we want to recalculate our insurance cost. Declare a new variable called new_insurance_cost underneath the expression that increased age by 4. Make sure you leave the line with the insurance_cost variable the same. We will use it later in our program!
Next, we want to find the difference between our new_insurance_cost and insurance_cost. To do this, let’s create a new variable called change_in_insurance_cost and set it equal to the difference between new_insurance_cost and insurance_cost. Note: depending on the order that we subtract (eg., new_insurance_cost - insurance cost vs. insurance_cost - new_insurance_cost), we’ll get a positive or negative version of the same number. To make this difference interpretable, let’s calculate new_insurance_cost - insurance_cost. Then we can say, “people who are four years older have estimated insurance costs that are change_in_insurance_cost dollars different, where the sign of change_in_insurance_cost tells us whether the cost is higher or lower.
I am unsure how to proceed.
This my code:
def insurance_cost(age,sex,bmi,num_of_children,smoker): return (250 * age) - (128 * sex) + (370 * bmi) + (425 * num_of_children) + (24000 * smoker) - 12500 age = 28 sex = 0 bmi = 26.2 num_of_children = 3 smoker = 0 total_insurance_cost = insurance_cost(age, sex, bmi, num_of_children, smoker) print("This person’s insurance cost is", total_insurance_cost, "dollars.") # Age Factor age+=4 new_insurance_cost = insurance_cost(age, sex, bmi, num_of_children, smoker) print("This person’s insurance cost is", new_insurance_cost, "dollars.") print(new_insurance_cost) new_insurance_cost=input() print(total_insurance_cost) total_insurance_cost=input() change_in_insurance_cost=float(new_insurance_cost)-float(total_insurance_cost) print("Difference in insurance cost",change_in_insurance_cost)
and the output:
This person’s insurance cost is 5469.0 dollars. This person’s insurance cost is 6469.0 dollars. 6469.0 Traceback (most recent call last): File "script.py", line 20, in <module> new_insurance_cost=input() EOFError: EOF when reading a line
I am strugggling with
- EOF error
2.Intrepreting the difference based on the changes in the variable
3.Outputing a string and float to explain this difference.
Any help will be greatly appreciated.
Thanks in advance.