-
-
Save codecademydev/4842ea099981b54303d1e4ec70a11777 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("{name}’s estimated insurance costs is {cost} dollars.".format(name=self.name,cost=estimated_cost)) | |
def update_age(self,new_age): | |
self.age = new_age | |
print(self.name + " is now "+ str(self.age) +" years old.") | |
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(self.name + " has "+ str(self.num_of_children) +" children.") | |
else: | |
print(self.name + " has "+ str(self.num_of_children) +" child.") | |
self.estimated_insurance_cost() | |
def patient_profile(self): | |
patient_information={} | |
patient_information["Name"]=self.name | |
patient_information["Sex"]=self.sex | |
patient_information["Age"]=self.age | |
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) | |
print(patient1.name) | |
patient1.update_age(30) | |
patient1.update_num_children(2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment