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]
3 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]3 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
Por favor alguem poderia me falar qual PC e melhor: Computador Gamer Fox PC FPS Intel Core i5 8GB (GeForce GTX 1050Ti 4GB GDDR5)
Ivanshal [37]

Eu acredito no primeiro como ele tem uma GTX 1050ti, i5 e 2tb.

3 0
3 years ago
Any malware software that covertly gathers user information without the user s knowledge, is known as ______ .
shusha [124]
It be known as spyware
3 0
3 years ago
Users in a corporation currently authenticate with a username and password. A security administrator wishes to implement two-fac
Katen [24]

Answer:

Option (C) is the correct answer of this question.

Explanation:

Smart card is the security administrator wishes to implement two-factor authentication to improve security.Normally this data is affiliated with either meaning, information, or both, and will be stored and transmitted within the chip of the card.A smart card, usually a Chip Card type.

  • It is a flexible card that holds an integral computer chip that preserves and sends a signal data, either database or semiconductor form.
  • Used for controlling access to a resource.
  • Data authentication, encryption, cloud storage, and software processing can be established by smart cards.

Other options are incorrect.

4 0
3 years ago
How do you create multiple columns in Word?
mrs_skeptik [129]

Answer:

I think it's B

Explanation:

it sounded right to me.

7 0
3 years ago
What is the difference between a switch's physical interface and the vlan interface?
Andreyy89
<span>Switch's physical interface is something as the name itself suggests itself that it is a physical port to which you can plug in a cable or a wire based on its function and usage where as VLAN interface is no physical port but are created virtually when needed.</span>
4 0
3 years ago
Read 2 more answers
Other questions:
  • A software program that enables users to find and display information stored as html pages on the internet is a(n) ____.
    5·1 answer
  • Is bit stuffing necessary in the control or address field in theHDLC protocol? why?
    13·1 answer
  • Application partitioning gives developers the opportunity to write application code that can later be placed on either a client
    7·1 answer
  • Prepare a risk assessment report (RAR) with information on the threats, vulnerabilities, likelihood of exploitation of security
    14·1 answer
  • What technology did one of the student's have to learn to use in order to help him with his homework in the film, "Disconnected:
    11·2 answers
  • I WILL GIVE BRAINLIEST TO WHO ANSWERS FIRST AND CORRECTLY.
    6·2 answers
  • Name:
    11·1 answer
  • 2. The<br>is the main and usually largest data storage hardware device in a computer​
    9·1 answer
  • One benefit proprietary licensed software is that it
    9·1 answer
  • If “A” represents in binary 10011001, what will be the value of word “CAB”?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!