Help required for Python Fundamentals: Medical Insurance Project - I'm not getting the same answers as the Hints

Hi I am a complete noobie to Python and this forum. I’m nervous about even asking my questions her because I don’t want to seem dumb.

https://www.codecademy.com/paths/data-analyst/tracks/dacp-python-fundamentals/modules/dscp-python-syntax/projects/ds-python-syntax-project

I’m confused because I am not getting the same answers as the Hints and I have tried to find an answer to my question but can’t find one specifically that answers my question.

Step 1: I created the initials variables below

create the initial variables below

age = 28
sex = 0
bmi = 26.2
num_of_children = 3
smoker = 0

Step 2: I created my formula like this as per instructed:

#Add insurance estimate formula below

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

Step 3: my print statement looks like this:

print(“This person’s insurance cost is” " “+ str(insurance_cost) + " dollars.”)

The output returned: This person’s insurance cost is 7000 dollars.

However, when I look at the answer from the hint section I get this:
The output of this print statement should be:

This person's insurance cost is 5469.0 dollars.

what am I doing wrong here?

I can’t see what your error may be; is this the same order that you ran your code in? Simply running the first two sections in order outputs 5469.0 as per the instructions. Sure you’re not altering insurance_cost between the assignments and the print?

age = 28
sex = 0
bmi = 26.2
num_of_children = 3
smoker = 0

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

print("This person's insurance cost is"  " "+ str(insurance_cost) +  " dollars.")
Out: This person's insurance cost is 5469.0 dollars.

Please see How do I format code in my posts? as unformatted code can be much harder for others to read.

2 Likes

Ahh thank you tgrtim. That must have been what happened. I had skipped ahead to the age factor and beyond and perhaps that’s why my output showed 7000 and not 5469.0. I will start the project again from the beginning.

Thank you very much.

2 Likes

Hi, welcome to the forums! :slightly_smiling_face:

This is a response that we see here quite a lot. I can totally relate to feeling like that in the past, so I understand where you’re coming from. It’s tough putting ourselves “out there” for others to comment. BUT, please don’t let what others might think influence your learning process. If you don’t understand something, google it, ask questions, use the search here in the forums…b/c I can guarantee you that others have been in the same situation.

We are all learners here.
Happy coding!

1 Like

Thank you lisa :slight_smile: Although I still feel pretty dumb

stop saying that and just focus on your learning and understanding

Good day

hello,welcome :innocent: :innocent: :innocent: :innocent: :innocent: :innocent: :innocent: