class Studentdetails:
def __init__(self, name, address, telephone, address2="London"):
self.name = name
self.address = address
self.telephone = telephone
self.city = address2
def __repr__(self):
return f'Name={self.name}, Address={self.address}, City={self.city}, Telephone={self.telephone}'
class Totalmarks():
def __init__(self, total=0.0, average=0.0):
self.totmarks = total
self.average = average
def total(self, total):
self.markslist = total
for i in range(5):
self.totmarks = self.totmarks + self.markslist[i]
return self.totmarks
def Aver(self):
self.average = self.totmarks / 5
return self.average
class Teachercomments():
def comments(self, average):
self.average = average
if self.average <= 30:
print("Teacher Comments: ", "\n", "Needs to work hard and attend extra sessions to progress.")
elif self.average >= 31 and self.average <= 50:
print("Teacher Comments: ", "\n", "Needs to improve the quality of work produced to make a progression")
elif self.average >= 51 and self.average <= 70:
print("Teacher Comments: ", "\n",
"Making good progress but need to focus on certain topics to achieve high marks")
elif self.average >= 71 and self.average <= 80:
print("Teacher Comments: ", "\n", "Needs to be carefully")
else:
print("Teacher Comments: ", "\n", "Well done for making an excellent progress.")
def report():
s = "*" * 65
studtotal = Totalmarks()
print(s, "\n", " " * 20, "Student Report", "\n", s)
marks = []
for i in range(5):
smarks = int(input("please enter your mark"))
marks.append(smarks)
print(marks)
sumtot = studtotal.total(marks)
av = studtotal.Aver()
print("Total marks:", sumtot)
print("Average:", av)
tcom = Teachercomments()
tcom.comments(av)
report()
name = ["Scott", "Liz", "Sarah", "Mark", "Dan"]
address = ["21, old kent road", "13,Trafalgar Square", "45,KingsCross Road", "33,Russel square",
"56,Lewisham Road"]
telephone = ["02075642222", "02078642123", "02084641111", "02085553234", "02076662123"]
students = []
assert len(name) == len(address) and len(address) == len(telephone)
for name_, address_, telephone_ in zip(name, address, telephone):
students.append(Studentdetails(name_, address_, telephone_))
for student in students:
print(student)
Output
*****************************************************************
Student Report
*****************************************************************
please enter your mark1
please enter your mark2
please enter your mark3
please enter your mark4
please enter your mark45
[1, 2, 3, 4, 45]
Total marks: 55.0
Average: 11.0
Teacher Comments:
Needs to work hard and attend extra sessions to progress.
Name=Scott, Address=21, old kent road, City=London, Telephone=02075642222
Name=Liz, Address=13,Trafalgar Square, City=London, Telephone=02078642123
Name=Sarah, Address=45,KingsCross Road, City=London, Telephone=02084641111
Name=Mark, Address=33,Russel square, City=London, Telephone=02085553234
Name=Dan, Address=56,Lewisham Road, City=London, Telephone=02076662123