1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Salsk061 [2.6K]
4 years ago
15

Add three methods to the Student class that compare twoStudent objects. One method (__eq__) should test for equality. A second m

ethod (__lt__) should test for less than. The third method (__ge__) 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.
Computers and Technology
1 answer:
shusha [124]4 years ago
5 0

Answer:

class Student(object):

def __init__(self, name, number):

self.name = name

self.scores = []

for count in range(number):

self.scores.append(0)

 

def getName(self):

 

return self.name

 

def setScore(self, i, score):

 

self.scores[i - 1] = score

 

def getScore(self, i):

 

return self.scores[i - 1]

 

def getAverage(self):

 

return sum(self.scores) / len(self._scores)

 

def getHighScore(self):

 

return max(self.scores)

def __eq__(self,student):

return self.name == student.name

 

def __ge__(self,student):

return self.name == student.name or self.name>student.name

 

def __lt__(self,student):

return self.name<student.name

 

def __str__(self):

return "Name: " + self.name + "\nScores: " + \

" ".join(map(str, self.scores))

 

 

def main():

student = Student("Ken", 5)

print(student)

for i in range(1, 6):

student.setScore(i, 100)

print(student)

 

print("\nSecond student")

student2 = Student("Ken", 5)

print(student2)

 

print("\nThird student")

student3 = Student("Amit", 5)

print(student3)

 

print("\nChecking equal student1 and student 2")

print(student.__eq__(student2))

 

print("\nChecking equal student1 and student 3")

print(student.__eq__(student3))

 

print("\nChecking greater than equal student1 and student 3")

print(student.__ge__(student3))

 

print("\nChecking less than student1 and student 3")

print(student.__lt__(student3))

if __name__ == "__main__":

You might be interested in
What describes the current cloud landscape for business?
KonstantinChe [14]

Answer:

Organizations need to change the vast majority of their tasks to the cloud to stay competitive describes the current Cloud landscape for business

Explanation:

All cloud computing frameworks are effectively open over the web with minimal requirement for actual equipment other than cloud servers at the back end.

5 0
3 years ago
Pls help computer science I will give brainliest
marissa [1.9K]

Answer:

A driver assists with hardware management.

Hope this helped.

5 0
3 years ago
Read 2 more answers
In which order do the DHCP messages occur when a client and server are negotiating address configuration?
Leona [35]
One two three and four
8 0
3 years ago
You want to draw a rectangle over the moon you added to your slide and then move it behind the moon. You want it to look like a
Ray Of Light [21]
I choose Home and it’s a good thing to have
5 0
3 years ago
The database contents might be loaded interactively or in batch mode using a variety of methods and devices including customized
oksian1 [2.3K]

Answer:

The answer is "Option A".

Explanation:

Database information is a storage file, that contains material for the SharePoint web application for one or more sets of sites. This content may include websites, files, documents, photographs and more. In this storage file a data store in batch mode, which uses a variety of different methods and tools, like custom software programs, that's why the given statement is "True".

4 0
3 years ago
Other questions:
  • What was the name of the system developed by Frederick Winslow Taylor, in which mass production is tied to the cultivation of ma
    10·1 answer
  • Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follo
    13·1 answer
  • Let X and Y be two decision problems. Suppose we know that X reduces to Yin polynomial time. Which of the following statements a
    14·1 answer
  • I'll give brainlyist
    9·2 answers
  • Select the correct answer. Which of these is a game-centric handheld gaming console? A. IPad B. iPhone C. PSVita D. Xbox ​
    9·2 answers
  • After a business transaction has been analyzed, which of the following must occur for the analysis to have been done correctly?
    9·1 answer
  • How do you think Beyoncé choreography has/will influence the future of dance?
    9·2 answers
  • What is computer system ?​
    9·2 answers
  • Sidney needs to create a decimal number variable that will be added to another number. What kind of variable is required?binaryB
    15·1 answer
  • A Social agency hires Accenture to improve training and experiences for caseworkers. What is one way Accenture can use Virtual R
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!