fork download
  1. class Patient:
  2. def __init__(self, name, surname, age, weight):
  3. self.name = name
  4. self.surname = surname
  5. self.age = int(age)
  6. self.weight = int(weight)
  7.  
  8. def is_healthy(self):
  9. if self.age <= 30 and self.weight in range(50, 120):
  10. print('Good health, %s %s!' % (self.name, self.surname))
  11. elif self.age in range(30, 40) and self.weight in range(1, 51) or self.weight >= 120:
  12. print('Be careful, %s %s!' % (self.name, self.surname))
  13. elif self.age >= 40 and self.weight in range(1, 120):
  14. print('Medical care required, %s %s!' % (self.name, self.surname))
  15. else:
  16. print('Normal condition')
  17. if __name__ == '__main__':
  18. Gamblou = Patient('Gamblou', 'Willings', 22, 75)
  19. Gamblou.is_healthy()
  20.  
  21. Tiana = Patient('Tiana', 'Lurka', 37, 44)
  22. Tiana.is_healthy()
  23.  
  24. Avian = Patient('Avian', 'Lazlo', 47, 111)
  25. Avian.is_healthy()
  26.  
  27. Olcou = Patient('Olcou', 'Davian', 18, 22)
  28. Olcou.is_healthy()
Success #stdin #stdout 0.02s 9248KB
stdin
Standard input is empty
stdout
Good health, Gamblou Willings!
Be careful, Tiana Lurka!
Medical care required, Avian Lazlo!
Normal condition