Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created November 18, 2020 20:31
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/bcd1c5df5c5bc3fcdcdcdbe9098a8375 to your computer and use it in GitHub Desktop.
Save codecademydev/bcd1c5df5c5bc3fcdcdcdbe9098a8375 to your computer and use it in GitHub Desktop.
Codecademy export
class Patient:
def __init__(self, name, age, sex, bmi, num_of_children, smoker):
self.name = name
self.age = age
# add more parameters here
self.sex = sex
self.bmi = bmi
self.num_of_children = num_of_children
self.smoker = smoker
def estimated_insurance_cost(self):
estimated_cost = 250*self.age - 128*self.sex + 370*self.bmi + 425*self.num_of_children + 24000*self.smoker - 12500
print("{}’s estimated insurance costs is {} dollars.".format(self.name, estimated_cost))
patient1 = Patient("John Doe", 25, 1, 22.2, 0, 0)
print(patient1.estimated_insurance_cost())
@jis5827
Copy link

jis5827 commented Aug 8, 2022

Run

@oviefrank
Copy link

I think you should call the estimated_insurance_cost method with a print function because when you return the total estimated cost, you use print.
use the instance of the class variable for Patient
patient1.estimated_insurance_cost()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment