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
What is it called when an attacker convinces you to enter personal information at an imposter website after receiving an email f
yaroslaw [1]

Answer:

Phishing

Explanation:

Phishing is a type of cyber attack in which the attacker masquerades as a trusted entity via e-mail and trick the recipient into clicking a malicious link that could steal user data including login details, credit card information e.t.c A phishing attack can have devastating effects such as Identity theft, Unauthorised purchase or stealing of funds on individuals.

The common types of phishing are<em>: Vishing, Smishing, Email Phishing, Search Engine Vishing, Whaling</em> e.t.c

3 0
4 years ago
Read 2 more answers
Which option represents the location of the Goal Seek function?
sweet-ann [11.9K]

Answer:b

Explanation:

3 0
3 years ago
Read 2 more answers
When both gears are the same size what will they produce
djverab [1.8K]

They produce a 1:1 ratio.  The input power is equal to the output power.

7 0
4 years ago
2. Which pattern microphone should Jennifer take to the press conference? Jennifer is a journalist with one of the leading newsp
Rudiy27

Answer:

dynamic

Explanation:

4 0
3 years ago
The which command _________________. a. can only be used to search for executables b. searches for a file in all directories sta
dsp73
Answer: D. Searches for a file only in the directories that are in the path variable
6 0
2 years ago
Other questions:
  • Which of the following is not an algorithm?
    8·1 answer
  • Torque is defined as _____.
    7·1 answer
  • Circular errors are caused by adding the cell name of a/an _______ cell to a formula.
    8·1 answer
  • Why are hardline Ethernet connections always faster than WiFi?
    8·1 answer
  • What is scratch in information system .
    14·1 answer
  • Using Word, Maureen is writing an outline of a presentation she plans to give to her company. She will be showing a video during
    12·2 answers
  • When you are cut off in traffic by another driver and you respond by “flipping him the bird,” you are using a type of gesture ca
    7·1 answer
  • Read the following scenario:
    10·2 answers
  • Saujani describes that women are highly underrepresented in STEM careersShe attributes this to women needing more confidence. Wh
    13·1 answer
  • Missing only a few days of school will not impact your grades.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!