Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created November 1, 2020 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/cc841c295ed31285427f937b40a78961 to your computer and use it in GitHub Desktop.
Save codecademydev/cc841c295ed31285427f937b40a78961 to your computer and use it in GitHub Desktop.
Codecademy export
# Calculate_insurance_cost() function below:
def calculate_insurance_cost(age, sex, bmi, num_of_children, smoker, name):
estimated_cost = 250*age - 128*sex + 370*bmi + 425*num_of_children + 24000*smoker - 12500
print("The estimated insurance cost for " + name + " is " + str(estimated_cost) + " dollars.")
return estimated_cost
# Input data for 2x people to calculate and print cost for each, as well as return the cost for each.
cost_person_1 = calculate_insurance_cost(28, 0, 26.2, 3, 0, "maria")
cost_person_2 = calculate_insurance_cost(35, 1, 22.2, 0, 1, "omar")
# Calculate difference in cost for person 1 and person 2 and print the difference as an absolute value.
def insurance_cost_difference(person_1, person_2):
diff = abs(cost_person_1 - cost_person_2)
print("The difference in insurance cost is " + str(diff) + " dollars.")
insurance_cost_difference(cost_person_1, cost_person_2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment