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
How does computer number system play a Vital role in a computer calculation. ​
lana [24]

Answer:

When we type some letters or words, the computer translates them in numbers as computers can understand only numbers. A computer can understand the positional number system where there are only a few symbols called digits and these symbols represent different values depending on the position they occupy in the number

Explanation: SAME AS

5 0
3 years ago
To paste text with the same formatting as the document in which it is entered, select _____ from the Paste menu. Keep Source For
SashulF [63]
Copy by command c and paste by command v
5 0
3 years ago
Read 2 more answers
What does the -pwd switch do? how can you make dsadd bring up a prompt asking for the users password?
Leno4ka [110]
Greeting's!

It Will Ask You To Input An Old Password "Current" Password And A "New" Password After That Is Done You Can Use The "New" Password Instead Of The "Old" Password.
3 0
3 years ago
In this unit, you developed your skills at coding in Python. In this lab, you will put those skills to work by creating a progra
Arturiano [62]

Answer:

Don't forget to close any parentheses you open. Other then that everything looks fine, I just polished it a little bit

Explanation:

name = input("What is your first name? ")

print("Hello", name)

age = int(input("How old are you? "))

print("In 10 years you will be", (age+10))

print("In 20 years you will be", (age+20))

print("5 years ago you were", (age-5))

5 0
3 years ago
Read 2 more answers
Children walking on the sidewalk, a person sitting in a parked car, and a parking lot with vehicles
Harlamova29_29 [7]

Answer:

Explanation:

Hello friend !!!!!!!!!!!!

The answer is <u><em>school zone</em></u>

Hope this helps

plz mark as brainliest!!!!!!!

6 0
4 years ago
Other questions:
  • Christine wants to send a quick communication to all department managers. She should send a _____. report
    13·2 answers
  • Up to 10 people is a good guideline for the size of your study group.
    15·1 answer
  • A user has been given Full Control permission to a shared folder. The user has been given Modify permission at the NTFS level to
    11·1 answer
  • Where can I watch infinity war for free?
    9·1 answer
  • The rule of thumb that predicts that the number of transistors on a cpu will double every two years is called ________ law.
    7·1 answer
  • ________________ occur when a system produces incorrect, inconsistent, or duplicate data.
    6·2 answers
  • Type the correct answer in the box.
    5·1 answer
  • What does the FixedUpdate loop do? Why do developers use it?
    14·1 answer
  • If, when asked for a date of birth, the user enters a future date, this error should be caught by a ________ check.
    8·1 answer
  • Informed _________ will better manage complexities and enable more efficient manufacturing of goods.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!