You are on page 1of 8

Question 1

Design a Student class so that the following output is produced upon executing the
following code

s1 = Student() Student name and department need to be set


print(“=========================”) =========================
s2 = Student(“Carol”) Department for Carol needs to be set
=========================
print(“=========================”)
Jon is from EEE department
s3 = Student(“Jon”, “EEE”)
=========================
print(“=========================”)
###########################
s1.update_name(“Bob”)
Name: Bob
s1.update_department(“CSE”)
Department: CSE
s2.update_department(“BBA”)
Bob enrolled in 3 course(s):
s1.enroll(“CSE110”, “MAT110”, “ENG091”)
CSE110, MAT110, ENG091
s2.enroll(“BUS101”)
=========================
s3.enroll(““MAT110”, “PHY111”)
Name: Carol
print(“###########################”)
Department: BBA
s1.printDetail()
Carol enrolled in 1 course(s):
print(“=========================”)
BUS101
s2.printDetail()
=========================
print(“=========================”)
Name: Jon
s3.printDetail()
Department: EEE
Jon enrolled in 2 course(s):
MAT110, PHY111
Question 2
Design a Student class so that the following output is produced upon executing the
following code:
[Hint: Each course has 3.0 credit hours. You must take at least 9.0 and at most
12.0 credit hours. ]

s1 = Student(“Alice”,“20103012”,“CSE”) ##########################
s2 = Student(“Bob”, “18301254”,“EEE”) Name: Alice
s3 = Student(“Carol”, “17101238”,“CSE”) ID: 20103012
print(“##########################”) Department: CSE
print(s1.details()) ##########################
print(“##########################”) Name: Bob
print(s2.details()) ID: 18301254
print(“##########################”) Department: EEE
s1.advise(“CSE110”, “MAT110”, “PHY111”) ##########################
print(“##########################”) Alice, you have taken 9.0 credits.
s2.advise(“BUS101”, “MAT120”) List of courses: CSE110, MAT110, PHY111
print(“##########################”) Status: Ok
s3.advise(“MAT110”, “PHY111”, “ENG102”, ##########################
“CSE111”, “CSE230”) Bob, you have taken 6.0 credits.
List of courses: BUS101, MAT120
Status: You have to take at least 1 more
course.
##########################
Carol, you have taken 15.0 credits.
List of courses: MAT110, PHY111, ENG102,
CSE111, CSE230
Status: You have to drop at least 1 course.
Question 3
Write the Hotel class with the required methods to give the following outputs as shown.

# Write your codes here. OUTPUT:

# Do not change the following lines of code. Staff With ID 1 is added


h = Hotel("Lakeshore") =================================
h.addStuff( "Adam", 26) Staff ID: 1
print("=================================") Name: Adam
print(h.getStuffById(1)) Age: 26
print("=================================") Phone no.: 000
h.addGuest(“Carol”,35,”123”) =================================
print("=================================") Guest With ID 1 is created
print(h.getGuestById(1)) =================================
print("=================================") Guest ID: 1
g2 = Hotel("Guest", "Diana, 32, “431”) Name: Carol
print("=================================") Age: 35
print(g2.getDetails())) Phone no.: 123
print("=================================") =================================
s1.allStaffs() Guest With ID 2 is created
print("=================================") =================================
g1.allGuest() Guest ID: 2
Name: Dianal
Age: 32
Phone no.: 431
=================================
All Staffs:
Number of Staff: 1
Staff ID: 1 Name: Adam Age: 26 Phone no: 000
=================================
All Guest:
Number of Guest: 2
Guest ID: 1 Name: Carol Age: 35 Phone no.: 123
Guest ID: 2 Name: Dianal Age: 32 Phone no.: 431
Question 4

Write the Author class with the required methods to give the following outputs as
shown.

# Write your codes here. OUTPUT:


=================================
# Do not change the following lines of code. =================================
print("=================================") A book can not be added without author name
a1 = Author() =================================
print("=================================") Number of Book(s): 1
a1.addBook(“Ice”, “Science Fiction”) Author Name: Anna Kavan
print("=================================") Science Fiction: Ice
a1.setName(“Anna Kavan”)
=================================
a1.addBook(“Ice”, “Science Fiction”)
=================================
a1.printDetail()
Number of Book(s): 2
print("=================================")
Author Name: Humayun Ahmed
a2 = Author(“Humayun Ahmed”)
Science Fiction: Onnobhubon
a2.addBook(“Onnobhubon”, “Science Fiction”)
Horror: Megher Upor Bari
a2.addBook(“Megher Upor Bari”, “Horror”)
=================================
print(=================================")
a2.printDetail() Number of Book(s): 3
a2.addBook(“Ireena”, “Science Fiction”) Author Name: Humayun Ahmed
print("=================================") Science Fiction: Onnobhubon, Ireena
a2.printDetail() Horror: Megher Upor Bari
print("=================================") =================================
Question 5
Write the Hospital class with the required methods to give the following outputs as shown.

# Write your codes here. OUTPUT:

# Do not change the following lines of code. Doctor's ID: 1d


d1 = Hospital("Doctor", "Samar Kumar", "Neurologist") Name: Samar Kumar
d1.addDoctor("1d") Speciality: Neurologist
print(d1.getDoctorByID("1d")) =================================
print("=================================") Patient's ID: 1p
p1 = Hospital("Patient", "Kashem Ahmed", 35, 12345) Name: Kashem Ahmed
p1.addPatient("1p") Age: 35
print(d1.getPatientByID("1p")) Phone no.: 12345
print("=================================") =================================
p1 = Hospital("Patient", "Tanina Haque", 26, 33456) Patient's ID: 2p
p1.addPatient("2p") Name: Tanina Haque
print(d1.getPatientByID("2p")) Age: 26
print("=================================") Phone no.: 33456
d1.allDoctors() =================================
p1.allPatients() All Doctors:
Number of Doctors: 1
{'1d': ['Samar Kumar', 'Neurologist']}
All Patients:
Number of Patients: 2
{'1p': ['Kashem Ahmed', 35, 12345], '2p':
['Tanina Haque', 26, 33456]}
Question 6
Question 7
Write the Game class with the required properties to give the following outputs as shown.

# Write your codes here. OUTPUT:


=================================
# Do not change the following lines of code. Agent Raze added
h = Game("Valorant") =================================
print("=================================") Total Duelists: 1
h.addDuelist("Raze","Paint shells","SHOWSTOPPER",8) Duelist 1
print("=================================") Agent Name:Raze
print(h.printAllDuelists()) Default ability:Paint shells
print("=================================")
Ultimate: SHOWSTOPPER
h.addDuelist("Phoenix","Hot hands","Run it back")
Required ultimate points: 8
print("=================================")
=================================
print(h.printAllDuelists())
Agent Phoenix added
print("=================================")
=================================
h.addSentinel("Sage","Healing ORB","Resurrection")
print("=================================") Total Duelists: 2
print(h.printAllSentinels()) Duelist 1
print("=================================") Agent Name:Raze
h.addSentinel("Killjoy","Turret","Lockdown",7) Default ability:Paint shells
print("=================================") Ultimate: SHOWSTOPPER
print(h.printAllSentinels()) Required ultimate points: 8
Duelist 2
Agent Name:Phoenix
Default ability:Hot hands
Ultimate: Run it back
Required ultimate points: 6
=================================
Agent Sage added
=================================
Total Sentinels: 1
Sentinel 1
Agent Name:Sage
Default ability:Healing ORB
Ultimate: Resurrection
Required ultimate points: 8
=================================
Agent Killjoy added
=================================
Total Sentinels: 2
Sentinel 1
Agent Name:Sage
Default ability:Healing ORB
Ultimate: Resurrection
Required ultimate points: 8
Sentinel 2
Agent Name:Killjoy
Default ability:Turret
Ultimate: Lockdown
Required ultimate points: 7

You might also like