Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created January 14, 2021 18:33
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/5af1c53fc97f923b02e98db6760b92e1 to your computer and use it in GitHub Desktop.
Save codecademydev/5af1c53fc97f923b02e98db6760b92e1 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
self.sex = sex
self.bmi = bmi
self.num_of_children = num_of_children
self.smoker = smoker
def estimated_insurance_cost(self):
estimated_cost = 250*age - 128*sex + 370*bmi + 425*num_of_children + 24000*smoker - 12500
print("{0}'s estimated insurance costs are {1}".format(self.name, str(estimated_cost))
def update_age(self, new_age):
self.age = new_age
print("{0} is now {1} years old.".format(self.name, str(self.age))
self.estimated_insurance_cost()
def update_num_Children(self, new_num_children):
self.num_of_children = new_num_children
if self.num_of_children == 1:
print("{0} has {1} child.".format(self.name, str(self.num_of_children))
else:
print("{0} has {1} children.".format(self.name, str(self.num_of_children))
self.estimated_insurance_cost()
def patient_profile(self):
patient_information = {}
patient_information["Name"] = self.name
patient_information["Age"] = self.age
patient_information["Sex"] = self.sex
patient_information["BMI"] = self.bmi
patient_information["Number of Children"] = self.num_of_children
patient_information["Smoker"] = self.smoker
return patient_information
patient1 = Patient("John Doe", 25, 1, 22.2, 0, 0)
patient1.estimated_insurance_cost()
print(patient1.patient_profile())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment