# Python Syntax: Medical Insurance Project

Hey Everyone!
I just finished the Medical Insurance Project in Python. Any feedback would be appreciated! Thanks

1 Like

Once you learned about functions should revisit this project and use function to eliminate some of the repetitiveness

Looks good! I recently decided to completely restart the Data Science course after they implemented their course updates (was about 30% through prior to updates). @stetim94 is definitely right about functions, or maybe even class? Will revisit both ideas once I get further into the new content.

I attached my project–I created new variables for the changed info, rather than changing the variables back and forth. A bit more work, but it keeps things straight in my head.

Feedback is appreciated!

1 Like

you could make a gist on gist.github.com, then copy and paste the link of the gist on the forum, which will recognize the gist and display it in a nice way.

2 Likes

Great, thanks! I’ll try editing my reply now and see if it works.

1 Like

There’s a handy link in the learning environment (share icon) near the save/run button that will even do it for you .

1 Like

I was like: I vaguely remember that there was a better way, but forgot what it was. Good one

2 Likes

Excellent, thank you!

1 Like

I learned functions and you are absolutely right! It really takes out the mass repeating.

Hey guys, I am new here learning python.
I am trying to understand how does the math work on this medical insurance project, my numbers just don’t line up. I follow the instructions, and I have no problems when writing the code. I would like to be able to understand the math, if anyone is kind of enough to explain it to me it would be appreciated.

Thank you

You’re basically adding up a series of numbers, each multiplied by a constant. Perhaps if you separate each part out it may be easier to read-

``````# constant of 250, multiplied by patient age
(250 * age)
# start adding together all other variables
+ (-128 * sex)  # the constant here is negative
+ (370 * bmi)
+ (425 * num_of_children)
+ (24000 * smoker)
-12500  # just remove 12,500 from the total number at this point
``````

If that’s not clear then consider adding a new question on the forums- FAQ: How to ask good questions or if the math itself is still unclear then take a bit of time to learn it because coding does require a certain level of mathematical knowledge. For this problem at the very least the order of mathematical operations must be known.

For a more general order of operations in Python see-
https://docs.python.org/3/reference/expressions.html#operator-precedence

1 Like

Thank you for your response, I did break it into parts and separated each part over the weekend and it definitely it was clear. Ha! I believe I was overthinking it too much that day.