Computers and Technology
Computers and Technology, 11.12.2019 20:31, cache77

Add three methods to the student class that compare twostudent objects. one method ) should test for equality. a second method ) should test for less than. the third method ) should test for greater than or equal to. in each case, the method returns the result of the comparison of the two students’ names. include a main function that tests all of the comparison operators.
current code is below:
"""
file: student. py
resources to manage a student's name and test scores.
"""
class student(object):
"""represents a student."""
def , name, number):
"""all scores are initially 0."""
self. name = name
self. scores = []
for count in range(number):
self. scores. append(0)
def getname(self):
"""returns the student's name."""
return self. name

def setscore(self, i, score):
"""resets the ith score, counting from 1."""
self. scores[i - 1] = score
def getscore(self, i):
"""returns the ith score, counting from 1."""
return self. scores[i - 1]

def getaverage(self):
"""returns the average score."""
return sum(self. scores) / len(self._scores)

def gethighscore(self):
"""returns the highest score."""
return max(self. scores)

def ):
"""returns the string representation of the student."""
return "name: " + self. name + "\nscores: " + \
" ".join(map(str, self. scores))

# write method definitions here
def main():
"""a simple test."""
student = student("ken", 5)
print(student)
for i in range(1, 6):
student. setscore(i, 100)
print(student)
if __name__ == "__main__":
main()

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 12:10, jefersina16
2. fabulously fit offers memberships for$35 per month plus a $50 enrollmentfee. the fitness studio offersmemberships for $40 per month plus a$35 enrollment fee. in how many monthswill the fitness clubs cost the same? what will the cost be?
Answers: 1
image
Computers and Technology, 24.06.2019 03:30, ilovewaffles70
Auniform resource locator (url) is a formatted string of text that web browsers, email applications, and other software programs use to identify a particular resource on the internet. true false
Answers: 2
image
Computers and Technology, 24.06.2019 10:00, genyjoannerubiera
In which view can you see speaker notes?
Answers: 1
image
Computers and Technology, 24.06.2019 15:30, PresleyPie9452
George is working as a programming team lead. which statements correctly describe the skills that he requires?
Answers: 3
Do you know the correct answer?
Add three methods to the student class that compare twostudent objects. one method ) should test for...

Questions in other subjects:

Konu
English, 06.05.2021 22:40