The instructions in Step 5 are:
Now that we’ve written the analyze_smoker()
function, let’s make use of it.
In the estimate_insurance_cost()
function, go to the line of code that prints the estimated insurance cost. On the next line, make a function call to analyze_smoker()
, passing in the smoker
variable as an argument.
Click “Save” to see the result.
Codecademy’s answer is this:
def analyze_smoker(smoker_status):
if smoker_status == 1:
print(“To lower your cost, you should consider quitting smoking.”)
else:
print(“Smoking is not an issue for you.”)
def estimate_insurance_cost(name, age, sex, bmi, num_of_children, smoker):
estimated_cost = 250age - 128sex + 370bmi + 425num_of_children + 24000*smoker - 12500
print(name + “'s Estimated Insurance Cost: " + str(estimated_cost) + " dollars.”)
analyze_smoker(smoker)
return estimated_cost
The output is:
Keanu’s Estimated Insurance Cost: 29591.0 dollars.
To lower your cost, you should consider quitting smoking.
I don’t understand how passing “smoker” as an argument would work. I understand that if I pass “1” as an argument, I would get the same output. And if I pass “0”, the output would be “Smoking is not an issue for you.”
Does the “_status” in the “analyze_smoker” function have anything to do with this?
Can someone please explain this to me? Thanks.
Hello and welcome to the forums! 
The value of the smoker column (and therefore that smoker
variable) would be either 1
(if they are a smoker) or 0
(if they are not), so you can directly pass that value into the analyze_smoker
function and use it on the conditional.
The name of the smoker_status
parameter is technically irrelevant, and we could call it anything, smoker_status
is just good as it reflects well what the value will actually be.
Hope that helps?
As an aside, when sharing code on the forums please format it according to this guide: How do I format code in my posts?, it’s especially important for indentation-sensitive languages like Python as it preserves the indentation of any code you share.
Thank you for your reply and for bringing my attention to code formatting in my posts.
I’m still confused about why the word “smoker” in the function call analyze_smoker(smoker) works.
Shouldn’t the function call be either analyze_smoker(1) or analyze_smoker(0)?
1 Like
The function call reads as follows:
keanu_insurance_cost = estimate_insurance_cost(name = ‘Keanu’, age = 29, sex = 1, bmi = 26.2, num_of_children = 3, smoker = 1)
I think I got it. Passing “smoker” as an argument would take the value of 1 because that’s what’s assigned to it. Am i right?
1 Like
Hello!
Yup, that’s right! The smoker_status
variable will take the value of whatever is passed in, which will be either a 1 or a 0, as these are the two possible values for smoker
.
Passing 1 or 0 directly into the function from inside estimate_insurance_cost
wouldn’t work because some of the people passed into the estimate_insurance_cost
function would be a smoker, while others would not, and hard coding a value would mean you could not differentiate between the two as only one of the two possible values would ever be passed into analyze_smoker
.
Happy coding! 
I get it now. Thanks so much! I really appreciate your help 
1 Like