Answer to Question #304041 in Python for thunderz

Question #304041

A hospital wants to store a record regarding its patients. The information to store include

  • Name of the patient
  • Age of the patient
  • Date of Birth of Patient (yyyy/mm/dd)
  • Disease
  • Date of Admission
  • Date of discharge

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.


1
Expert's answer
2022-02-28T13:54:17-0500
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


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS