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
Explain
Charra [1.4K]

Answer:

The main difference between LAN, MAN and WAN is the scope and coverage of the networks. LAN (Local area network) is usually used to connect computers in smaller distances such as in a building or in offices. They use various topologies such as bus topology, ring topology, star typology etc to connect the computers and share information only among the computers connected in LAN. A Metropolitan Network covers larger coverage than LAN and is usually used for connecting a city rather than single organization. A Wide Area Network is collection of networks or many LANS. The perfect example of WAN is internet which connects thousands and millions of networks. Another factor which distinguishes between LAN, MAN and WAN is that LAN and MAN are owned by certain entities such as government, educational institutions or organizations whereas WAN (i.e. Internet) is not owned by anyone.

4 0
2 years ago
Choose the answer that best completes the
Fiesta28 [93]

Answer:

the information processing cycle

Explanation:

3 0
2 years ago
Read 2 more answers
Check all of the file types that a Slides presentation can be downloaded as.
GuDViN [60]

Answer:

.JPEG

.PDF

.pptx

General Concepts:

<u>Google</u>

  • Slides has an option to download a wide multitude of formats

Explanation:

If we go into File, and then under Download, we should be able to see which file types that a Slides presentation can be downloaded as.

Attached below is an image of the options.

4 0
3 years ago
Read 2 more answers
What type of machine is a hand drill?<br><br> A. Simple machine <br> B. Compound machine
Shalnov [3]
<span>It is a Compound machine.</span>
7 0
3 years ago
Read 2 more answers
How do you add Rulers to a document?: *
swat32

Answer:

a. click on View, then ruler

Explanation:

If you want to add ruler to the document following is the procedure to do it:

Click on View.

Then check the ruler in the group called show.

You will get the ruler in your document.You can also remove it by unchecking the ruler box.

Ruler is used to measure and line up objects.

Hence the answer to this question is option A.

4 0
2 years ago
Other questions:
  • What will happen with communication methods in five years?
    8·1 answer
  • How many bytes of information can be stored on a hard drive?
    7·1 answer
  • When an interrogator speaks highly about how a crime was committed, hoping to get the suspect to brag about his or her involveme
    7·2 answers
  • Biomimicry is the term used when engineers are inspired by objects found in nature? Group of answer choices True False
    10·1 answer
  • (5 points) Create a user-defined data structure (i.e., struct) called Point that represents a two-dimensional Cartesian coordina
    5·1 answer
  • A=1/2h(a+b) solve for h
    6·1 answer
  • (I need help also can u guys just give me some example just in case I got confuse)
    13·1 answer
  • Which of the following substances increases in quantity during repititive muscle contraction during oxygen deficti ?
    11·1 answer
  • Write a program to Test if mold is stored in the variable word.
    5·1 answer
  • Write a program using LinkedList class and ListIterator interface to demonstrate the following activities:
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!