A hospital wants to store a record regarding its patients. The information to store include
Create a class called Patient to store the above information. Date of Birth and Disease of a patient should be private data attributes. Create public methods which take all above information as input from user and then display / output all the information.
class Pacient:
def set(self):
self.name = input('Name:')
self.age = input('Age:')
self.__birth = input('Date of Birth of Patient (yyyy/mm/dd):')
self.__disease = input('Disease:')
self.admission = input('Date of Admission (yyyy/mm/dd):')
self.discharge = input('Date of discharge (yyyy/mm/dd):')
def __str__(self):
return ('Name: ' + self.name + '\n' +
'Age: ' + self.age + '\n' +
'Date of Birth of Patient (yyyy/mm/dd): ' + self.__birth + '\n' +
'Disease: ' + self.__disease + '\n' +
'Date of Admission (yyyy/mm/dd):' + self.admission + '\n' +
'Date of discharge: ' + self.discharge)
pacient1 = Pacient()
pacient1.set()
print(pacient1)
Name:Antony
Age:25
Date of Birth of Patient (yyyy/mm/dd):2010/01/09
Disease:COVID
Date of Admission (yyyy/mm/dd):2022/02/22
Date of discharge (yyyy/mm/dd):2022/02/28
Name: Antony
Age: 25
Date of Birth of Patient (yyyy/mm/dd): 2010/01/09
Disease: COVID
Date of Admission (yyyy/mm/dd):2022/02/22
Date of discharge: 2022/02/28
Comments
Leave a comment