Skip to content

Instantly share code, notes, and snippets.

@codecademydev

codecademydev/script.py Secret

Created Oct 28, 2020
Embed
What would you like to do?
Codecademy export
# create the initial variables below
age = 28
sex = 0
bmi = 26.2
num_of_children = 3
smoker = 0
# Add insurance estimate formula below
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.")
# Age Factor
age += 4
new_insurance_cost = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 12500
change_in_insurance_cost = new_insurance_cost - insurance_cost
print("The Change in cost of insurance after increasing the age by 4 years is " + str(change_in_insurance_cost) + " dollars.")
# BMI Factor
age = 28
bmi += 3.1
new_cost_bmi = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 1250
change_cost_bmi = new_cost_bmi - insurance_cost
print("The change in estimated isnurance cost after increasing BMI by 3.1 is " + str(change_cost_bmi) + " dollars.")
# Male vs. Female Factor
bmi = 26.2
sex = 1
new_cost_sex = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 1250
change_cost_sex = new_cost_sex - insurance_cost
print("The change in estimated cost for being male instead of female is " + str(change_cost_sex) + " dollars")
# Extra Practice
num_of_children = 0
new_cost_0_kids = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 1250
change_cost_0_kids = new_cost_sex - new_cost_0_kids
print("The change in estimated cost being a male with 3 kids compared to 0 kids is " + str(change_cost_0_kids) + "dollars")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.