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
Wendy wants to learn how to write a computer program that can get the dimensions of a rectangle from the user and then tell the
otez555 [7]

Answer:

algorithms for finding the area

Explanation:

you need algorithms to find out any computer input information.

4 0
3 years ago
Read 2 more answers
To create a public key signature, you would use the ______ key.
olya-2409 [2.1K]

Answer:

To create a public key signature, you would use the <u>_private_</u> key.

Explanation:

To create a public key signature, a  private key is essential to enable authorization.

A private key uses one key to make data unreadable by intruders and for the data to be accessed the same key would be needed to do so.

The login details and some important credentials to access user data contains both the user's public key data and private key data. Both private key and public key are two keys that work together to accomplish security goals.

The public key uses different keys to make data readable and unreadable.

The public key is important to verify authorization to access encrypted data by making sure the access authorization came from someone who has the private key. In other words, it's a system put in place to cross-check the holder of the private key by providing the public key of the encrypted data that needed to be accessed. Though, it depends on the key used to encrypt the data as data encrypted with a public key would require a private key for the data to be readable.

4 0
3 years ago
How do cameras work? Explain in 2-3 sentences.
FinnZ [79.3K]

Answer:

In a digital camera, exactly the opposite happens. Light from the thing you are photographing zooms into the camera lens. This incoming "picture" hits the image sensor chip, which breaks it up into millions of pixels. The sensor measures the color and brightness of each pixel and stores it as a number.

Explanation:

3 0
2 years ago
Describe the purpose of working directory and how it can be speed or slow file access
Cloud [144]

Explanation:

The working directory is just a file path on your computer that sets the default location of any files you read. If you want to read a file 'file.txt'.

6 0
1 year ago
Which word best completes the comparison of Beowulf and Grendel?
Hatshy [7]

Answer:

sympathetic

Explanation:

If you will have a go at Beowulf, you will find that Grendel is a dangerous demon for whom humanity means nothing, and people for him are just like something that is to be eaten. However, when you will have a go at Grendel, you will find that he is not just a beast without the brain, as he does have affection and conception.

4 0
3 years ago
Read 2 more answers
Other questions:
  • a supermarket having a sale on canned foods' the sale includes 12 cans of soup for 10.65 what is the unit price per can of soup
    6·2 answers
  • A customer has contacted you to help him alleviate the large amount of time and effort that goes into adding and removing users
    12·1 answer
  • What is a special class of adware that collects data about the user and transmits it over the Internet without the user’s knowle
    14·1 answer
  • An example of a current disruptive technology is a?
    8·2 answers
  • What are html documents also called?
    12·1 answer
  • Jeremy has created a document that has images and a chart. The chart has to be updated manually, and double-clicking on the char
    15·1 answer
  • The National Archives is part of the federal government, which means that its content:
    9·1 answer
  • What is digital scavenger hunting? A. An application that locates addresses B. A scavenger hunt where players use GPS and digita
    5·1 answer
  • Francisco is becoming a dad for the first time. He feels relatively clueless about all things involving parenting and is looking
    12·1 answer
  • imagine that you are explaining the art of visual comparison to a group of photography students. You are mentoring. What do you
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!