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
Linda subscribes to a cloud service. The service provider hosts the cloud infrastructure and delivers computing resources over t
siniylev [52]

Answer

Public cloud

Explanation

A cloud service is any service that is made available to users who are on demand via internet from the cloud computing service providers.  These service providers have servers in their company premises where they offer the services from.

A public cloud is a type of computing in which a service provider makes resources available to the public via the internet. The service provider hosts the cloud infrastructure and delivers computing resources over the Internet Resources vary by provider but may include storage capabilities, applications or virtual machines.


3 0
3 years ago
Which consumer document is most likely to help you if you have trouble figuring out how to operate a device
kenny6666 [7]
The answe is 'B', as it should contain all the required information on how to operate the device, as well as a troubleshooting guide.
6 0
3 years ago
Define Class in C++. Briefly discuss.
lesya [120]

Answer:

Class are the collection of variable and member function.

Class are the blueprint of an object.

Explanation:

Following are the points regarding class in c++

1.In C++ class is an user defined datatype..

2.Classes are the collection of variable and function in c++.

3.To access the property of class we can create object of that class

4.We can use following syntax to declared any class in c++

class classname

{

accessmodifier:

//statement and function

};

main()

{

classname objectname;

}

implementation of class in c++

#include<iostream>

class test // class declaration

{

public: // access modifier

void fun3() // Method definition

{

cout<<" hello :";

}

};

void main() // main function

{

test ob;// creating object

ob.fun3(); // calling function

}

In this program we declared a class "test " in class test. We giving public access modifier .The public access modifier define that variable and function are accessible outside the class and in main method we create the object ob which call the function fun3().

Output:hello :

3 0
3 years ago
The management of Ventura Inc. approves the purchase of a few computers for the sales team. The management wants only the most b
BaLLatris [955]

Answer:

Ventura Inc requires only System software's

Explanation:

The system software has three major functions which are:

1. File and disk management: this involve managing of files in the system, when user want to save, move, copy, delete and rename files, The system software will handle those task

2. Allocating system resources: The system resources such as time, memory, data input and output are  allocated by the system software. The main memory is managed by the system software to avoid conflict among various task.

3. Monitoring system activities:  The system security and system performance is also monitored by the system software.

The first two functionalities are the requirement of ventura inc  

8 0
3 years ago
An incurred cost that cannot be recovered, which is irrelevant for all decisions about the future, is included in the projected
iragen [17]

Answer:

An incurred cost that cannot be recovered, which is irrelevant for all decisions about the future, is included in the projected cost of a project. According to "Thinking Like an Economist," this an example of:<u> Failing to ignore sunk costs</u>

Explanation:

A sunk cost is a cost that cannot be recovered or changed and is independent of any future costs a business may incur. Since decision-making only affects the future course of business, sunk costs should be irrelevant in the decision-making process

3 0
3 years ago
Other questions:
  • Which is not an example of a boolean operator?
    6·2 answers
  • Given that a function receives three parameters a, b, c, of type double, write some code, to be included as part of the function
    9·1 answer
  • Host to IP address lookup and its reverse lookup option are very important network services for any size network. It is also how
    14·1 answer
  • Adam is evaluating the security of a web server before it goes live. He believes that an issue in the code allows an SQL injecti
    5·1 answer
  • A defensive driver's priority is __<br> A. efficiency<br> B. speed<br> C. handling<br> D. safety
    9·2 answers
  • A customer has a computer for a home business, but wants to have another computer as a web server. What would be the best soluti
    11·2 answers
  • As a general rule, the number of bullet points on a slide should not exceed _____. a.2 b.4 c.8 d.10
    9·1 answer
  • Suppose Client A initiates a Telnet session with Server S. At about the same time, Client B also initiates a Telnet session with
    13·1 answer
  • You press the F9 key to convert an object to a symbol true or false​
    12·1 answer
  • Suppose you want to boot a VM from its virtual DVD drive, but it boots to the VM’s hard drive. Which of the following could be t
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!