Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Patient:
- def __init__(self, name, sugar_in, fat_in, salt_in):
- self.name = input('Type Name: ')
- self.sugar_in = float(input('Type Daily Sugar Intake (grams): '))
- self.fat_in = float(input('Type Daily Fat Intake (grams): '))
- self.salt_in = float(input('Type Daily Salt Intake (mgrams): '))
- print()
- self.max_sugar = 37.5
- self.max_fat = 77
- self.max_salt = 2300
- def patient_is_healthy(self):
- print(f"{self.name} Diagnotic: ")
- if self.sugar_in <= self.max_sugar:
- print(f'Sugar Intake {self.sugar_in} is under limit of 37.5g. It is OK. Congratulations!')
- else:
- print(f'Sugar Intake {self.sugar_in} is over limit of 37.5g. It is not healthy!')
- if self.fat_in <= self.max_fat:
- print(f'Fat Intake {self.fat_in} is under the limit of 77g. It is OK. Congratulations!')
- else:
- print(f'Fat Intake {self.fat_in} is over the limit of 77g. It is not healthy!')
- if self.salt_in <= self.max_salt:
- print(f'Salt Intake {self.salt_in} is under the limit of 2,300mg. It is OK. Congratulations!')
- else:
- print(f'Salt Intake {self.salt_in} is over the limit of 2,300mg. It is not healthy!')
- # 3 user examples with max values of sugar, fat and salt)
- patient1 = Patient("user1", 37.5, 77, 2300)
- patient2 = Patient("user2", 37.5, 77, 2300)
- patient3 = Patient("user3", 37.5, 77, 2300)
- print()
- patient1.patient_is_healthy()
- print()
- patient2.patient_is_healthy()
- print()
- patient3.patient_is_healthy()
Advertisement
Add Comment
Please, Sign In to add comment