-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path150768_q1.py
70 lines (58 loc) · 2.17 KB
/
150768_q1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def addPatient(patients):
name = input("Enter the patient's name: ")
age = input("Enter the patient's age: ")
illness = input("Enter the patient's illness: ")
patient = {
'name': name,
'age': age,
'illness': illness
}
patients.append(patient)
print(f"The patient named {name} has been successfully added.")
def showPatients(patients):
if not patients:
print("No patients were found.")
else:
for patient in patients:
print(f"Name: {patient['name']}, \nAge: {patient['age']}, \nIllness: {patient['illness']}")
def searchPatient(patients):
name = input("Enter the patient's name: ")
for patient in patients:
if patient['name'].lower() == name.lower():
print(f"Name: {patient['name']}, \nAge: {patient['age']}, \nIllness: {patient['illness']}")
return
print(f"The patient named {name} was not found.")
def removePatient(patients):
name = input("Enter the patient's name: ")
for patient in patients:
if patient['name'].lower() == name.lower():
patients.remove(patient)
print(f"The patient named {name} was successfully removed.")
return
print(f"The patient named {name} was not found.")
def main():
patients = []
while True:
print("\nHospital Patient Management System")
print("1. Add a new patient")
print("2. Display all patients")
print("3. Search for a patient by name")
print("4. Remove a patient by name")
print("5. Exit")
choice = input("Choose an option number: ")
if choice == '1':
addPatient(patients)
elif choice == '2':
showPatients(patients)
elif choice == '3':
searchPatient(patients)
elif choice == '4':
removePatient(patients)
elif choice == '5':
print("Exiting the program.")
break
else:
print("Invalid choice. Please try again.")
# Run the main program
if __name__ == "__main__":
main()