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
In a paragraph of no less than 125 words, explain what netiquette is and how it improves efficiency and productivity in the work
Pani-rosa [81]

Netiquette actually means "Internet etiquette." Just like etiquette is a code of polite behavior in society, netiquette is a code of good behavior on the Internet. This includes several aspects of the Internet, such as email, sending memos, or basic communication regarding office task.

Now we should note that communication is not just a pivotal part of any organization, it is an integral part of any organization, without communication, an organization will suffer greatly. Communication is said to be effective when the receiver understands the message conveyed just as the sender wanted to,  having said that Netiquette improves efficiency and productivity in the workplace because it creates an avenue for efficient communication which includes clear instructions, fast message delivery, and proper explanation, and this bridges the gap between managers and employees even when they are miles apart. A clear message about a task makes it easier to carry out the said task, thereby resulting in high productivity in the workplace.

7 0
3 years ago
Write two statements to read in values for my_city followed by my_state. Do not provide a prompt. Assign log_entry with current_
Ainat [17]

Answer:

Here is the program:

current_time = '2014-07-26 02:12:18:'  

my_city = ''

my_state = ''

log_entry = ''

 

my_city = input("")   #reads in value for my_city

my_state = input("")  #reads in value for my_state

log_entry = current_time + ' ' + my_city + ' ' + my_state   #concatenates current_time, my_city and my_state values with ' ' empty space between them

 

print(log_entry)

Explanation:

You can also replace

log_entry = current_time + ' ' + my_city + ' ' + my_state  

with

log_entry = f'{current_time} {my_city} {my_state}'

it uses f-strings to format the strings

If you want to hard code the values for my_city and my_state then you can replace the above

my_city = input("")

my_state = input("")

with

my_city = "Houston"

my_state = "Texas"

but if you want to read these values at the console from user then use the input() method.

The screenshot of the program along with the output is attached.

7 0
3 years ago
How many generations of computers languages have there been since the middle of the 20th century
Molodets [167]
<span>There are 4 computer language generations. First is the first generation language or 1GL, second is the second-generation languages or the 2GL, next is the third-generation languages or the 3GL, and the last is fourth-generation languages or the 4GL.</span>
4 0
2 years ago
Read 2 more answers
Which two factors most influenced the growth of the Internet during the 1970s?
eduard

Answer:

The answer is "increase in the power of public universities and increased appreciation for a liberal arts education". DARPA and Russia had nothing to do with this. Yes, the computer hardware improvement led to a growth, but National Science Foundation funding in 1981, and hence this is also not an option. And electrical power supply had nothing to do with this. Hence, the above answer. as the concept of the internet is based on liberal arts of education, to impart practical and intellectual skillsets, and hence to grow the social responsibility among the citizens of the whole world. Also, the power of public universities had a big role to play definitely, and this was confirmed from Pentagon as well then when the question was raised, is this due to the risk of a nuclear attack.

Many people think that the main reason was the nuclear attack threat, but that was not an issue definitely. Actually this was the time of liberalization, and the power of the public universities was increased. Hence, they got the chance to share the information of various sorts with the people, and in the process internet started expanding.

Explanation:

The answer is self explanatory.

8 0
2 years ago
Read 2 more answers
Tim has an old server computer that his company uses as a backup. One of the hard drives has gone bad and needs to be replaced.
algol [13]

Answer: SCSI hard drive.

Explanation:

SCSI means Small Computer System Interface.

It is a fast bus with the capacity to connect a number of devices to a computer system simultaneously, those devices includes printer, scanners, tape drives, hard drives, CD-ROM devices. SCSI helps to connect devices and transfer data in between computer and ancillary devices.

SCSI was invented by the American National Standard Institutes (ANSI)

Common Components of SCSI includes;

• Target.

• Expander.

• Service delivery.

• Initiator.

• Sub system.

3 0
3 years ago
Other questions:
  • Lisa wants to send an email with some confidential Information. Which of these options would work best for her?
    6·1 answer
  • For a class project, Jerome builds a simple circuit with a battery and three light bulbs. On his way to school, Jerome drops his
    9·1 answer
  • What are the two most popular applications of theInternet?
    7·1 answer
  • A teacher wants a program to give extra points to students who fail a test. Write a Python program to do the following: (a) Ask
    5·1 answer
  • The Binder Prime Company wants to recognize the employee who sold the most of its products during a specified period. Write a qu
    12·1 answer
  • What Network does zoom run on? Does anyone use it (hint Hint)
    6·1 answer
  • A debate about city schools are more better than village schools​
    8·1 answer
  • How do we “read” and “write” in MAR and MDR memory unit, please help I am very confused :)
    10·1 answer
  • Byte pair encoding is a data encoding technique. The encoding algorithm looks for pairs of characters that appear in the string
    10·1 answer
  • What is the significance of the scientific method?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!