crzcas

Patient intake (sugar, fat, salt))

Feb 16th, 2022
1,466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.59 KB | None | 0 0
  1. class Patient:
  2.  
  3.     def __init__(self, name, sugar_in, fat_in, salt_in):
  4.         self.name = input('Type Name: ')
  5.         self.sugar_in = float(input('Type Daily Sugar Intake (grams): '))
  6.         self.fat_in = float(input('Type Daily Fat Intake (grams): '))
  7.         self.salt_in = float(input('Type Daily Salt Intake (mgrams): '))
  8.         print()
  9.         self.max_sugar = 37.5
  10.         self.max_fat = 77
  11.         self.max_salt = 2300
  12.  
  13.     def patient_is_healthy(self):
  14.         print(f"{self.name} Diagnotic: ")
  15.         if self.sugar_in <= self.max_sugar:
  16.             print(f'Sugar Intake {self.sugar_in} is under limit of 37.5g. It is OK. Congratulations!')
  17.         else:
  18.             print(f'Sugar Intake {self.sugar_in} is over limit of 37.5g. It is not healthy!')
  19.        
  20.         if self.fat_in <= self.max_fat:
  21.             print(f'Fat Intake {self.fat_in} is under the limit of 77g. It is OK. Congratulations!')
  22.         else:
  23.             print(f'Fat Intake {self.fat_in} is over the limit of 77g. It is not healthy!')
  24.  
  25.         if self.salt_in <= self.max_salt:
  26.             print(f'Salt Intake {self.salt_in} is under the limit of 2,300mg. It is OK. Congratulations!')
  27.         else:
  28.             print(f'Salt Intake {self.salt_in} is over the limit of 2,300mg. It is not healthy!')
  29.  
  30.  
  31. # 3 user examples with max values of sugar, fat and salt)
  32. patient1 = Patient("user1", 37.5, 77, 2300)
  33. patient2 = Patient("user2", 37.5, 77, 2300)
  34. patient3 = Patient("user3", 37.5, 77, 2300)
  35.  
  36. print()
  37. patient1.patient_is_healthy()
  38. print()
  39. patient2.patient_is_healthy()
  40. print()
  41. patient3.patient_is_healthy()
  42.  
Advertisement
Add Comment
Please, Sign In to add comment